@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.
- package/CHANGELOG.md +64 -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/extractRequestedIntervals.d.ts +29 -9
- package/dist/analysis/extractRequestedIntervals.d.ts.map +1 -1
- package/dist/analysis/extractRequestedIntervals.js +173 -42
- package/dist/analysis/extractRequestedIntervals.js.map +1 -1
- package/dist/analysis/index.d.ts +1 -0
- package/dist/analysis/index.d.ts.map +1 -1
- package/dist/analysis/index.js +1 -0
- package/dist/analysis/index.js.map +1 -1
- 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/api.d.ts.map +1 -1
- package/dist/api.js +12 -3
- package/dist/api.js.map +1 -1
- package/dist/diagnostics.d.ts +6 -2
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/manifest.d.ts +2 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +4 -0
- package/dist/manifest.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +57 -1
- package/dist/program.js.map +1 -1
- package/dist/transformers/callsiteIdInjection.d.ts.map +1 -1
- package/dist/transformers/callsiteIdInjection.js +8 -1
- 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/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,69 @@
|
|
|
1
1
|
# @invinite-org/chartlang-compiler
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e620ba8: Add `bgcolor(color, opts?)` and `barcolor(color, opts?)` — Pine-ergonomic
|
|
8
|
+
top-level aliases for the `bg-color` / `bar-color` plot styles. One call
|
|
9
|
+
(`bgcolor(close > open ? "#16a34a" : "#dc2626", { transp: 80 })`) replaces
|
|
10
|
+
the verbose `plot(NaN, { style: { kind: "bg-color", … } })`. Surfaced in the
|
|
11
|
+
generated primitive reference and taught in the chartlang-coding skill.
|
|
12
|
+
|
|
13
|
+
Deliverable 2 (per-bar dynamic color): `PlotEmission` gains an optional
|
|
14
|
+
`colorValue: Color | null` channel; the runtime resolves the `bgcolor` /
|
|
15
|
+
`barcolor` per-bar color into it (omitted on the static `plot` path → wire
|
|
16
|
+
byte-identical, every pinned `plot-hash` untouched), validates it
|
|
17
|
+
(non-empty color string or `null`), and dedups it last-write-wins per
|
|
18
|
+
`(slotId, bar)` like `value`. Adapters prefer `colorValue` over the static
|
|
19
|
+
`style.color` at render time — this precedence is now the normative
|
|
20
|
+
adapter-kit contract (`PlotEmission.colorValue` JSDoc) and is implemented in
|
|
21
|
+
the canvas2d reference renderer (`null` ⇒ paint-nothing gap; omitted ⇒ static
|
|
22
|
+
fallback). The Pine converter emits the real per-bar dynamic color
|
|
23
|
+
(`bgcolor(close > open ? "#16a34a" : "#dc2626")`) instead of a static
|
|
24
|
+
`plot(NaN, …)`, so `bgcolor`/`barcolor` round-trip with per-bar semantics
|
|
25
|
+
intact.
|
|
26
|
+
|
|
27
|
+
- 08cba38: Add `time.*` calendar accessors (`time.year/month/dayofmonth/dayofweek/hour/
|
|
28
|
+
minute/second/timestamp`), a `time.timeClose(t, tz?)` bar-close accessor
|
|
29
|
+
(Pine's `time_close()` = bar start + interval), a `session.isOpen(t, spec, tz?)`
|
|
30
|
+
helper, and an `input.session` kind. Calendar fields are derived from a `Time`
|
|
31
|
+
epoch via the host (authors stay sandboxed — `Date`/`Intl` remain banned). v1
|
|
32
|
+
is UTC + fixed-offset only; exchange-tz/DST is a scoped follow-up. The Pine
|
|
33
|
+
converter lowers `dayofweek` / `time()` / `time_close()` / `input.session`.
|
|
34
|
+
- 1efb49c: Add multi-symbol support to `request.security`. `request.security({ symbol,
|
|
35
|
+
interval })` now reads a **different instrument** (not just a higher
|
|
36
|
+
timeframe), e.g. `request.security({ symbol: "AMEX:SPY", interval: "1D" })`.
|
|
37
|
+
`symbol` is optional (defaults to the chart symbol) and must be a compile-time
|
|
38
|
+
literal (`input.symbol` / `input.enum` resolved). A new `multiSymbol` adapter
|
|
39
|
+
capability gates non-chart-symbol requests: a different-symbol request against
|
|
40
|
+
an adapter declaring `multiSymbol: false` degrades to an all-NaN
|
|
41
|
+
bar/series with a single deduped `multi-symbol-not-supported` diagnostic,
|
|
42
|
+
mirroring `multi-timeframe-not-supported` (the symbol gate precedes the
|
|
43
|
+
timeframe gate, so a both-different request emits only the symbol diagnostic).
|
|
44
|
+
The Pine converter now lowers `request.security("OTHER", tf, expr)`, and the
|
|
45
|
+
`chartlang scaffold-adapter` template advertises `multiSymbol`.
|
|
46
|
+
- 1efb49c: Add `state.array<T>(capacity)` — a persistent, bounded FIFO collection. Push
|
|
47
|
+
many values across bars (`a.push(v)`) into a fixed-capacity ring and read
|
|
48
|
+
them back by element (`a.get(0)` = newest, `a.last()`, `a.size`,
|
|
49
|
+
`a.capacity`, `a.clear()`). Bounded literal capacity keeps it
|
|
50
|
+
serialization-clean. The Pine converter lowers a bounded numeric
|
|
51
|
+
`var array<…>` Camp B ring to it.
|
|
52
|
+
|
|
53
|
+
The compiler guards the capacity: it must be a compile-time numeric literal
|
|
54
|
+
(a `const` numeric binding is accepted) that is a positive integer within
|
|
55
|
+
`MAX_STATE_ARRAY_CAPACITY` (100_000). A non-literal capacity errors
|
|
56
|
+
`state-array-capacity-not-literal`; an out-of-range / non-integer literal
|
|
57
|
+
errors `state-array-capacity-exceeds-max`.
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Updated dependencies [e620ba8]
|
|
62
|
+
- Updated dependencies [08cba38]
|
|
63
|
+
- Updated dependencies [1efb49c]
|
|
64
|
+
- Updated dependencies [1efb49c]
|
|
65
|
+
- @invinite-org/chartlang-core@1.3.0
|
|
66
|
+
|
|
3
67
|
## 1.3.0
|
|
4
68
|
|
|
5
69
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractDependencyGraph.d.ts","sourceRoot":"","sources":["../../src/analysis/extractDependencyGraph.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,KAAK,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAE7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,GACjB,QAAQ,CAAC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,GACpD,QAAQ,CAAC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,aAAa,C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;CACtD,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,gBAAgB,GAAG,IAAI,CAAC;AAElG;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC3C,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAChD,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC1D,CAAC,CAAC;AAuYH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAClC,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,aAAa,CAAC,qBAAqB,CAAC,EACxD,eAAe,EAAE,eAAe,GACjC,QAAQ,CAsUV"}
|
|
@@ -70,7 +70,15 @@ function extractBindingOutputs(binding, sourceFile, checker, sourcePath, diagnos
|
|
|
70
70
|
const visit = (node) => {
|
|
71
71
|
if (ts.isCallExpression(node)) {
|
|
72
72
|
const callee = resolveCalleeName(node, checker);
|
|
73
|
-
|
|
73
|
+
// `bgcolor`/`barcolor` are plot-producing callees, so a binding
|
|
74
|
+
// that only paints a background still counts as "produces plots"
|
|
75
|
+
// (drives the `dep-output-not-titled` guard). Their `title` opt is
|
|
76
|
+
// a plot label, NOT a `.output()`-referenceable series-number, so
|
|
77
|
+
// they never add a titled output nor trip `duplicate-output-title`.
|
|
78
|
+
if (callee === "bgcolor" || callee === "barcolor") {
|
|
79
|
+
hasUntitledPlot = true;
|
|
80
|
+
}
|
|
81
|
+
else if (callee === "plot") {
|
|
74
82
|
const optsArg = node.arguments[1];
|
|
75
83
|
let title;
|
|
76
84
|
if (optsArg !== undefined && ts.isObjectLiteralExpression(optsArg)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractDependencyGraph.js","sourceRoot":"","sources":["../../src/analysis/extractDependencyGraph.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAA0B,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAyJrE;;;;GAIG;AACH,SAAS,eAAe,CAAC,IAAmB;IACxC,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC;IAC/C,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,YAAY;QAAE,OAAO,KAAK,CAAC;IAC3D,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IACzD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,UAA6B;IAClD,MAAM,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACpC,oBAAoB;IACpB,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,EAAE,CAAC,yBAAyB,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACzE,MAAM,eAAe,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QACrD,MAAM,IAAI,GAAI,QAAuC,CAAC,IAAI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S,CAAC,MAAM,CAAC,CAAC;YACvC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtB,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,oBAAoB,CAAC,IAAI,GAAG,EAAU,CAAC;YAChF,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;QACvE,CAAC;IACL,CAAC,CAAC;IAEF,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK;YAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { JsonValue, OutputDeclaration } from \"@invinite-org/chartlang-core\";\nimport ts from \"typescript\";\n\nimport { type CompileDiagnostic, createDiagnostic } from \"../diagnostics.js\";\nimport { resolveCalleeName } from \"../transformers/resolveCallee.js\";\nimport type { StructuralBindingInfo } from \"./structuralChecks.js\";\n\n/**\n * Producer reference recorded on a consumer-side `const` binding. The\n * same-file variant carries the local binding name; the cross-file\n * variant carries the resolved POSIX path + ES-module export name.\n *\n * @since 0.7\n * @stable\n * @example\n * const r: ProducerRef = { kind: \"same-file\", bindingName: \"baseTrend\" };\n * void r;\n */\nexport type ProducerRef =\n | Readonly<{ kind: \"same-file\"; bindingName: string }>\n | Readonly<{ kind: \"cross-file\"; sourcePath: string; exportName: string }>;\n\n/**\n * One dep-graph edge — consumer binding → producer with the merged\n * effective inputs the bundler needs to fold into the producer's\n * compiled module at emit time.\n *\n * @since 0.7\n * @stable\n * @example\n * declare const dummyOutputs: ReadonlyArray<OutputDeclaration>;\n * const e: DepConsumesEntry = {\n * localId: \"fastTrend\",\n * producerRef: { kind: \"same-file\", bindingName: \"baseTrend\" },\n * outputs: dummyOutputs,\n * effectiveInputs: { length: 20 },\n * };\n * void e;\n */\nexport type DepConsumesEntry = Readonly<{\n readonly localId: string;\n readonly producerRef: ProducerRef;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly effectiveInputs: Readonly<Record<string, JsonValue>>;\n}>;\n\n/**\n * One exported (drawn) indicator the file declares. `exportName` is\n * `\"default\"` for `export default`, the identifier text otherwise.\n *\n * @since 0.7\n * @stable\n * @example\n * // declare const callExpression: ts.CallExpression;\n * const d: DrawnScript = {\n * exportName: \"default\",\n * bindingName: \"default\",\n * defineCall: undefined as unknown as ts.CallExpression,\n * outputs: [],\n * consumes: [],\n * };\n * void d;\n */\nexport type DrawnScript = Readonly<{\n readonly exportName: string;\n readonly bindingName: string;\n readonly defineCall: ts.CallExpression;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly consumes: ReadonlyArray<DepConsumesEntry>;\n}>;\n\n/**\n * One private (data-only) dep binding the file declares. `defineCall`\n * is `null` when the dep is a cross-file binding (the AST node lives\n * in the producer's source file).\n *\n * @since 0.7\n * @stable\n * @example\n * const d: PrivateDep = {\n * localId: \"fastTrend\",\n * producerRef: { kind: \"same-file\", bindingName: \"baseTrend\" },\n * effectiveInputs: { length: 20 },\n * defineCall: null,\n * outputs: [],\n * consumes: [],\n * };\n * void d;\n */\nexport type PrivateDep = Readonly<{\n readonly localId: string;\n readonly producerRef: ProducerRef;\n readonly effectiveInputs: Readonly<Record<string, JsonValue>>;\n readonly defineCall: ts.CallExpression | null;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly consumes: ReadonlyArray<DepConsumesEntry>;\n}>;\n\n/**\n * Producer snapshot returned by `resolveProducer` for cross-file\n * `import X from \"./Y.chart\"` consumer references.\n *\n * @since 0.7\n * @stable\n * @example\n * const snap: ProducerSnapshot = { name: \"trend\", outputs: [], inputs: {} };\n * void snap;\n */\nexport type ProducerSnapshot = Readonly<{\n readonly name: string;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly inputs: Readonly<Record<string, unknown>>;\n}>;\n\n/**\n * Callback the bundler supplies so the analysis pass can recursively\n * compile sibling `.chart.ts` files. Returns `null` when the producer\n * cannot be resolved (cycle, unknown path, no `defineIndicator(...)`).\n *\n * @since 0.7\n * @stable\n * @example\n * const r: ResolveProducer = () => null;\n * void r;\n */\nexport type ResolveProducer = (sourcePath: string, exportName: string) => ProducerSnapshot | null;\n\n/**\n * The compiled dep-graph artefact returned by `extractDependencyGraph`.\n * `drawn` + `privateDeps` are the indexed binding sets; `diagnostics`\n * is the union of every per-binding diagnostic surfaced during\n * walking + validation.\n *\n * @since 0.7\n * @stable\n * @example\n * const g: DepGraph = { drawn: [], privateDeps: [], diagnostics: [] };\n * void g;\n */\nexport type DepGraph = Readonly<{\n readonly drawn: ReadonlyArray<DrawnScript>;\n readonly privateDeps: ReadonlyArray<PrivateDep>;\n readonly diagnostics: ReadonlyArray<CompileDiagnostic>;\n}>;\n\ntype BindingOutputs = Readonly<{\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly hasUntitledPlot: boolean;\n}>;\n\ntype DepConsumesMutable = {\n localId: string;\n producerRef: ProducerRef;\n outputs: ReadonlyArray<OutputDeclaration>;\n effectiveInputs: Readonly<Record<string, JsonValue>>;\n};\n\n/**\n * Read a JSON-clean literal from a TS expression — number, string,\n * boolean, or null. Returns `undefined` for non-literal expressions\n * (identifiers, computed access, calls, …).\n */\nfunction readJsonLiteral(node: ts.Expression): JsonValue | undefined {\n if (ts.isNumericLiteral(node)) return Number(node.text);\n if (ts.isStringLiteral(node)) return node.text;\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false;\n if (node.kind === ts.SyntaxKind.NullKeyword) return null;\n return undefined;\n}\n\n/**\n * Read the function body the `compute` property assignment of a\n * `define*({ compute })` call literal points at. Returns `null` when\n * the property is missing or non-function (treat as zero plot calls).\n *\n * Handles both arrow functions (`compute: () => {}`) and method\n * shorthand (`compute() {}`).\n */\nfunction readComputeBody(defineCall: ts.CallExpression): ts.Node | null {\n const arg = defineCall.arguments[0];\n /* v8 ignore next */\n if (arg === undefined || !ts.isObjectLiteralExpression(arg)) return null;\n const computeProperty = arg.properties.find((property) => {\n const name = (property as { name?: ts.PropertyName }).name;\n return name !== undefined && ts.isIdentifier(name) && name.text === \"compute\";\n });\n if (computeProperty === undefined) return null;\n if (ts.isPropertyAssignment(computeProperty)) {\n const initializer = computeProperty.initializer;\n return ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)\n ? initializer.body\n : null;\n }\n /* v8 ignore start */\n if (ts.isMethodDeclaration(computeProperty)) {\n return computeProperty.body ?? null;\n }\n return null;\n}\n/* v8 ignore stop */\n\n/**\n * Sweep D — extract producer outputs from `plot(value, { title })`\n * calls inside the binding's compute body. Emits\n * `duplicate-output-title` for clashes.\n */\nfunction extractBindingOutputs(\n binding: StructuralBindingInfo,\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n sourcePath: string,\n diagnostics: CompileDiagnostic[],\n): BindingOutputs {\n const body = readComputeBody(binding.defineCall);\n const outputs: OutputDeclaration[] = [];\n const seenTitles = new Set<string>();\n let hasUntitledPlot = false;\n\n /* v8 ignore next 3 */\n if (body === null) {\n return Object.freeze({ outputs: Object.freeze(outputs.slice()), hasUntitledPlot });\n }\n\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node)) {\n const callee = resolveCalleeName(node, checker);\n if (callee === \"plot\") {\n const optsArg = node.arguments[1];\n let title: string | undefined;\n if (optsArg !== undefined && ts.isObjectLiteralExpression(optsArg)) {\n for (const property of optsArg.properties) {\n /* v8 ignore next */\n if (!ts.isPropertyAssignment(property)) continue;\n const propertyName = property.name;\n if (!ts.isIdentifier(propertyName) || propertyName.text !== \"title\") {\n continue;\n }\n const initializer = property.initializer;\n /* v8 ignore next */\n if (!ts.isStringLiteral(initializer)) continue;\n title = initializer.text;\n }\n }\n if (title === undefined) {\n hasUntitledPlot = true;\n } else if (seenTitles.has(title)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"duplicate-output-title\",\n message: `\\`${binding.bindingName}\\` declares two outputs titled \"${title}\". Titles must be unique within a script.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n } else {\n seenTitles.add(title);\n outputs.push(Object.freeze({ title, kind: \"series-number\" as const }));\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n ts.forEachChild(body, visit);\n return Object.freeze({ outputs: Object.freeze(outputs.slice()), hasUntitledPlot });\n}\n\ntype ChainResolution = Readonly<{\n readonly root: ts.Identifier;\n readonly inputs: Readonly<Record<string, JsonValue>>;\n readonly ok: boolean;\n}>;\n\n/**\n * Sweep B — resolve a `<binding>.withInputs({...}).withInputs({...})`\n * chain back to its rooted identifier and the merged effective-inputs\n * map. Emits `dep-dynamic` / `dep-invalid-input-override` for invalid\n * argument shapes.\n */\nfunction resolveWithInputsChain(\n expression: ts.Expression,\n sourceFile: ts.SourceFile,\n sourcePath: string,\n diagnostics: CompileDiagnostic[],\n): ChainResolution | null {\n type Layer = { args: ts.ObjectLiteralExpression; ok: boolean };\n const layers: Layer[] = [];\n let current: ts.Expression = expression;\n while (ts.isCallExpression(current)) {\n const callee = current.expression;\n /* v8 ignore next 2 */\n if (!ts.isPropertyAccessExpression(callee)) return null;\n if (callee.name.text !== \"withInputs\") return null;\n const arg = current.arguments[0];\n if (arg === undefined || !ts.isObjectLiteralExpression(arg)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message:\n \"`.withInputs(...)` requires an object literal with literal-only property values.\",\n file: sourcePath,\n node: arg ?? /* v8 ignore next */ current,\n sourceFile,\n }),\n );\n layers.unshift({ args: ts.factory.createObjectLiteralExpression([]), ok: false });\n } else {\n layers.unshift({ args: arg, ok: true });\n }\n current = callee.expression;\n }\n /* v8 ignore next */\n if (!ts.isIdentifier(current)) return null;\n\n const merged: Record<string, JsonValue> = {};\n let ok = true;\n for (const layer of layers) {\n if (!layer.ok) {\n ok = false;\n continue;\n }\n for (const property of layer.args.properties) {\n if (!ts.isPropertyAssignment(property)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message:\n \"`.withInputs(...)` requires a plain object literal — no spread, shorthand, or computed keys.\",\n file: sourcePath,\n node: property,\n sourceFile,\n }),\n );\n ok = false;\n continue;\n }\n const key = property.name;\n if (!ts.isIdentifier(key) && !ts.isStringLiteral(key)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message: \"`.withInputs(...)` keys must be identifiers or string literals.\",\n file: sourcePath,\n node: key,\n sourceFile,\n }),\n );\n ok = false;\n continue;\n }\n const literal = readJsonLiteral(property.initializer);\n if (literal === undefined) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message: `\\`.withInputs({ ${key.text}: ... })\\` value must be a JSON literal (number, string, boolean, or null).`,\n file: sourcePath,\n node: property.initializer,\n sourceFile,\n }),\n );\n ok = false;\n continue;\n }\n merged[key.text] = literal;\n }\n }\n return Object.freeze({\n root: current,\n inputs: Object.freeze({ ...merged }),\n ok,\n });\n}\n\n/**\n * Validate an `effectiveInputs` map against the producer's `inputs`\n * schema. Each producer-input descriptor is shaped like\n * `{ kind: \"int\", defaultValue: 14, ... }`. Type-mismatch and unknown\n * keys both emit `dep-invalid-input-override`.\n */\nfunction validateInputOverrides(\n bindingName: string,\n inputs: Readonly<Record<string, JsonValue>>,\n producerInputs: Readonly<Record<string, unknown>>,\n node: ts.Node,\n sourceFile: ts.SourceFile,\n sourcePath: string,\n diagnostics: CompileDiagnostic[],\n): void {\n for (const [key, value] of Object.entries(inputs)) {\n const descriptor = producerInputs[key];\n if (descriptor === undefined) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-invalid-input-override\",\n message: `\\`${bindingName}\\` overrides input \"${key}\" which the producer does not declare.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n continue;\n }\n const expectedKind =\n typeof descriptor === \"object\" && descriptor !== null && \"kind\" in descriptor\n ? (descriptor as { kind: unknown }).kind\n : undefined;\n if (typeof expectedKind === \"string\") {\n const valueType = describeJsonValueKind(value);\n const expectedType = expectedTypeForKind(expectedKind);\n if (expectedType !== null && expectedType !== valueType) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-invalid-input-override\",\n message: `\\`${bindingName}\\` override for \"${key}\" expects ${expectedType} (producer declared \\`${expectedKind}\\`), received ${valueType}.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n }\n }\n }\n}\n\nfunction describeJsonValueKind(value: JsonValue): string {\n if (value === null) return \"null\";\n /* v8 ignore next */\n if (Array.isArray(value)) return \"array\";\n return typeof value;\n}\n\nconst KIND_TO_VALUE_TYPE: ReadonlyMap<string, string> = new Map([\n [\"int\", \"number\"],\n [\"float\", \"number\"],\n [\"price\", \"number\"],\n [\"time\", \"number\"],\n [\"string\", \"string\"],\n [\"enum\", \"string\"],\n [\"color\", \"string\"],\n [\"symbol\", \"string\"],\n [\"interval\", \"string\"],\n [\"bool\", \"boolean\"],\n]);\n\nfunction expectedTypeForKind(kind: string): string | null {\n return KIND_TO_VALUE_TYPE.get(kind) ?? null;\n}\n\n/**\n * Walk back from a `<receiver>.output(\"title\")` callee to a same-file\n * binding identifier OR an imported identifier — whichever applies.\n * Returns the underlying identifier or `null` when the receiver is a\n * non-resolvable shape (computed access, call result, etc.).\n */\nfunction resolveOutputReceiverRoot(receiver: ts.Expression): ts.Identifier | null {\n if (ts.isIdentifier(receiver)) return receiver;\n return null;\n}\n\nfunction originIsImport(symbol: ts.Symbol): {\n moduleSpecifier: string;\n exportName: string;\n} | null {\n const declarations = symbol.declarations ?? /* v8 ignore next */ [];\n for (const declaration of declarations) {\n if (ts.isImportClause(declaration)) {\n const importDecl = declaration.parent;\n const specifier = importDecl.moduleSpecifier;\n /* v8 ignore next */\n if (!ts.isStringLiteral(specifier)) continue;\n return { moduleSpecifier: specifier.text, exportName: \"default\" };\n }\n if (ts.isImportSpecifier(declaration)) {\n const importDecl = declaration.parent.parent.parent;\n const specifier = importDecl.moduleSpecifier;\n /* v8 ignore next */\n if (!ts.isStringLiteral(specifier)) continue;\n const exportName = declaration.propertyName?.text ?? declaration.name.text;\n return { moduleSpecifier: specifier.text, exportName };\n }\n }\n return null;\n}\n\ntype ResolvedBinding =\n | Readonly<{ kind: \"same-file\"; binding: StructuralBindingInfo }>\n | Readonly<{\n kind: \"cross-file\";\n sourcePath: string;\n exportName: string;\n snapshot: ProducerSnapshot;\n }>;\n\nfunction resolveBinding(\n identifier: ts.Identifier,\n checker: ts.TypeChecker,\n bindingsByName: ReadonlyMap<string, StructuralBindingInfo>,\n resolveProducer: ResolveProducer,\n): ResolvedBinding | null {\n const sameFile = bindingsByName.get(identifier.text);\n if (sameFile !== undefined) {\n return Object.freeze({ kind: \"same-file\", binding: sameFile });\n }\n const symbol = checker.getSymbolAtLocation(identifier);\n /* v8 ignore next */\n if (symbol === undefined) return null;\n const importOrigin = originIsImport(symbol);\n if (importOrigin === null) return null;\n const snapshot = resolveProducer(importOrigin.moduleSpecifier, importOrigin.exportName);\n if (snapshot === null) return null;\n return Object.freeze({\n kind: \"cross-file\",\n sourcePath: importOrigin.moduleSpecifier,\n exportName: importOrigin.exportName,\n snapshot,\n });\n}\n\n/**\n * Run the dependency-graph analysis pass over a `.chart.ts` source\n * file. Sweeps the AST four times — outputs, withInputs chains,\n * consumer `.output(...)` calls, cycle detection — and returns a\n * frozen `DepGraph` plus the diagnostics surfaced along the way.\n *\n * `resolveProducer` is a caller-supplied callback that the bundler\n * (Task 3) wires to a recursive compile entry point. In Task 2 the\n * pass works against `() => null` for cross-file edges; tests pass\n * mocked snapshots instead.\n *\n * @since 0.7\n * @stable\n * @example\n * // const graph = extractDependencyGraph(sf, checker, \"demo.chart.ts\", bindings, () => null);\n * const fn: typeof extractDependencyGraph = extractDependencyGraph;\n * void fn;\n */\nexport function extractDependencyGraph(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n sourcePath: string,\n structuralBindings: ReadonlyArray<StructuralBindingInfo>,\n resolveProducer: ResolveProducer,\n): DepGraph {\n const diagnostics: CompileDiagnostic[] = [];\n const bindingsByName = new Map<string, StructuralBindingInfo>();\n for (const binding of structuralBindings) {\n if (binding.exportKind === \"default\") continue;\n bindingsByName.set(binding.bindingName, binding);\n }\n\n const outputsByBinding = new Map<string, BindingOutputs>();\n for (const binding of structuralBindings) {\n outputsByBinding.set(\n binding.bindingName,\n extractBindingOutputs(binding, sourceFile, checker, sourcePath, diagnostics),\n );\n }\n\n type BindingEffectiveInputs = Readonly<{\n rootName: string;\n rootBinding: ResolvedBinding | null;\n inputs: Readonly<Record<string, JsonValue>>;\n }>;\n const effectiveInputsByBinding = new Map<string, BindingEffectiveInputs>();\n\n for (const statement of sourceFile.statements) {\n if (!ts.isVariableStatement(statement)) continue;\n for (const declaration of statement.declarationList.declarations) {\n /* v8 ignore next */\n if (!ts.isIdentifier(declaration.name)) continue;\n const initializer = declaration.initializer;\n if (initializer === undefined) continue;\n if (!ts.isCallExpression(initializer)) continue;\n const callee = initializer.expression;\n if (ts.isPropertyAccessExpression(callee) && callee.name.text === \"withInputs\") {\n const chain = resolveWithInputsChain(\n initializer,\n sourceFile,\n sourcePath,\n diagnostics,\n );\n /* v8 ignore next */\n if (chain === null) continue;\n const root = resolveBinding(chain.root, checker, bindingsByName, resolveProducer);\n effectiveInputsByBinding.set(declaration.name.text, {\n rootName: chain.root.text,\n rootBinding: root,\n inputs: chain.inputs,\n });\n if (root !== null && chain.ok) {\n const producerInputs = root.kind === \"cross-file\" ? root.snapshot.inputs : {};\n validateInputOverrides(\n declaration.name.text,\n chain.inputs,\n producerInputs,\n initializer,\n sourceFile,\n sourcePath,\n diagnostics,\n );\n }\n }\n }\n }\n\n const consumesByBinding = new Map<string, DepConsumesMutable[]>();\n for (const binding of structuralBindings) {\n consumesByBinding.set(binding.bindingName, []);\n }\n\n for (const binding of structuralBindings) {\n const body = readComputeBody(binding.defineCall);\n if (body === null) continue;\n const consumerConsumes = consumesByBinding.get(binding.bindingName);\n /* v8 ignore next */\n if (consumerConsumes === undefined) continue;\n const seenLocalIds = new Set<string>();\n const visit = (node: ts.Node): void => {\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === \"output\"\n ) {\n const arg = node.arguments[0];\n if (arg === undefined || !ts.isStringLiteral(arg)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message:\n \"`<binding>.output(...)` requires a single string-literal argument.\",\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n ts.forEachChild(node, visit);\n return;\n }\n const title = arg.text;\n const root = resolveOutputReceiverRoot(node.expression.expression);\n if (root === null) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message:\n \"`.output(...)` receiver must trace back to a `const`-bound `defineIndicator(...)` result.\",\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n ts.forEachChild(node, visit);\n return;\n }\n const effective = effectiveInputsByBinding.get(root.text);\n let resolvedRootName: string;\n let resolvedRoot: ResolvedBinding | null;\n let effectiveInputs: Readonly<Record<string, JsonValue>>;\n if (effective !== undefined) {\n resolvedRootName = effective.rootName;\n resolvedRoot = effective.rootBinding;\n effectiveInputs = effective.inputs;\n } else {\n resolvedRootName = root.text;\n resolvedRoot = resolveBinding(root, checker, bindingsByName, resolveProducer);\n effectiveInputs = Object.freeze({});\n }\n if (resolvedRoot === null) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message: `\\`.output(\"${title}\")\\` receiver \\`${root.text}\\` does not resolve to a known same-file or imported indicator binding.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n ts.forEachChild(node, visit);\n return;\n }\n\n const producerOutputs: ReadonlyArray<OutputDeclaration> =\n resolvedRoot.kind === \"same-file\"\n ? (outputsByBinding.get(resolvedRoot.binding.bindingName) as BindingOutputs)\n .outputs\n : resolvedRoot.snapshot.outputs;\n const producerHasUntitled =\n resolvedRoot.kind === \"same-file\" &&\n (outputsByBinding.get(resolvedRoot.binding.bindingName) as BindingOutputs)\n .hasUntitledPlot;\n const titles = new Set(producerOutputs.map((o) => o.title));\n if (!titles.has(title)) {\n if (producerHasUntitled) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-output-not-titled\",\n message: `Producer \\`${resolvedRootName}\\` declares an untitled \\`plot(...)\\` but consumer references \\`.output(\"${title}\")\\`. Title every \\`plot\\` the producer emits or remove the consumer reference.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n } else {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-unknown-output\",\n message: `Producer \\`${resolvedRootName}\\` does not declare an output titled \"${title}\".`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n }\n ts.forEachChild(node, visit);\n return;\n }\n\n const localId = effective !== undefined ? root.text : root.text;\n if (!seenLocalIds.has(localId)) {\n seenLocalIds.add(localId);\n const producerRef: ProducerRef =\n resolvedRoot.kind === \"same-file\"\n ? Object.freeze({\n kind: \"same-file\",\n bindingName: resolvedRoot.binding.bindingName,\n })\n : Object.freeze({\n kind: \"cross-file\",\n sourcePath: resolvedRoot.sourcePath,\n exportName: resolvedRoot.exportName,\n });\n consumerConsumes.push({\n localId,\n producerRef,\n outputs: producerOutputs,\n effectiveInputs,\n });\n }\n }\n ts.forEachChild(node, visit);\n };\n ts.forEachChild(body, visit);\n }\n\n const sameFileEdges = new Map<string, Set<string>>();\n for (const [bindingName, consumes] of consumesByBinding.entries()) {\n const targets = new Set<string>();\n for (const entry of consumes) {\n if (entry.producerRef.kind === \"same-file\") {\n targets.add(entry.producerRef.bindingName);\n }\n }\n sameFileEdges.set(bindingName, targets);\n }\n const cycles = detectCycles(sameFileEdges);\n for (const cycle of cycles) {\n const path = `${cycle.join(\" -> \")} -> ${cycle[0] ?? /* v8 ignore next */ \"\"}`;\n for (const member of cycle) {\n const binding = structuralBindings.find((b) => b.bindingName === member);\n /* v8 ignore next */\n if (binding === undefined) continue;\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-cycle\",\n message: `Dependency cycle detected: ${path}`,\n file: sourcePath,\n node: binding.defineCall,\n sourceFile,\n }),\n );\n }\n }\n\n const drawn: DrawnScript[] = [];\n const privateDeps: PrivateDep[] = [];\n // First emit any withInputs-derived alias bindings as synthetic\n // private deps so the bundler + runtime can mount one DepRunner\n // per unique alias. The alias has no `defineCall` of its own —\n // its compute body lives on the producer the alias chains off.\n for (const [aliasName, info] of effectiveInputsByBinding.entries()) {\n /* v8 ignore start */\n if (bindingsByName.has(aliasName)) continue;\n if (info.rootBinding === null) continue;\n /* v8 ignore stop */\n const producerRef: ProducerRef =\n info.rootBinding.kind === \"same-file\"\n ? Object.freeze({\n kind: \"same-file\",\n bindingName: info.rootBinding.binding.bindingName,\n })\n : Object.freeze({\n kind: \"cross-file\",\n sourcePath: info.rootBinding.sourcePath,\n exportName: info.rootBinding.exportName,\n });\n const aliasOutputs: ReadonlyArray<OutputDeclaration> =\n info.rootBinding.kind === \"same-file\"\n ? (outputsByBinding.get(info.rootBinding.binding.bindingName) as BindingOutputs)\n .outputs\n : info.rootBinding.snapshot.outputs;\n privateDeps.push(\n Object.freeze({\n localId: aliasName,\n producerRef,\n effectiveInputs: info.inputs,\n defineCall: null,\n outputs: aliasOutputs,\n consumes: Object.freeze([]),\n }),\n );\n }\n for (const binding of structuralBindings) {\n const outputs = (outputsByBinding.get(binding.bindingName) as BindingOutputs).outputs;\n const consumes = (consumesByBinding.get(binding.bindingName) as DepConsumesMutable[]).map(\n (entry) =>\n Object.freeze({\n localId: entry.localId,\n producerRef: entry.producerRef,\n outputs: entry.outputs,\n effectiveInputs: entry.effectiveInputs,\n }),\n );\n const frozenConsumes = Object.freeze(consumes);\n if (binding.exportKind === \"private\") {\n // Private structural bindings are always `const X =\n // defineIndicator(...)` direct calls — withInputs-derived\n // aliases live in `effectiveInputsByBinding` and were\n // already emitted as synthetic private deps above. Hence\n // the alias-via-private-binding branch is structurally\n // unreachable here.\n const producerRef: ProducerRef = Object.freeze({\n kind: \"same-file\",\n bindingName: binding.bindingName,\n });\n privateDeps.push(\n Object.freeze({\n localId: binding.bindingName,\n producerRef,\n effectiveInputs: Object.freeze({}),\n defineCall: binding.defineCall,\n outputs,\n consumes: frozenConsumes,\n }),\n );\n } else {\n drawn.push(\n Object.freeze({\n exportName: binding.exportKind === \"default\" ? \"default\" : binding.bindingName,\n bindingName: binding.bindingName,\n defineCall: binding.defineCall,\n outputs,\n consumes: frozenConsumes,\n }),\n );\n }\n }\n\n return Object.freeze({\n drawn: Object.freeze(drawn.slice()),\n privateDeps: Object.freeze(privateDeps.slice()),\n diagnostics: Object.freeze(diagnostics.slice()),\n });\n}\n\n/**\n * Colour-marking iterative DFS — returns every cycle found in the\n * directed adjacency map. Each cycle is the ordered list of node ids\n * along the back-edge. Used by `extractDependencyGraph` to surface\n * `dep-cycle` diagnostics at every binding in the cycle.\n */\nfunction detectCycles(edges: ReadonlyMap<string, ReadonlySet<string>>): string[][] {\n const WHITE = 0;\n const GREY = 1;\n const BLACK = 2;\n const colour = new Map<string, number>();\n for (const key of edges.keys()) colour.set(key, WHITE);\n\n const cycles: string[][] = [];\n const seenCycles = new Set<string>();\n\n const dfs = (start: string): void => {\n type Frame = { node: string; iter: Iterator<string> };\n const stack: Frame[] = [];\n const pathIndex = new Map<string, number>();\n const pathOrder: string[] = [];\n\n const targets = edges.get(start) ?? /* v8 ignore next */ new Set<string>();\n colour.set(start, GREY);\n pathIndex.set(start, 0);\n pathOrder.push(start);\n stack.push({ node: start, iter: targets[Symbol.iterator]() });\n\n while (stack.length > 0) {\n const top = stack[stack.length - 1];\n /* v8 ignore next */\n if (top === undefined) break;\n const next = top.iter.next();\n if (next.done) {\n colour.set(top.node, BLACK);\n pathIndex.delete(top.node);\n pathOrder.pop();\n stack.pop();\n continue;\n }\n const child = next.value;\n const childColour = colour.get(child) ?? /* v8 ignore next */ WHITE;\n if (childColour === BLACK) continue;\n if (childColour === GREY) {\n const startIdx = pathIndex.get(child);\n /* v8 ignore next */\n if (startIdx === undefined) continue;\n const cycle = pathOrder.slice(startIdx);\n const sortedKey = [...cycle].sort().join(\"|\");\n if (!seenCycles.has(sortedKey)) {\n seenCycles.add(sortedKey);\n cycles.push(cycle);\n }\n continue;\n }\n colour.set(child, GREY);\n pathIndex.set(child, pathOrder.length);\n pathOrder.push(child);\n const childTargets = edges.get(child) ?? /* v8 ignore next */ new Set<string>();\n stack.push({ node: child, iter: childTargets[Symbol.iterator]() });\n }\n };\n\n for (const key of edges.keys()) {\n if (colour.get(key) === WHITE) dfs(key);\n }\n return cycles;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"extractDependencyGraph.js","sourceRoot":"","sources":["../../src/analysis/extractDependencyGraph.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAA0B,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAyJrE;;;;GAIG;AACH,SAAS,eAAe,CAAC,IAAmB;IACxC,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC;IAC/C,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,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,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { JsonValue, OutputDeclaration } from \"@invinite-org/chartlang-core\";\nimport ts from \"typescript\";\n\nimport { type CompileDiagnostic, createDiagnostic } from \"../diagnostics.js\";\nimport { resolveCalleeName } from \"../transformers/resolveCallee.js\";\nimport type { StructuralBindingInfo } from \"./structuralChecks.js\";\n\n/**\n * Producer reference recorded on a consumer-side `const` binding. The\n * same-file variant carries the local binding name; the cross-file\n * variant carries the resolved POSIX path + ES-module export name.\n *\n * @since 0.7\n * @stable\n * @example\n * const r: ProducerRef = { kind: \"same-file\", bindingName: \"baseTrend\" };\n * void r;\n */\nexport type ProducerRef =\n | Readonly<{ kind: \"same-file\"; bindingName: string }>\n | Readonly<{ kind: \"cross-file\"; sourcePath: string; exportName: string }>;\n\n/**\n * One dep-graph edge — consumer binding → producer with the merged\n * effective inputs the bundler needs to fold into the producer's\n * compiled module at emit time.\n *\n * @since 0.7\n * @stable\n * @example\n * declare const dummyOutputs: ReadonlyArray<OutputDeclaration>;\n * const e: DepConsumesEntry = {\n * localId: \"fastTrend\",\n * producerRef: { kind: \"same-file\", bindingName: \"baseTrend\" },\n * outputs: dummyOutputs,\n * effectiveInputs: { length: 20 },\n * };\n * void e;\n */\nexport type DepConsumesEntry = Readonly<{\n readonly localId: string;\n readonly producerRef: ProducerRef;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly effectiveInputs: Readonly<Record<string, JsonValue>>;\n}>;\n\n/**\n * One exported (drawn) indicator the file declares. `exportName` is\n * `\"default\"` for `export default`, the identifier text otherwise.\n *\n * @since 0.7\n * @stable\n * @example\n * // declare const callExpression: ts.CallExpression;\n * const d: DrawnScript = {\n * exportName: \"default\",\n * bindingName: \"default\",\n * defineCall: undefined as unknown as ts.CallExpression,\n * outputs: [],\n * consumes: [],\n * };\n * void d;\n */\nexport type DrawnScript = Readonly<{\n readonly exportName: string;\n readonly bindingName: string;\n readonly defineCall: ts.CallExpression;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly consumes: ReadonlyArray<DepConsumesEntry>;\n}>;\n\n/**\n * One private (data-only) dep binding the file declares. `defineCall`\n * is `null` when the dep is a cross-file binding (the AST node lives\n * in the producer's source file).\n *\n * @since 0.7\n * @stable\n * @example\n * const d: PrivateDep = {\n * localId: \"fastTrend\",\n * producerRef: { kind: \"same-file\", bindingName: \"baseTrend\" },\n * effectiveInputs: { length: 20 },\n * defineCall: null,\n * outputs: [],\n * consumes: [],\n * };\n * void d;\n */\nexport type PrivateDep = Readonly<{\n readonly localId: string;\n readonly producerRef: ProducerRef;\n readonly effectiveInputs: Readonly<Record<string, JsonValue>>;\n readonly defineCall: ts.CallExpression | null;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly consumes: ReadonlyArray<DepConsumesEntry>;\n}>;\n\n/**\n * Producer snapshot returned by `resolveProducer` for cross-file\n * `import X from \"./Y.chart\"` consumer references.\n *\n * @since 0.7\n * @stable\n * @example\n * const snap: ProducerSnapshot = { name: \"trend\", outputs: [], inputs: {} };\n * void snap;\n */\nexport type ProducerSnapshot = Readonly<{\n readonly name: string;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly inputs: Readonly<Record<string, unknown>>;\n}>;\n\n/**\n * Callback the bundler supplies so the analysis pass can recursively\n * compile sibling `.chart.ts` files. Returns `null` when the producer\n * cannot be resolved (cycle, unknown path, no `defineIndicator(...)`).\n *\n * @since 0.7\n * @stable\n * @example\n * const r: ResolveProducer = () => null;\n * void r;\n */\nexport type ResolveProducer = (sourcePath: string, exportName: string) => ProducerSnapshot | null;\n\n/**\n * The compiled dep-graph artefact returned by `extractDependencyGraph`.\n * `drawn` + `privateDeps` are the indexed binding sets; `diagnostics`\n * is the union of every per-binding diagnostic surfaced during\n * walking + validation.\n *\n * @since 0.7\n * @stable\n * @example\n * const g: DepGraph = { drawn: [], privateDeps: [], diagnostics: [] };\n * void g;\n */\nexport type DepGraph = Readonly<{\n readonly drawn: ReadonlyArray<DrawnScript>;\n readonly privateDeps: ReadonlyArray<PrivateDep>;\n readonly diagnostics: ReadonlyArray<CompileDiagnostic>;\n}>;\n\ntype BindingOutputs = Readonly<{\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly hasUntitledPlot: boolean;\n}>;\n\ntype DepConsumesMutable = {\n localId: string;\n producerRef: ProducerRef;\n outputs: ReadonlyArray<OutputDeclaration>;\n effectiveInputs: Readonly<Record<string, JsonValue>>;\n};\n\n/**\n * Read a JSON-clean literal from a TS expression — number, string,\n * boolean, or null. Returns `undefined` for non-literal expressions\n * (identifiers, computed access, calls, …).\n */\nfunction readJsonLiteral(node: ts.Expression): JsonValue | undefined {\n if (ts.isNumericLiteral(node)) return Number(node.text);\n if (ts.isStringLiteral(node)) return node.text;\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false;\n if (node.kind === ts.SyntaxKind.NullKeyword) return null;\n return undefined;\n}\n\n/**\n * Read the function body the `compute` property assignment of a\n * `define*({ compute })` call literal points at. Returns `null` when\n * the property is missing or non-function (treat as zero plot calls).\n *\n * Handles both arrow functions (`compute: () => {}`) and method\n * shorthand (`compute() {}`).\n */\nfunction readComputeBody(defineCall: ts.CallExpression): ts.Node | null {\n const arg = defineCall.arguments[0];\n /* v8 ignore next */\n if (arg === undefined || !ts.isObjectLiteralExpression(arg)) return null;\n const computeProperty = arg.properties.find((property) => {\n const name = (property as { name?: ts.PropertyName }).name;\n return name !== undefined && ts.isIdentifier(name) && name.text === \"compute\";\n });\n if (computeProperty === undefined) return null;\n if (ts.isPropertyAssignment(computeProperty)) {\n const initializer = computeProperty.initializer;\n return ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)\n ? initializer.body\n : null;\n }\n /* v8 ignore start */\n if (ts.isMethodDeclaration(computeProperty)) {\n return computeProperty.body ?? null;\n }\n return null;\n}\n/* v8 ignore stop */\n\n/**\n * Sweep D — extract producer outputs from `plot(value, { title })`\n * calls inside the binding's compute body. Emits\n * `duplicate-output-title` for clashes.\n */\nfunction extractBindingOutputs(\n binding: StructuralBindingInfo,\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n sourcePath: string,\n diagnostics: CompileDiagnostic[],\n): BindingOutputs {\n const body = readComputeBody(binding.defineCall);\n const outputs: OutputDeclaration[] = [];\n const seenTitles = new Set<string>();\n let hasUntitledPlot = false;\n\n /* v8 ignore next 3 */\n if (body === null) {\n return Object.freeze({ outputs: Object.freeze(outputs.slice()), hasUntitledPlot });\n }\n\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node)) {\n const callee = resolveCalleeName(node, checker);\n // `bgcolor`/`barcolor` are plot-producing callees, so a binding\n // that only paints a background still counts as \"produces plots\"\n // (drives the `dep-output-not-titled` guard). Their `title` opt is\n // a plot label, NOT a `.output()`-referenceable series-number, so\n // they never add a titled output nor trip `duplicate-output-title`.\n if (callee === \"bgcolor\" || callee === \"barcolor\") {\n hasUntitledPlot = true;\n } else if (callee === \"plot\") {\n const optsArg = node.arguments[1];\n let title: string | undefined;\n if (optsArg !== undefined && ts.isObjectLiteralExpression(optsArg)) {\n for (const property of optsArg.properties) {\n /* v8 ignore next */\n if (!ts.isPropertyAssignment(property)) continue;\n const propertyName = property.name;\n if (!ts.isIdentifier(propertyName) || propertyName.text !== \"title\") {\n continue;\n }\n const initializer = property.initializer;\n /* v8 ignore next */\n if (!ts.isStringLiteral(initializer)) continue;\n title = initializer.text;\n }\n }\n if (title === undefined) {\n hasUntitledPlot = true;\n } else if (seenTitles.has(title)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"duplicate-output-title\",\n message: `\\`${binding.bindingName}\\` declares two outputs titled \"${title}\". Titles must be unique within a script.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n } else {\n seenTitles.add(title);\n outputs.push(Object.freeze({ title, kind: \"series-number\" as const }));\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n ts.forEachChild(body, visit);\n return Object.freeze({ outputs: Object.freeze(outputs.slice()), hasUntitledPlot });\n}\n\ntype ChainResolution = Readonly<{\n readonly root: ts.Identifier;\n readonly inputs: Readonly<Record<string, JsonValue>>;\n readonly ok: boolean;\n}>;\n\n/**\n * Sweep B — resolve a `<binding>.withInputs({...}).withInputs({...})`\n * chain back to its rooted identifier and the merged effective-inputs\n * map. Emits `dep-dynamic` / `dep-invalid-input-override` for invalid\n * argument shapes.\n */\nfunction resolveWithInputsChain(\n expression: ts.Expression,\n sourceFile: ts.SourceFile,\n sourcePath: string,\n diagnostics: CompileDiagnostic[],\n): ChainResolution | null {\n type Layer = { args: ts.ObjectLiteralExpression; ok: boolean };\n const layers: Layer[] = [];\n let current: ts.Expression = expression;\n while (ts.isCallExpression(current)) {\n const callee = current.expression;\n /* v8 ignore next 2 */\n if (!ts.isPropertyAccessExpression(callee)) return null;\n if (callee.name.text !== \"withInputs\") return null;\n const arg = current.arguments[0];\n if (arg === undefined || !ts.isObjectLiteralExpression(arg)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message:\n \"`.withInputs(...)` requires an object literal with literal-only property values.\",\n file: sourcePath,\n node: arg ?? /* v8 ignore next */ current,\n sourceFile,\n }),\n );\n layers.unshift({ args: ts.factory.createObjectLiteralExpression([]), ok: false });\n } else {\n layers.unshift({ args: arg, ok: true });\n }\n current = callee.expression;\n }\n /* v8 ignore next */\n if (!ts.isIdentifier(current)) return null;\n\n const merged: Record<string, JsonValue> = {};\n let ok = true;\n for (const layer of layers) {\n if (!layer.ok) {\n ok = false;\n continue;\n }\n for (const property of layer.args.properties) {\n if (!ts.isPropertyAssignment(property)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message:\n \"`.withInputs(...)` requires a plain object literal — no spread, shorthand, or computed keys.\",\n file: sourcePath,\n node: property,\n sourceFile,\n }),\n );\n ok = false;\n continue;\n }\n const key = property.name;\n if (!ts.isIdentifier(key) && !ts.isStringLiteral(key)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message: \"`.withInputs(...)` keys must be identifiers or string literals.\",\n file: sourcePath,\n node: key,\n sourceFile,\n }),\n );\n ok = false;\n continue;\n }\n const literal = readJsonLiteral(property.initializer);\n if (literal === undefined) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message: `\\`.withInputs({ ${key.text}: ... })\\` value must be a JSON literal (number, string, boolean, or null).`,\n file: sourcePath,\n node: property.initializer,\n sourceFile,\n }),\n );\n ok = false;\n continue;\n }\n merged[key.text] = literal;\n }\n }\n return Object.freeze({\n root: current,\n inputs: Object.freeze({ ...merged }),\n ok,\n });\n}\n\n/**\n * Validate an `effectiveInputs` map against the producer's `inputs`\n * schema. Each producer-input descriptor is shaped like\n * `{ kind: \"int\", defaultValue: 14, ... }`. Type-mismatch and unknown\n * keys both emit `dep-invalid-input-override`.\n */\nfunction validateInputOverrides(\n bindingName: string,\n inputs: Readonly<Record<string, JsonValue>>,\n producerInputs: Readonly<Record<string, unknown>>,\n node: ts.Node,\n sourceFile: ts.SourceFile,\n sourcePath: string,\n diagnostics: CompileDiagnostic[],\n): void {\n for (const [key, value] of Object.entries(inputs)) {\n const descriptor = producerInputs[key];\n if (descriptor === undefined) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-invalid-input-override\",\n message: `\\`${bindingName}\\` overrides input \"${key}\" which the producer does not declare.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n continue;\n }\n const expectedKind =\n typeof descriptor === \"object\" && descriptor !== null && \"kind\" in descriptor\n ? (descriptor as { kind: unknown }).kind\n : undefined;\n if (typeof expectedKind === \"string\") {\n const valueType = describeJsonValueKind(value);\n const expectedType = expectedTypeForKind(expectedKind);\n if (expectedType !== null && expectedType !== valueType) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-invalid-input-override\",\n message: `\\`${bindingName}\\` override for \"${key}\" expects ${expectedType} (producer declared \\`${expectedKind}\\`), received ${valueType}.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n }\n }\n }\n}\n\nfunction describeJsonValueKind(value: JsonValue): string {\n if (value === null) return \"null\";\n /* v8 ignore next */\n if (Array.isArray(value)) return \"array\";\n return typeof value;\n}\n\nconst KIND_TO_VALUE_TYPE: ReadonlyMap<string, string> = new Map([\n [\"int\", \"number\"],\n [\"float\", \"number\"],\n [\"price\", \"number\"],\n [\"time\", \"number\"],\n [\"string\", \"string\"],\n [\"enum\", \"string\"],\n [\"color\", \"string\"],\n [\"symbol\", \"string\"],\n [\"interval\", \"string\"],\n [\"bool\", \"boolean\"],\n]);\n\nfunction expectedTypeForKind(kind: string): string | null {\n return KIND_TO_VALUE_TYPE.get(kind) ?? null;\n}\n\n/**\n * Walk back from a `<receiver>.output(\"title\")` callee to a same-file\n * binding identifier OR an imported identifier — whichever applies.\n * Returns the underlying identifier or `null` when the receiver is a\n * non-resolvable shape (computed access, call result, etc.).\n */\nfunction resolveOutputReceiverRoot(receiver: ts.Expression): ts.Identifier | null {\n if (ts.isIdentifier(receiver)) return receiver;\n return null;\n}\n\nfunction originIsImport(symbol: ts.Symbol): {\n moduleSpecifier: string;\n exportName: string;\n} | null {\n const declarations = symbol.declarations ?? /* v8 ignore next */ [];\n for (const declaration of declarations) {\n if (ts.isImportClause(declaration)) {\n const importDecl = declaration.parent;\n const specifier = importDecl.moduleSpecifier;\n /* v8 ignore next */\n if (!ts.isStringLiteral(specifier)) continue;\n return { moduleSpecifier: specifier.text, exportName: \"default\" };\n }\n if (ts.isImportSpecifier(declaration)) {\n const importDecl = declaration.parent.parent.parent;\n const specifier = importDecl.moduleSpecifier;\n /* v8 ignore next */\n if (!ts.isStringLiteral(specifier)) continue;\n const exportName = declaration.propertyName?.text ?? declaration.name.text;\n return { moduleSpecifier: specifier.text, exportName };\n }\n }\n return null;\n}\n\ntype ResolvedBinding =\n | Readonly<{ kind: \"same-file\"; binding: StructuralBindingInfo }>\n | Readonly<{\n kind: \"cross-file\";\n sourcePath: string;\n exportName: string;\n snapshot: ProducerSnapshot;\n }>;\n\nfunction resolveBinding(\n identifier: ts.Identifier,\n checker: ts.TypeChecker,\n bindingsByName: ReadonlyMap<string, StructuralBindingInfo>,\n resolveProducer: ResolveProducer,\n): ResolvedBinding | null {\n const sameFile = bindingsByName.get(identifier.text);\n if (sameFile !== undefined) {\n return Object.freeze({ kind: \"same-file\", binding: sameFile });\n }\n const symbol = checker.getSymbolAtLocation(identifier);\n /* v8 ignore next */\n if (symbol === undefined) return null;\n const importOrigin = originIsImport(symbol);\n if (importOrigin === null) return null;\n const snapshot = resolveProducer(importOrigin.moduleSpecifier, importOrigin.exportName);\n if (snapshot === null) return null;\n return Object.freeze({\n kind: \"cross-file\",\n sourcePath: importOrigin.moduleSpecifier,\n exportName: importOrigin.exportName,\n snapshot,\n });\n}\n\n/**\n * Run the dependency-graph analysis pass over a `.chart.ts` source\n * file. Sweeps the AST four times — outputs, withInputs chains,\n * consumer `.output(...)` calls, cycle detection — and returns a\n * frozen `DepGraph` plus the diagnostics surfaced along the way.\n *\n * `resolveProducer` is a caller-supplied callback that the bundler\n * (Task 3) wires to a recursive compile entry point. In Task 2 the\n * pass works against `() => null` for cross-file edges; tests pass\n * mocked snapshots instead.\n *\n * @since 0.7\n * @stable\n * @example\n * // const graph = extractDependencyGraph(sf, checker, \"demo.chart.ts\", bindings, () => null);\n * const fn: typeof extractDependencyGraph = extractDependencyGraph;\n * void fn;\n */\nexport function extractDependencyGraph(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n sourcePath: string,\n structuralBindings: ReadonlyArray<StructuralBindingInfo>,\n resolveProducer: ResolveProducer,\n): DepGraph {\n const diagnostics: CompileDiagnostic[] = [];\n const bindingsByName = new Map<string, StructuralBindingInfo>();\n for (const binding of structuralBindings) {\n if (binding.exportKind === \"default\") continue;\n bindingsByName.set(binding.bindingName, binding);\n }\n\n const outputsByBinding = new Map<string, BindingOutputs>();\n for (const binding of structuralBindings) {\n outputsByBinding.set(\n binding.bindingName,\n extractBindingOutputs(binding, sourceFile, checker, sourcePath, diagnostics),\n );\n }\n\n type BindingEffectiveInputs = Readonly<{\n rootName: string;\n rootBinding: ResolvedBinding | null;\n inputs: Readonly<Record<string, JsonValue>>;\n }>;\n const effectiveInputsByBinding = new Map<string, BindingEffectiveInputs>();\n\n for (const statement of sourceFile.statements) {\n if (!ts.isVariableStatement(statement)) continue;\n for (const declaration of statement.declarationList.declarations) {\n /* v8 ignore next */\n if (!ts.isIdentifier(declaration.name)) continue;\n const initializer = declaration.initializer;\n if (initializer === undefined) continue;\n if (!ts.isCallExpression(initializer)) continue;\n const callee = initializer.expression;\n if (ts.isPropertyAccessExpression(callee) && callee.name.text === \"withInputs\") {\n const chain = resolveWithInputsChain(\n initializer,\n sourceFile,\n sourcePath,\n diagnostics,\n );\n /* v8 ignore next */\n if (chain === null) continue;\n const root = resolveBinding(chain.root, checker, bindingsByName, resolveProducer);\n effectiveInputsByBinding.set(declaration.name.text, {\n rootName: chain.root.text,\n rootBinding: root,\n inputs: chain.inputs,\n });\n if (root !== null && chain.ok) {\n const producerInputs = root.kind === \"cross-file\" ? root.snapshot.inputs : {};\n validateInputOverrides(\n declaration.name.text,\n chain.inputs,\n producerInputs,\n initializer,\n sourceFile,\n sourcePath,\n diagnostics,\n );\n }\n }\n }\n }\n\n const consumesByBinding = new Map<string, DepConsumesMutable[]>();\n for (const binding of structuralBindings) {\n consumesByBinding.set(binding.bindingName, []);\n }\n\n for (const binding of structuralBindings) {\n const body = readComputeBody(binding.defineCall);\n if (body === null) continue;\n const consumerConsumes = consumesByBinding.get(binding.bindingName);\n /* v8 ignore next */\n if (consumerConsumes === undefined) continue;\n const seenLocalIds = new Set<string>();\n const visit = (node: ts.Node): void => {\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === \"output\"\n ) {\n const arg = node.arguments[0];\n if (arg === undefined || !ts.isStringLiteral(arg)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message:\n \"`<binding>.output(...)` requires a single string-literal argument.\",\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n ts.forEachChild(node, visit);\n return;\n }\n const title = arg.text;\n const root = resolveOutputReceiverRoot(node.expression.expression);\n if (root === null) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message:\n \"`.output(...)` receiver must trace back to a `const`-bound `defineIndicator(...)` result.\",\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n ts.forEachChild(node, visit);\n return;\n }\n const effective = effectiveInputsByBinding.get(root.text);\n let resolvedRootName: string;\n let resolvedRoot: ResolvedBinding | null;\n let effectiveInputs: Readonly<Record<string, JsonValue>>;\n if (effective !== undefined) {\n resolvedRootName = effective.rootName;\n resolvedRoot = effective.rootBinding;\n effectiveInputs = effective.inputs;\n } else {\n resolvedRootName = root.text;\n resolvedRoot = resolveBinding(root, checker, bindingsByName, resolveProducer);\n effectiveInputs = Object.freeze({});\n }\n if (resolvedRoot === null) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-dynamic\",\n message: `\\`.output(\"${title}\")\\` receiver \\`${root.text}\\` does not resolve to a known same-file or imported indicator binding.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n ts.forEachChild(node, visit);\n return;\n }\n\n const producerOutputs: ReadonlyArray<OutputDeclaration> =\n resolvedRoot.kind === \"same-file\"\n ? (outputsByBinding.get(resolvedRoot.binding.bindingName) as BindingOutputs)\n .outputs\n : resolvedRoot.snapshot.outputs;\n const producerHasUntitled =\n resolvedRoot.kind === \"same-file\" &&\n (outputsByBinding.get(resolvedRoot.binding.bindingName) as BindingOutputs)\n .hasUntitledPlot;\n const titles = new Set(producerOutputs.map((o) => o.title));\n if (!titles.has(title)) {\n if (producerHasUntitled) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-output-not-titled\",\n message: `Producer \\`${resolvedRootName}\\` declares an untitled \\`plot(...)\\` but consumer references \\`.output(\"${title}\")\\`. Title every \\`plot\\` the producer emits or remove the consumer reference.`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n } else {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-unknown-output\",\n message: `Producer \\`${resolvedRootName}\\` does not declare an output titled \"${title}\".`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n }\n ts.forEachChild(node, visit);\n return;\n }\n\n const localId = effective !== undefined ? root.text : root.text;\n if (!seenLocalIds.has(localId)) {\n seenLocalIds.add(localId);\n const producerRef: ProducerRef =\n resolvedRoot.kind === \"same-file\"\n ? Object.freeze({\n kind: \"same-file\",\n bindingName: resolvedRoot.binding.bindingName,\n })\n : Object.freeze({\n kind: \"cross-file\",\n sourcePath: resolvedRoot.sourcePath,\n exportName: resolvedRoot.exportName,\n });\n consumerConsumes.push({\n localId,\n producerRef,\n outputs: producerOutputs,\n effectiveInputs,\n });\n }\n }\n ts.forEachChild(node, visit);\n };\n ts.forEachChild(body, visit);\n }\n\n const sameFileEdges = new Map<string, Set<string>>();\n for (const [bindingName, consumes] of consumesByBinding.entries()) {\n const targets = new Set<string>();\n for (const entry of consumes) {\n if (entry.producerRef.kind === \"same-file\") {\n targets.add(entry.producerRef.bindingName);\n }\n }\n sameFileEdges.set(bindingName, targets);\n }\n const cycles = detectCycles(sameFileEdges);\n for (const cycle of cycles) {\n const path = `${cycle.join(\" -> \")} -> ${cycle[0] ?? /* v8 ignore next */ \"\"}`;\n for (const member of cycle) {\n const binding = structuralBindings.find((b) => b.bindingName === member);\n /* v8 ignore next */\n if (binding === undefined) continue;\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"dep-cycle\",\n message: `Dependency cycle detected: ${path}`,\n file: sourcePath,\n node: binding.defineCall,\n sourceFile,\n }),\n );\n }\n }\n\n const drawn: DrawnScript[] = [];\n const privateDeps: PrivateDep[] = [];\n // First emit any withInputs-derived alias bindings as synthetic\n // private deps so the bundler + runtime can mount one DepRunner\n // per unique alias. The alias has no `defineCall` of its own —\n // its compute body lives on the producer the alias chains off.\n for (const [aliasName, info] of effectiveInputsByBinding.entries()) {\n /* v8 ignore start */\n if (bindingsByName.has(aliasName)) continue;\n if (info.rootBinding === null) continue;\n /* v8 ignore stop */\n const producerRef: ProducerRef =\n info.rootBinding.kind === \"same-file\"\n ? Object.freeze({\n kind: \"same-file\",\n bindingName: info.rootBinding.binding.bindingName,\n })\n : Object.freeze({\n kind: \"cross-file\",\n sourcePath: info.rootBinding.sourcePath,\n exportName: info.rootBinding.exportName,\n });\n const aliasOutputs: ReadonlyArray<OutputDeclaration> =\n info.rootBinding.kind === \"same-file\"\n ? (outputsByBinding.get(info.rootBinding.binding.bindingName) as BindingOutputs)\n .outputs\n : info.rootBinding.snapshot.outputs;\n privateDeps.push(\n Object.freeze({\n localId: aliasName,\n producerRef,\n effectiveInputs: info.inputs,\n defineCall: null,\n outputs: aliasOutputs,\n consumes: Object.freeze([]),\n }),\n );\n }\n for (const binding of structuralBindings) {\n const outputs = (outputsByBinding.get(binding.bindingName) as BindingOutputs).outputs;\n const consumes = (consumesByBinding.get(binding.bindingName) as DepConsumesMutable[]).map(\n (entry) =>\n Object.freeze({\n localId: entry.localId,\n producerRef: entry.producerRef,\n outputs: entry.outputs,\n effectiveInputs: entry.effectiveInputs,\n }),\n );\n const frozenConsumes = Object.freeze(consumes);\n if (binding.exportKind === \"private\") {\n // Private structural bindings are always `const X =\n // defineIndicator(...)` direct calls — withInputs-derived\n // aliases live in `effectiveInputsByBinding` and were\n // already emitted as synthetic private deps above. Hence\n // the alias-via-private-binding branch is structurally\n // unreachable here.\n const producerRef: ProducerRef = Object.freeze({\n kind: \"same-file\",\n bindingName: binding.bindingName,\n });\n privateDeps.push(\n Object.freeze({\n localId: binding.bindingName,\n producerRef,\n effectiveInputs: Object.freeze({}),\n defineCall: binding.defineCall,\n outputs,\n consumes: frozenConsumes,\n }),\n );\n } else {\n drawn.push(\n Object.freeze({\n exportName: binding.exportKind === \"default\" ? \"default\" : binding.bindingName,\n bindingName: binding.bindingName,\n defineCall: binding.defineCall,\n outputs,\n consumes: frozenConsumes,\n }),\n );\n }\n }\n\n return Object.freeze({\n drawn: Object.freeze(drawn.slice()),\n privateDeps: Object.freeze(privateDeps.slice()),\n diagnostics: Object.freeze(diagnostics.slice()),\n });\n}\n\n/**\n * Colour-marking iterative DFS — returns every cycle found in the\n * directed adjacency map. Each cycle is the ordered list of node ids\n * along the back-edge. Used by `extractDependencyGraph` to surface\n * `dep-cycle` diagnostics at every binding in the cycle.\n */\nfunction detectCycles(edges: ReadonlyMap<string, ReadonlySet<string>>): string[][] {\n const WHITE = 0;\n const GREY = 1;\n const BLACK = 2;\n const colour = new Map<string, number>();\n for (const key of edges.keys()) colour.set(key, WHITE);\n\n const cycles: string[][] = [];\n const seenCycles = new Set<string>();\n\n const dfs = (start: string): void => {\n type Frame = { node: string; iter: Iterator<string> };\n const stack: Frame[] = [];\n const pathIndex = new Map<string, number>();\n const pathOrder: string[] = [];\n\n const targets = edges.get(start) ?? /* v8 ignore next */ new Set<string>();\n colour.set(start, GREY);\n pathIndex.set(start, 0);\n pathOrder.push(start);\n stack.push({ node: start, iter: targets[Symbol.iterator]() });\n\n while (stack.length > 0) {\n const top = stack[stack.length - 1];\n /* v8 ignore next */\n if (top === undefined) break;\n const next = top.iter.next();\n if (next.done) {\n colour.set(top.node, BLACK);\n pathIndex.delete(top.node);\n pathOrder.pop();\n stack.pop();\n continue;\n }\n const child = next.value;\n const childColour = colour.get(child) ?? /* v8 ignore next */ WHITE;\n if (childColour === BLACK) continue;\n if (childColour === GREY) {\n const startIdx = pathIndex.get(child);\n /* v8 ignore next */\n if (startIdx === undefined) continue;\n const cycle = pathOrder.slice(startIdx);\n const sortedKey = [...cycle].sort().join(\"|\");\n if (!seenCycles.has(sortedKey)) {\n seenCycles.add(sortedKey);\n cycles.push(cycle);\n }\n continue;\n }\n colour.set(child, GREY);\n pathIndex.set(child, pathOrder.length);\n pathOrder.push(child);\n const childTargets = edges.get(child) ?? /* v8 ignore next */ new Set<string>();\n stack.push({ node: child, iter: childTargets[Symbol.iterator]() });\n }\n };\n\n for (const key of edges.keys()) {\n if (colour.get(key) === WHITE) dfs(key);\n }\n return cycles;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractInputs.d.ts","sourceRoot":"","sources":["../../src/analysis/extractInputs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,KAAK,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"extractInputs.d.ts","sourceRoot":"","sources":["../../src/analysis/extractInputs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,KAAK,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AA4C7E;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEpE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACtD,oBAAoB,EAAE,OAAO,CAAC;IAC9B,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACjD,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CACzB,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,UAAU,GAAE,MAA4B,EACxC,KAAK,GAAE,EAAE,CAAC,IAAiB,GAC5B,mBAAmB,CAwErB"}
|
|
@@ -22,6 +22,7 @@ const INPUT_KINDS = new Set([
|
|
|
22
22
|
"price",
|
|
23
23
|
"symbol",
|
|
24
24
|
"interval",
|
|
25
|
+
"session",
|
|
25
26
|
"externalSeries",
|
|
26
27
|
]);
|
|
27
28
|
/** Wire-tag mapping — camelCase builder names become kebab-case manifest tags. */
|
|
@@ -37,6 +38,7 @@ const KIND_TO_WIRE = Object.freeze({
|
|
|
37
38
|
price: "price",
|
|
38
39
|
symbol: "symbol",
|
|
39
40
|
interval: "interval",
|
|
41
|
+
session: "session",
|
|
40
42
|
externalSeries: "external-series",
|
|
41
43
|
});
|
|
42
44
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractInputs.js","sourceRoot":"","sources":["../../src/analysis/extractInputs.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAA0B,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IACzB,iBAAiB;IACjB,aAAa;IACb,eAAe;IACf,sBAAsB;CACzB,CAAC,CAAC;AAEH,sDAAsD;AACtD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IACxB,KAAK;IACL,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,QAAQ;IACR,UAAU;IACV,gBAAgB;CACnB,CAAC,CAAC;AAEH,kFAAkF;AAClF,MAAM,YAAY,GAAqC,MAAM,CAAC,MAAM,CAAC;IACjE,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;I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E,CAAC,yBAAyB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QACzE,IAAI,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC,EAAE,CAAC;YACxC,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;QACjC,CAAC;aAAM,CAAC;YACJ,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;QACjC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAqB;IAC3C,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QACjF,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAS,2BAA2B,CAAC,IAAY,EAAE,IAAa,EAAE,OAAyB;IACvF,OAAO,CAAC,WAAW,CAAC,IAAI,CACpB,gBAAgB,CAAC;QACb,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,2BAA2B;QACjC,OAAO,EAAE,SAAS,IAAI,kFAAkF;QACxG,IAAI,EAAE,OAAO,CAAC,UAAU;QACxB,IAAI;QACJ,UAAU,EAAE,OAAO,CAAC,UAAU;KACjC,CAAC,CACL,CAAC;AACN,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport ts from \"typescript\";\n\nimport { type CompileDiagnostic, createDiagnostic } from \"../diagnostics.js\";\nimport { resolveCalleeName } from \"../transformers/resolveCallee.js\";\n\nconst DEFINE_CALLS = new Set([\n \"defineIndicator\",\n \"defineAlert\",\n \"defineDrawing\",\n \"defineAlertCondition\",\n]);\n\n/** Names the walker recognises as `input.*` calls. */\nconst INPUT_KINDS = new Set([\n \"int\",\n \"float\",\n \"bool\",\n \"string\",\n \"enum\",\n \"color\",\n \"source\",\n \"time\",\n \"price\",\n \"symbol\",\n \"interval\",\n \"externalSeries\",\n]);\n\n/** Wire-tag mapping — camelCase builder names become kebab-case manifest tags. */\nconst KIND_TO_WIRE: Readonly<Record<string, string>> = Object.freeze({\n int: \"int\",\n float: \"float\",\n bool: \"bool\",\n string: \"string\",\n enum: \"enum\",\n color: \"color\",\n source: \"source\",\n time: \"time\",\n price: \"price\",\n symbol: \"symbol\",\n interval: \"interval\",\n externalSeries: \"external-series\",\n});\n\n/**\n * Frozen, JSON-clean input descriptor extracted from a script's\n * `define*({ inputs })` object.\n *\n * @since 0.4\n * @example\n * const d: ExtractedDescriptor = { kind: \"int\", defaultValue: 14 };\n * void d;\n */\nexport type ExtractedDescriptor = Readonly<Record<string, unknown>>;\n\n/**\n * Result of input extraction. Diagnostics are hard errors when the\n * declaration uses an unknown builder or non-literal descriptor values.\n *\n * @since 0.4\n * @example\n * const r: ExtractInputsResult = {\n * inputs: { length: { kind: \"int\", defaultValue: 14 } },\n * userPickableInterval: false,\n * diagnostics: [],\n * };\n * void r;\n */\nexport type ExtractInputsResult = Readonly<{\n inputs: Readonly<Record<string, ExtractedDescriptor>>;\n userPickableInterval: boolean;\n diagnostics: ReadonlyArray<CompileDiagnostic>;\n}>;\n\n/**\n * Walk a script's AST and serialise every `input.*` call inside\n * `defineIndicator({ inputs: { ... } })`, `defineAlert`, or\n * `defineDrawing` into the manifest's `inputs` record.\n *\n * The optional `scope` parameter narrows the walk to a single AST subtree\n * (typically one binding's `defineCall`) so multi-export files derive\n * per-binding inputs. Defaults to the whole `sourceFile`.\n *\n * @since 0.4\n * @example\n * // const r = extractInputs(sourceFile, checker, \"demo.chart.ts\");\n * // r.inputs.length === { kind: \"int\", defaultValue: 14 };\n * const fn: typeof extractInputs = extractInputs;\n * void fn;\n */\nexport function extractInputs(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n sourcePath: string = sourceFile.fileName,\n scope: ts.Node = sourceFile,\n): ExtractInputsResult {\n const inputs: Record<string, ExtractedDescriptor> = {};\n const diagnostics: CompileDiagnostic[] = [];\n let userPickableInterval = false;\n let intervalCount = 0;\n\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node) && isDefineCall(node, checker)) {\n const inputsObject = readInputsArg(node);\n if (inputsObject !== null) {\n for (const property of inputsObject.properties) {\n if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name)) {\n continue;\n }\n const initializer = property.initializer;\n if (!ts.isCallExpression(initializer)) continue;\n const callee = resolveCalleeName(initializer, checker);\n if (callee === null || !callee.startsWith(\"input.\")) continue;\n\n const kind = callee.slice(\"input.\".length);\n if (!INPUT_KINDS.has(kind)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"unknown-input-kind\",\n message: `input.${kind} is not a recognised input builder`,\n file: sourcePath,\n node: initializer.expression,\n sourceFile,\n }),\n );\n continue;\n }\n\n const wireKind = KIND_TO_WIRE[kind] as string;\n if (wireKind === \"interval\") {\n intervalCount += 1;\n userPickableInterval = true;\n if (intervalCount > 1) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"multiple-input-interval\",\n message: \"Only one input.interval() per script (PLAN §4.5)\",\n file: sourcePath,\n node: initializer.expression,\n sourceFile,\n }),\n );\n }\n }\n\n const descriptor = serialiseDescriptor(wireKind, kind, initializer, {\n sourceFile,\n sourcePath,\n diagnostics,\n });\n if (descriptor !== null) {\n inputs[property.name.text] = descriptor;\n }\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(scope);\n\n return Object.freeze({\n inputs: Object.freeze({ ...inputs }),\n userPickableInterval,\n diagnostics: Object.freeze(diagnostics.slice()),\n });\n}\n\ntype SerialiseContext = Readonly<{\n sourceFile: ts.SourceFile;\n sourcePath: string;\n diagnostics: CompileDiagnostic[];\n}>;\n\nfunction isDefineCall(node: ts.CallExpression, checker: ts.TypeChecker): boolean {\n const calleeName = resolveCalleeName(node, checker);\n return calleeName !== null && DEFINE_CALLS.has(calleeName);\n}\n\nfunction readInputsArg(node: ts.CallExpression): ts.ObjectLiteralExpression | null {\n const argument = node.arguments[0];\n if (argument === undefined || !ts.isObjectLiteralExpression(argument)) return null;\n for (const property of argument.properties) {\n if (!ts.isPropertyAssignment(property)) continue;\n if (!ts.isIdentifier(property.name) || property.name.text !== \"inputs\") continue;\n const initializer = property.initializer;\n if (ts.isObjectLiteralExpression(initializer)) return initializer;\n }\n return null;\n}\n\nfunction serialiseDescriptor(\n wireKind: string,\n builderKind: string,\n call: ts.CallExpression,\n context: SerialiseContext,\n): ExtractedDescriptor | null {\n if (wireKind === \"external-series\") {\n return serialiseExternalSeries(call, context);\n }\n\n const defaultArg = call.arguments[0];\n if (defaultArg === undefined) {\n addDefaultLiteralDiagnostic(builderKind, call.expression, context);\n return null;\n }\n const defaultValue = readLiteral(defaultArg);\n if (defaultValue === undefined || Array.isArray(defaultValue)) {\n addDefaultLiteralDiagnostic(builderKind, defaultArg, context);\n return null;\n }\n\n const descriptor: Record<string, unknown> = {\n kind: wireKind,\n defaultValue,\n };\n\n if (wireKind === \"enum\") {\n const optionsArg = call.arguments[1];\n const options = optionsArg === undefined ? null : readStringArray(optionsArg);\n if (options === null) {\n addDefaultLiteralDiagnostic(builderKind, optionsArg ?? call.expression, context);\n return null;\n }\n descriptor.options = Object.freeze(options.slice());\n copyObjectLiteralFields(call.arguments[2], descriptor, builderKind, context);\n } else {\n copyObjectLiteralFields(call.arguments[1], descriptor, builderKind, context);\n }\n\n return Object.freeze(descriptor);\n}\n\nfunction serialiseExternalSeries(\n call: ts.CallExpression,\n context: SerialiseContext,\n): ExtractedDescriptor | null {\n const arg = call.arguments[0];\n if (arg === undefined || !ts.isObjectLiteralExpression(arg)) {\n addDefaultLiteralDiagnostic(\"externalSeries\", arg ?? call.expression, context);\n return null;\n }\n\n const descriptor: Record<string, unknown> = { kind: \"external-series\" };\n let sawName = false;\n let sawSchema = false;\n\n for (const property of arg.properties) {\n if (ts.isShorthandPropertyAssignment(property) && property.name.text === \"schema\") {\n descriptor.schema = Object.freeze({ kind: \"external-series-schema\" });\n sawSchema = true;\n continue;\n }\n if (!ts.isPropertyAssignment(property)) continue;\n const key = propertyNameText(property.name);\n if (key === null) continue;\n if (key === \"name\") {\n const value = readLiteral(property.initializer);\n if (typeof value !== \"string\") {\n addDefaultLiteralDiagnostic(\"externalSeries\", property.initializer, context);\n return null;\n }\n descriptor.name = value;\n sawName = true;\n } else if (key === \"schema\") {\n descriptor.schema = Object.freeze({ kind: \"external-series-schema\" });\n sawSchema = true;\n } else if (key === \"title\") {\n const value = readLiteral(property.initializer);\n if (typeof value !== \"string\") {\n addDefaultLiteralDiagnostic(\"externalSeries\", property.initializer, context);\n return null;\n }\n descriptor.title = value;\n }\n }\n\n if (!sawName || !sawSchema) {\n addDefaultLiteralDiagnostic(\"externalSeries\", arg, context);\n return null;\n }\n return Object.freeze(descriptor);\n}\n\nfunction copyObjectLiteralFields(\n arg: ts.Expression | undefined,\n descriptor: Record<string, unknown>,\n builderKind: string,\n context: SerialiseContext,\n): void {\n if (arg === undefined) return;\n const unwrapped = unwrapConstAssertion(arg);\n if (!ts.isObjectLiteralExpression(unwrapped)) {\n addDefaultLiteralDiagnostic(builderKind, arg, context);\n return;\n }\n\n for (const property of unwrapped.properties) {\n if (!ts.isPropertyAssignment(property)) continue;\n const key = propertyNameText(property.name);\n if (key === null) continue;\n const value = readLiteral(property.initializer);\n if (value === undefined) {\n addDefaultLiteralDiagnostic(builderKind, property.initializer, context);\n continue;\n }\n descriptor[key] = value;\n }\n}\n\nfunction readLiteral(node: ts.Expression): unknown | undefined {\n const unwrapped = unwrapConstAssertion(node);\n if (ts.isNumericLiteral(unwrapped)) return Number(unwrapped.text);\n if (\n ts.isPrefixUnaryExpression(unwrapped) &&\n (unwrapped.operator === ts.SyntaxKind.MinusToken ||\n unwrapped.operator === ts.SyntaxKind.PlusToken) &&\n ts.isNumericLiteral(unwrapped.operand)\n ) {\n const value = Number(unwrapped.operand.text);\n return unwrapped.operator === ts.SyntaxKind.MinusToken ? -value : value;\n }\n if (ts.isStringLiteral(unwrapped) || ts.isNoSubstitutionTemplateLiteral(unwrapped)) {\n return unwrapped.text;\n }\n if (unwrapped.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (unwrapped.kind === ts.SyntaxKind.FalseKeyword) return false;\n if (ts.isArrayLiteralExpression(unwrapped)) {\n const values: string[] = [];\n for (const element of unwrapped.elements) {\n const literal = readLiteral(element);\n if (typeof literal !== \"string\") return undefined;\n values.push(literal);\n }\n return Object.freeze(values);\n }\n return undefined;\n}\n\nfunction readStringArray(node: ts.Expression): ReadonlyArray<string> | null {\n const value = readLiteral(node);\n if (!Array.isArray(value)) return null;\n return Object.freeze(value.slice());\n}\n\nfunction unwrapConstAssertion(node: ts.Expression): ts.Expression {\n let current = node;\n while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current)) {\n if (ts.isParenthesizedExpression(current)) {\n current = current.expression;\n } else {\n current = current.expression;\n }\n }\n return current;\n}\n\nfunction propertyNameText(name: ts.PropertyName): string | null {\n if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNumericLiteral(name)) {\n return name.text;\n }\n return null;\n}\n\nfunction addDefaultLiteralDiagnostic(kind: string, node: ts.Node, context: SerialiseContext): void {\n context.diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"input-default-not-literal\",\n message: `input.${kind} default must be a literal (number / string / boolean), not a variable reference`,\n file: context.sourcePath,\n node,\n sourceFile: context.sourceFile,\n }),\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"extractInputs.js","sourceRoot":"","sources":["../../src/analysis/extractInputs.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAA0B,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,C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,2BAA2B;QACjC,OAAO,EAAE,SAAS,IAAI,kFAAkF;QACxG,IAAI,EAAE,OAAO,CAAC,UAAU;QACxB,IAAI;QACJ,UAAU,EAAE,OAAO,CAAC,UAAU;KACjC,CAAC,CACL,CAAC;AACN,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport ts from \"typescript\";\n\nimport { type CompileDiagnostic, createDiagnostic } from \"../diagnostics.js\";\nimport { resolveCalleeName } from \"../transformers/resolveCallee.js\";\n\nconst DEFINE_CALLS = new Set([\n \"defineIndicator\",\n \"defineAlert\",\n \"defineDrawing\",\n \"defineAlertCondition\",\n]);\n\n/** Names the walker recognises as `input.*` calls. */\nconst INPUT_KINDS = new Set([\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 \"externalSeries\",\n]);\n\n/** Wire-tag mapping — camelCase builder names become kebab-case manifest tags. */\nconst KIND_TO_WIRE: Readonly<Record<string, string>> = Object.freeze({\n int: \"int\",\n float: \"float\",\n bool: \"bool\",\n string: \"string\",\n enum: \"enum\",\n color: \"color\",\n source: \"source\",\n time: \"time\",\n price: \"price\",\n symbol: \"symbol\",\n interval: \"interval\",\n session: \"session\",\n externalSeries: \"external-series\",\n});\n\n/**\n * Frozen, JSON-clean input descriptor extracted from a script's\n * `define*({ inputs })` object.\n *\n * @since 0.4\n * @example\n * const d: ExtractedDescriptor = { kind: \"int\", defaultValue: 14 };\n * void d;\n */\nexport type ExtractedDescriptor = Readonly<Record<string, unknown>>;\n\n/**\n * Result of input extraction. Diagnostics are hard errors when the\n * declaration uses an unknown builder or non-literal descriptor values.\n *\n * @since 0.4\n * @example\n * const r: ExtractInputsResult = {\n * inputs: { length: { kind: \"int\", defaultValue: 14 } },\n * userPickableInterval: false,\n * diagnostics: [],\n * };\n * void r;\n */\nexport type ExtractInputsResult = Readonly<{\n inputs: Readonly<Record<string, ExtractedDescriptor>>;\n userPickableInterval: boolean;\n diagnostics: ReadonlyArray<CompileDiagnostic>;\n}>;\n\n/**\n * Walk a script's AST and serialise every `input.*` call inside\n * `defineIndicator({ inputs: { ... } })`, `defineAlert`, or\n * `defineDrawing` into the manifest's `inputs` record.\n *\n * The optional `scope` parameter narrows the walk to a single AST subtree\n * (typically one binding's `defineCall`) so multi-export files derive\n * per-binding inputs. Defaults to the whole `sourceFile`.\n *\n * @since 0.4\n * @example\n * // const r = extractInputs(sourceFile, checker, \"demo.chart.ts\");\n * // r.inputs.length === { kind: \"int\", defaultValue: 14 };\n * const fn: typeof extractInputs = extractInputs;\n * void fn;\n */\nexport function extractInputs(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n sourcePath: string = sourceFile.fileName,\n scope: ts.Node = sourceFile,\n): ExtractInputsResult {\n const inputs: Record<string, ExtractedDescriptor> = {};\n const diagnostics: CompileDiagnostic[] = [];\n let userPickableInterval = false;\n let intervalCount = 0;\n\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node) && isDefineCall(node, checker)) {\n const inputsObject = readInputsArg(node);\n if (inputsObject !== null) {\n for (const property of inputsObject.properties) {\n if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name)) {\n continue;\n }\n const initializer = property.initializer;\n if (!ts.isCallExpression(initializer)) continue;\n const callee = resolveCalleeName(initializer, checker);\n if (callee === null || !callee.startsWith(\"input.\")) continue;\n\n const kind = callee.slice(\"input.\".length);\n if (!INPUT_KINDS.has(kind)) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"unknown-input-kind\",\n message: `input.${kind} is not a recognised input builder`,\n file: sourcePath,\n node: initializer.expression,\n sourceFile,\n }),\n );\n continue;\n }\n\n const wireKind = KIND_TO_WIRE[kind] as string;\n if (wireKind === \"interval\") {\n intervalCount += 1;\n userPickableInterval = true;\n if (intervalCount > 1) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"multiple-input-interval\",\n message: \"Only one input.interval() per script (PLAN §4.5)\",\n file: sourcePath,\n node: initializer.expression,\n sourceFile,\n }),\n );\n }\n }\n\n const descriptor = serialiseDescriptor(wireKind, kind, initializer, {\n sourceFile,\n sourcePath,\n diagnostics,\n });\n if (descriptor !== null) {\n inputs[property.name.text] = descriptor;\n }\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(scope);\n\n return Object.freeze({\n inputs: Object.freeze({ ...inputs }),\n userPickableInterval,\n diagnostics: Object.freeze(diagnostics.slice()),\n });\n}\n\ntype SerialiseContext = Readonly<{\n sourceFile: ts.SourceFile;\n sourcePath: string;\n diagnostics: CompileDiagnostic[];\n}>;\n\nfunction isDefineCall(node: ts.CallExpression, checker: ts.TypeChecker): boolean {\n const calleeName = resolveCalleeName(node, checker);\n return calleeName !== null && DEFINE_CALLS.has(calleeName);\n}\n\nfunction readInputsArg(node: ts.CallExpression): ts.ObjectLiteralExpression | null {\n const argument = node.arguments[0];\n if (argument === undefined || !ts.isObjectLiteralExpression(argument)) return null;\n for (const property of argument.properties) {\n if (!ts.isPropertyAssignment(property)) continue;\n if (!ts.isIdentifier(property.name) || property.name.text !== \"inputs\") continue;\n const initializer = property.initializer;\n if (ts.isObjectLiteralExpression(initializer)) return initializer;\n }\n return null;\n}\n\nfunction serialiseDescriptor(\n wireKind: string,\n builderKind: string,\n call: ts.CallExpression,\n context: SerialiseContext,\n): ExtractedDescriptor | null {\n if (wireKind === \"external-series\") {\n return serialiseExternalSeries(call, context);\n }\n\n const defaultArg = call.arguments[0];\n if (defaultArg === undefined) {\n addDefaultLiteralDiagnostic(builderKind, call.expression, context);\n return null;\n }\n const defaultValue = readLiteral(defaultArg);\n if (defaultValue === undefined || Array.isArray(defaultValue)) {\n addDefaultLiteralDiagnostic(builderKind, defaultArg, context);\n return null;\n }\n\n const descriptor: Record<string, unknown> = {\n kind: wireKind,\n defaultValue,\n };\n\n if (wireKind === \"enum\") {\n const optionsArg = call.arguments[1];\n const options = optionsArg === undefined ? null : readStringArray(optionsArg);\n if (options === null) {\n addDefaultLiteralDiagnostic(builderKind, optionsArg ?? call.expression, context);\n return null;\n }\n descriptor.options = Object.freeze(options.slice());\n copyObjectLiteralFields(call.arguments[2], descriptor, builderKind, context);\n } else {\n copyObjectLiteralFields(call.arguments[1], descriptor, builderKind, context);\n }\n\n return Object.freeze(descriptor);\n}\n\nfunction serialiseExternalSeries(\n call: ts.CallExpression,\n context: SerialiseContext,\n): ExtractedDescriptor | null {\n const arg = call.arguments[0];\n if (arg === undefined || !ts.isObjectLiteralExpression(arg)) {\n addDefaultLiteralDiagnostic(\"externalSeries\", arg ?? call.expression, context);\n return null;\n }\n\n const descriptor: Record<string, unknown> = { kind: \"external-series\" };\n let sawName = false;\n let sawSchema = false;\n\n for (const property of arg.properties) {\n if (ts.isShorthandPropertyAssignment(property) && property.name.text === \"schema\") {\n descriptor.schema = Object.freeze({ kind: \"external-series-schema\" });\n sawSchema = true;\n continue;\n }\n if (!ts.isPropertyAssignment(property)) continue;\n const key = propertyNameText(property.name);\n if (key === null) continue;\n if (key === \"name\") {\n const value = readLiteral(property.initializer);\n if (typeof value !== \"string\") {\n addDefaultLiteralDiagnostic(\"externalSeries\", property.initializer, context);\n return null;\n }\n descriptor.name = value;\n sawName = true;\n } else if (key === \"schema\") {\n descriptor.schema = Object.freeze({ kind: \"external-series-schema\" });\n sawSchema = true;\n } else if (key === \"title\") {\n const value = readLiteral(property.initializer);\n if (typeof value !== \"string\") {\n addDefaultLiteralDiagnostic(\"externalSeries\", property.initializer, context);\n return null;\n }\n descriptor.title = value;\n }\n }\n\n if (!sawName || !sawSchema) {\n addDefaultLiteralDiagnostic(\"externalSeries\", arg, context);\n return null;\n }\n return Object.freeze(descriptor);\n}\n\nfunction copyObjectLiteralFields(\n arg: ts.Expression | undefined,\n descriptor: Record<string, unknown>,\n builderKind: string,\n context: SerialiseContext,\n): void {\n if (arg === undefined) return;\n const unwrapped = unwrapConstAssertion(arg);\n if (!ts.isObjectLiteralExpression(unwrapped)) {\n addDefaultLiteralDiagnostic(builderKind, arg, context);\n return;\n }\n\n for (const property of unwrapped.properties) {\n if (!ts.isPropertyAssignment(property)) continue;\n const key = propertyNameText(property.name);\n if (key === null) continue;\n const value = readLiteral(property.initializer);\n if (value === undefined) {\n addDefaultLiteralDiagnostic(builderKind, property.initializer, context);\n continue;\n }\n descriptor[key] = value;\n }\n}\n\nfunction readLiteral(node: ts.Expression): unknown | undefined {\n const unwrapped = unwrapConstAssertion(node);\n if (ts.isNumericLiteral(unwrapped)) return Number(unwrapped.text);\n if (\n ts.isPrefixUnaryExpression(unwrapped) &&\n (unwrapped.operator === ts.SyntaxKind.MinusToken ||\n unwrapped.operator === ts.SyntaxKind.PlusToken) &&\n ts.isNumericLiteral(unwrapped.operand)\n ) {\n const value = Number(unwrapped.operand.text);\n return unwrapped.operator === ts.SyntaxKind.MinusToken ? -value : value;\n }\n if (ts.isStringLiteral(unwrapped) || ts.isNoSubstitutionTemplateLiteral(unwrapped)) {\n return unwrapped.text;\n }\n if (unwrapped.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (unwrapped.kind === ts.SyntaxKind.FalseKeyword) return false;\n if (ts.isArrayLiteralExpression(unwrapped)) {\n const values: string[] = [];\n for (const element of unwrapped.elements) {\n const literal = readLiteral(element);\n if (typeof literal !== \"string\") return undefined;\n values.push(literal);\n }\n return Object.freeze(values);\n }\n return undefined;\n}\n\nfunction readStringArray(node: ts.Expression): ReadonlyArray<string> | null {\n const value = readLiteral(node);\n if (!Array.isArray(value)) return null;\n return Object.freeze(value.slice());\n}\n\nfunction unwrapConstAssertion(node: ts.Expression): ts.Expression {\n let current = node;\n while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current)) {\n if (ts.isParenthesizedExpression(current)) {\n current = current.expression;\n } else {\n current = current.expression;\n }\n }\n return current;\n}\n\nfunction propertyNameText(name: ts.PropertyName): string | null {\n if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNumericLiteral(name)) {\n return name.text;\n }\n return null;\n}\n\nfunction addDefaultLiteralDiagnostic(kind: string, node: ts.Node, context: SerialiseContext): void {\n context.diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"input-default-not-literal\",\n message: `input.${kind} default must be a literal (number / string / boolean), not a variable reference`,\n file: context.sourcePath,\n node,\n sourceFile: context.sourceFile,\n }),\n );\n}\n"]}
|
|
@@ -1,30 +1,50 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RequestedFeed, type SecurityExpressionDescriptor } from "@invinite-org/chartlang-core";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import { type CompileDiagnostic } from "../diagnostics.js";
|
|
4
4
|
import type { ExtractedDescriptor } from "./extractInputs.js";
|
|
5
5
|
/**
|
|
6
6
|
* Combined result of the `request.*` analysis pass: the sorted, deduped list
|
|
7
|
-
* of requested intervals
|
|
7
|
+
* of requested intervals (the **main-symbol** projection), the sorted, deduped
|
|
8
|
+
* list of requested `(symbol?, interval)` {@link RequestedFeed | feeds} (the
|
|
9
|
+
* superset), plus one {@link SecurityExpressionDescriptor} per
|
|
8
10
|
* `request.security({ interval }, (bar) => …)` expression callsite (sorted by
|
|
9
11
|
* `slotId`).
|
|
10
12
|
*
|
|
13
|
+
* `intervals` keeps its exact existing meaning — the symbol-omitted
|
|
14
|
+
* (chart-symbol) higher-timeframe intervals — so existing manifests stay
|
|
15
|
+
* byte-identical. `feeds` adds the symbol dimension: one entry per distinct
|
|
16
|
+
* `(symbol, interval)` pair, deduped + ordered by the shared
|
|
17
|
+
* `feedKey(symbol, interval)` so the printed manifest is byte-stable.
|
|
18
|
+
*
|
|
11
19
|
* @since 0.7
|
|
12
20
|
* @stable
|
|
13
21
|
* @example
|
|
14
|
-
* const r: RequestAnalysis = { intervals: ["1W"], securityExpressions: [] };
|
|
22
|
+
* const r: RequestAnalysis = { intervals: ["1W"], feeds: [], securityExpressions: [] };
|
|
15
23
|
* void r;
|
|
16
24
|
*/
|
|
17
25
|
export type RequestAnalysis = Readonly<{
|
|
18
26
|
intervals: ReadonlyArray<string>;
|
|
27
|
+
feeds: ReadonlyArray<RequestedFeed>;
|
|
19
28
|
securityExpressions: ReadonlyArray<SecurityExpressionDescriptor>;
|
|
20
29
|
}>;
|
|
21
30
|
/**
|
|
22
31
|
* Walk a script's AST and collect every static `interval` argument to
|
|
23
|
-
* `request.security({ interval: ... })` and `request.lowerTf(...)`,
|
|
24
|
-
* `request.security`
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* `request.
|
|
32
|
+
* `request.security({ interval: ... })` and `request.lowerTf(...)`, every
|
|
33
|
+
* distinct requested `(symbol?, interval)` feed (`request.security` only —
|
|
34
|
+
* `request.lowerTf` has no symbol), plus every `request.security` *expression*
|
|
35
|
+
* callsite (a second arrow/function argument). Dynamic intervals emit
|
|
36
|
+
* `request-security-interval-not-literal` (for `request.security`) or
|
|
37
|
+
* `request-lower-tf-interval-not-literal` (for `request.lowerTf`); a dynamic
|
|
38
|
+
* `request.security` symbol emits `request-security-symbol-not-literal`. Either
|
|
39
|
+
* dynamic axis is excluded.
|
|
40
|
+
*
|
|
41
|
+
* The `symbol` opt is read the same three ways `interval` is — a string literal,
|
|
42
|
+
* an `inputs.<enum>` access (expanded to all options), or an `inputs.<name>`
|
|
43
|
+
* `input.symbol` default literal — and the cartesian product of resolved
|
|
44
|
+
* symbols × intervals is deduped into `feeds` via the shared
|
|
45
|
+
* `feedKey(symbol, interval)`. A symbol-omitted (or empty-literal) feed keeps its
|
|
46
|
+
* interval in `intervals` (the main-symbol projection); a present-symbol feed
|
|
47
|
+
* does not.
|
|
28
48
|
*
|
|
29
49
|
* Each expression callsite is recorded as a {@link SecurityExpressionDescriptor}
|
|
30
50
|
* keyed by the same `slotId` the callsite-id transformer injects (via the
|
|
@@ -36,7 +56,7 @@ export type RequestAnalysis = Readonly<{
|
|
|
36
56
|
* @since 0.7
|
|
37
57
|
* @stable
|
|
38
58
|
* @example
|
|
39
|
-
* // const { intervals, securityExpressions } =
|
|
59
|
+
* // const { intervals, feeds, securityExpressions } =
|
|
40
60
|
* // extractRequestAnalysis(sf, checker, inputs, diagnostics, path, true);
|
|
41
61
|
* const fn: typeof extractRequestAnalysis = extractRequestAnalysis;
|
|
42
62
|
* void fn;
|