@invinite-org/chartlang-compiler 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +3 -0
  3. package/dist/analysis/extractCapabilities.d.ts +5 -1
  4. package/dist/analysis/extractCapabilities.d.ts.map +1 -1
  5. package/dist/analysis/extractCapabilities.js +6 -2
  6. package/dist/analysis/extractCapabilities.js.map +1 -1
  7. package/dist/analysis/extractDependencyGraph.d.ts +160 -0
  8. package/dist/analysis/extractDependencyGraph.d.ts.map +1 -0
  9. package/dist/analysis/extractDependencyGraph.js +690 -0
  10. package/dist/analysis/extractDependencyGraph.js.map +1 -0
  11. package/dist/analysis/extractInputs.d.ts +5 -1
  12. package/dist/analysis/extractInputs.d.ts.map +1 -1
  13. package/dist/analysis/extractInputs.js +6 -2
  14. package/dist/analysis/extractInputs.js.map +1 -1
  15. package/dist/analysis/extractMaxLookback.d.ts +6 -1
  16. package/dist/analysis/extractMaxLookback.d.ts.map +1 -1
  17. package/dist/analysis/extractMaxLookback.js +10 -5
  18. package/dist/analysis/extractMaxLookback.js.map +1 -1
  19. package/dist/analysis/forbiddenConstructs.d.ts.map +1 -1
  20. package/dist/analysis/forbiddenConstructs.js +3 -0
  21. package/dist/analysis/forbiddenConstructs.js.map +1 -1
  22. package/dist/analysis/index.d.ts +3 -1
  23. package/dist/analysis/index.d.ts.map +1 -1
  24. package/dist/analysis/index.js +1 -0
  25. package/dist/analysis/index.js.map +1 -1
  26. package/dist/analysis/structuralChecks.d.ts +64 -8
  27. package/dist/analysis/structuralChecks.d.ts.map +1 -1
  28. package/dist/analysis/structuralChecks.js +111 -22
  29. package/dist/analysis/structuralChecks.js.map +1 -1
  30. package/dist/api.d.ts +40 -0
  31. package/dist/api.d.ts.map +1 -1
  32. package/dist/api.js +484 -35
  33. package/dist/api.js.map +1 -1
  34. package/dist/bundle.d.ts +90 -3
  35. package/dist/bundle.d.ts.map +1 -1
  36. package/dist/bundle.js +59 -5
  37. package/dist/bundle.js.map +1 -1
  38. package/dist/dependency/index.d.ts +3 -0
  39. package/dist/dependency/index.d.ts.map +1 -0
  40. package/dist/dependency/index.js +4 -0
  41. package/dist/dependency/index.js.map +1 -0
  42. package/dist/dependency/resolveProducer.d.ts +183 -0
  43. package/dist/dependency/resolveProducer.d.ts.map +1 -0
  44. package/dist/dependency/resolveProducer.js +256 -0
  45. package/dist/dependency/resolveProducer.js.map +1 -0
  46. package/dist/diagnostics.d.ts +6 -2
  47. package/dist/diagnostics.d.ts.map +1 -1
  48. package/dist/diagnostics.js.map +1 -1
  49. package/dist/index.d.ts +3 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +1 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/manifest.d.ts +8 -1
  54. package/dist/manifest.d.ts.map +1 -1
  55. package/dist/manifest.js +27 -0
  56. package/dist/manifest.js.map +1 -1
  57. package/dist/program.d.ts +1 -0
  58. package/dist/program.d.ts.map +1 -1
  59. package/dist/program.js +80 -4
  60. package/dist/program.js.map +1 -1
  61. package/dist/transformers/callsiteIdInjection.d.ts +2 -1
  62. package/dist/transformers/callsiteIdInjection.d.ts.map +1 -1
  63. package/dist/transformers/callsiteIdInjection.js +15 -0
  64. package/dist/transformers/callsiteIdInjection.js.map +1 -1
  65. package/dist/transformers/index.d.ts +2 -0
  66. package/dist/transformers/index.d.ts.map +1 -1
  67. package/dist/transformers/index.js +1 -0
  68. package/dist/transformers/index.js.map +1 -1
  69. package/dist/transformers/plotKindFromCallsite.d.ts +43 -0
  70. package/dist/transformers/plotKindFromCallsite.d.ts.map +1 -0
  71. package/dist/transformers/plotKindFromCallsite.js +103 -0
  72. package/dist/transformers/plotKindFromCallsite.js.map +1 -0
  73. package/dist/transformers/rewriteDependencyAccessors.d.ts +65 -0
  74. package/dist/transformers/rewriteDependencyAccessors.d.ts.map +1 -0
  75. package/dist/transformers/rewriteDependencyAccessors.js +204 -0
  76. package/dist/transformers/rewriteDependencyAccessors.js.map +1 -0
  77. package/dist/typesEmit.d.ts +14 -11
  78. package/dist/typesEmit.d.ts.map +1 -1
  79. package/dist/typesEmit.js +91 -7
  80. package/dist/typesEmit.js.map +1 -1
  81. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,106 @@
1
1
  # @invinite-org/chartlang-compiler
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f0c8eb8: Add `CompiledScriptObject.output` / `.withInputs` sentinels, `DependencyDeclaration` + `OutputDeclaration` types, optional `dependencies` / `outputs` / `exportName` / `siblings` / `isDrawn` fields on `ScriptManifest`, `CompiledScriptBundle` + `isCompiledScriptBundle` narrowing helper, and six new `dep-*` `DiagnosticCode` entries (`dep-error`, `dep-cycle`, `dep-unknown-output`, `dep-invalid-input-override`, `dep-dynamic`, `dep-output-not-titled`). The compiler ambient shim is widened in lockstep so script source resolves the new surface. Additive within `apiVersion: 1`.
8
+ - f0c8eb8: Add `extractDependencyGraph` analysis pass and `rewriteDependencyAccessors`
9
+ transformer for indicator composition. Six new `dep-*` compile diagnostics
10
+ plus three structural diagnostics (`multiple-default-exports`,
11
+ `non-const-define-binding`, `duplicate-output-title`). Multi-binding
12
+ `defineIndicator` per file now accepted; single-file behaviour unchanged.
13
+ Existing `.chart.ts` files compile through with byte-identical output.
14
+ - 2123181: Bundle multi-export `.chart.ts` files into one ESM module, inline cross-file
15
+ `.chart.ts` deps recursively via the new `createProducerResolver` walker, emit
16
+ a union-shape manifest sidecar (single object or array depending on
17
+ drawn-export count), and emit per-export `.d.ts` declarations carrying the
18
+ typed `output<K>` / `withInputs` accessors. Single-script files remain
19
+ byte-identical.
20
+ - 2123181: Indicator composition (Phase 7 closeout): one chartlang indicator can
21
+ read another indicator's titled plot output as a typed `Series<number>`.
22
+
23
+ - Compose via local `const` binding plus `<binding>.output("title")` —
24
+ no new public API beyond the chainable `.output` / `.withInputs`
25
+ accessors on `CompiledScriptObject`.
26
+ - A single `.chart.ts` MAY declare a default export plus any number of
27
+ named exports plus any number of private `const` deps. Export form
28
+ determines render policy: drawn exports render with the
29
+ `export:<exportName>/` slot-id prefix; private `const` deps are data
30
+ feeds only and their visuals are dropped.
31
+ - Cross-file `import baseTrend from "./base-trend.chart"` resolves
32
+ recursively; shared producers inline exactly once per consumer.
33
+ - Additive within `apiVersion: 1.x`. The 172-entry
34
+ `STATEFUL_PRIMITIVES` set is unchanged. `DiagnosticCode` widens to 32
35
+ with the new `dep-*` codes (`dep-error`, `dep-cycle`,
36
+ `dep-unknown-output`, `dep-invalid-input-override`, `dep-dynamic`,
37
+ `dep-output-not-titled`).
38
+ - Five conformance scenarios in `@invinite-org/chartlang-conformance`
39
+ pin the runtime contract end-to-end (`dep-private-single-file`,
40
+ `dep-multi-export`, `dep-cross-file`, `dep-diamond`,
41
+ `dep-error-halts-parent`). `Scenario.additionalSources` lets
42
+ cross-file scenarios ship producer + consumer side-by-side.
43
+ - Two new example scripts in `examples/scripts/`:
44
+ `base-trend.chart.ts` (producer) + `trend-confirmation.chart.ts`
45
+ (multi-export consumer). React-demo gains a fifth catalogue entry
46
+ exercising the feature end-to-end in the browser.
47
+ - Docs: `docs/language/indicator-composition.md` narrative guide,
48
+ `docs/spec/manifest.md` + `docs/spec/semantics.md` +
49
+ `docs/spec/versioning.md` updates, five new glossary entries.
50
+
51
+ - 2123181: Light up the end-to-end cross-file dep path for indicator composition. The
52
+ compiler's `rewriteDependencyAccessors` transformer now collapses
53
+ `const <alias> = <root>.withInputs({...})...` chains to the bare root
54
+ identifier so the runtime sentinel never fires at module load; the merged
55
+ effective inputs flow through the `__dependencies[i].inputOverrides` slot
56
+ into the runtime's `DepRunner`. Cross-file producers' `@invinite-org/chartlang-core`
57
+ imports are hoisted above the inlined IIFE so esbuild dedupes them against
58
+ the consumer's imports and pulls in every symbol the producer uses
59
+ (`input.int`, `ta.ema`, …). The `__dependencies` export is now prepended
60
+ pre-bundle so esbuild's tree-shaker keeps each alias binding alive. The
61
+ `dep-cross-file` conformance scenario joins `ALL_SCENARIOS` and the suite
62
+ runs 225 scenarios green.
63
+ - 4d77f4d: Emit `ScriptManifest.plots` — one `PlotSlotDescriptor` per `plot()` /
64
+ `hline()` callsite, in source order, carrying the compiler-issued
65
+ `slotId`, the statically-known plot `kind` (derived from the opts
66
+ `style.kind` literal; bare `plot` ⇒ `line`, `hline` ⇒ `horizontal-line`;
67
+ dynamic styles fall back to `line` best-effort), and a literal `title`
68
+ when present. Additive: the field is omitted for scripts with no
69
+ plot/hline callsites, so existing manifests are byte-identical.
70
+ - 0427459: Persist `defineIndicator({ overlay })` onto `ScriptManifest.overlay?:
71
+ boolean` so the runtime has a script-level default-pane signal. Add
72
+ `HLineOpts.pane?: "overlay" | "new" | string` mirroring `PlotOpts.pane`
73
+ so hlines opt into the same pane router. The compiler's `buildManifest`
74
+ extracts the literal-boolean `overlay` from the `defineIndicator`
75
+ object literal via `extractOverrides` and emits it on the bundled
76
+ `__manifest`; the ambient core shim now carries `ScriptManifest.overlay?`
77
+ and `HLineOpts.pane?` to keep downstream packages type-aligned.
78
+
79
+ Step 1 of the `subpane-rendering` feature. Pure additive contract
80
+ change — every new field is optional and absence keeps existing
81
+ manifests / emissions byte-identical. The runtime, adapter, and demos
82
+ land in tasks 2-5.
83
+
84
+ ### Patch Changes
85
+
86
+ - d6d1a1f: Fix Phase-7 indicator composition where a producer's titled `plot(...)` outputs were never wired to consumers. The compiler computed each binding's `outputs` statically but only wrote them into the manifest sidecar, never onto the producer object's own `manifest.outputs` — so the runtime allocated no dep-output ring buffer and every `<binding>.output("title")` read returned NaN past warmup.
87
+
88
+ `defineIndicator` now copies an optional `outputs` opts field into the manifest (omitted ⇒ manifest byte-identical to a script with no titled plots), and the compiler bakes each producer binding's titled `outputs` into its `defineIndicator({...})` opts literal so private deps, named-export siblings, and cross-file producer defaults are self-describing at runtime. Output-free scripts are untouched. Additive within `apiVersion: 1`.
89
+
90
+ - 3b4952d: Remove the redundant `bars` plot kind. It was never reachable from the script-author API (`PlotOptsStyle` had no `bars` arm and the runtime `buildStyle` had no `case`), no `ta.*` primitive or example emitted it, and the canvas2d reference adapter declared it as a capability but never rendered it. It carried the same `{ baseline: number }` shape as `histogram`, so it was a dead arm of the `PlotKind` / wire-level `PlotStyle` unions.
91
+
92
+ `PlotKind`, the adapter-kit `PlotStyle` union, `validateEmission`, the `capabilities.bars()` / `PHASE_5_PLOT_KINDS` surfaces, and the canvas2d adapter's dead `bars.ts` renderer are all dropped. chartlang has no users yet, so this is a hard reset with no deprecation path. Authors who want columns use `histogram`.
93
+
94
+ - Updated dependencies [d6d1a1f]
95
+ - Updated dependencies [f0c8eb8]
96
+ - Updated dependencies [2123181]
97
+ - Updated dependencies [2123181]
98
+ - Updated dependencies [2123181]
99
+ - Updated dependencies [4d77f4d]
100
+ - Updated dependencies [3b4952d]
101
+ - Updated dependencies [0427459]
102
+ - @invinite-org/chartlang-core@1.1.0
103
+
3
104
  ## 1.0.1
4
105
 
5
106
  ### Patch Changes
package/README.md CHANGED
@@ -29,6 +29,9 @@ pnpm add @invinite-org/chartlang-compiler
29
29
  - Phase 4 diagnostics include `input-call-not-literal`,
30
30
  `input-schema-not-literal`, `requires-intervals-not-literal`, and
31
31
  `request-security-interval-not-literal`.
32
+ - `createProducerResolver({ rootDir }, compileProducer)` — cross-file
33
+ `.chart.ts` resolver feeding indicator-composition (§22.10). Pass it
34
+ to `compile` / `compileFile` / `compileProject` as `resolveProducer`.
32
35
 
33
36
  ## Minimum-viable API call
34
37
 
@@ -10,6 +10,10 @@ type CapabilityId = "indicators" | "drawings" | "alerts" | "alertConditions";
10
10
  * `resolveCalleeName`. The result is deduplicated and sorted for
11
11
  * deterministic manifest output.
12
12
  *
13
+ * The optional `scope` parameter narrows the walk to a single AST subtree
14
+ * (typically one binding's `defineCall`) so multi-export files can derive
15
+ * per-binding capability sets. Defaults to the whole `sourceFile`.
16
+ *
13
17
  * @since 0.1
14
18
  * @example
15
19
  * // const caps = extractCapabilities(sourceFile, checker, "indicator");
@@ -17,6 +21,6 @@ type CapabilityId = "indicators" | "drawings" | "alerts" | "alertConditions";
17
21
  * const fn: typeof extractCapabilities = extractCapabilities;
18
22
  * void fn;
19
23
  */
20
- export declare function extractCapabilities(sourceFile: ts.SourceFile, checker: ts.TypeChecker, kind?: "indicator" | "drawing" | "alert" | "alertCondition"): ReadonlyArray<CapabilityId>;
24
+ export declare function extractCapabilities(sourceFile: ts.SourceFile, checker: ts.TypeChecker, kind?: "indicator" | "drawing" | "alert" | "alertCondition", scope?: ts.Node): ReadonlyArray<CapabilityId>;
21
25
  export {};
22
26
  //# sourceMappingURL=extractCapabilities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extractCapabilities.d.ts","sourceRoot":"","sources":["../../src/analysis/extractCapabilities.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,KAAK,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAE7E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAC/B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,GAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,gBAA8B,GACzE,aAAa,CAAC,YAAY,CAAC,CAyB7B"}
1
+ {"version":3,"file":"extractCapabilities.d.ts","sourceRoot":"","sources":["../../src/analysis/extractCapabilities.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,KAAK,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAC/B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,GAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,gBAA8B,EACxE,KAAK,GAAE,EAAE,CAAC,IAAiB,GAC5B,aAAa,CAAC,YAAY,CAAC,CAyB7B"}
@@ -12,6 +12,10 @@ import { resolveCalleeName } from "../transformers/resolveCallee.js";
12
12
  * `resolveCalleeName`. The result is deduplicated and sorted for
13
13
  * deterministic manifest output.
14
14
  *
15
+ * The optional `scope` parameter narrows the walk to a single AST subtree
16
+ * (typically one binding's `defineCall`) so multi-export files can derive
17
+ * per-binding capability sets. Defaults to the whole `sourceFile`.
18
+ *
15
19
  * @since 0.1
16
20
  * @example
17
21
  * // const caps = extractCapabilities(sourceFile, checker, "indicator");
@@ -19,7 +23,7 @@ import { resolveCalleeName } from "../transformers/resolveCallee.js";
19
23
  * const fn: typeof extractCapabilities = extractCapabilities;
20
24
  * void fn;
21
25
  */
22
- export function extractCapabilities(sourceFile, checker, kind = "indicator") {
26
+ export function extractCapabilities(sourceFile, checker, kind = "indicator", scope = sourceFile) {
23
27
  const SEED_BY_KIND = {
24
28
  indicator: "indicators",
25
29
  drawing: "drawings",
@@ -37,7 +41,7 @@ export function extractCapabilities(sourceFile, checker, kind = "indicator") {
37
41
  }
38
42
  ts.forEachChild(node, visit);
39
43
  };
40
- ts.forEachChild(sourceFile, visit);
44
+ visit(scope);
41
45
  const ordered = Array.from(found).sort();
42
46
  return Object.freeze(ordered);
43
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"extractCapabilities.js","sourceRoot":"","sources":["../../src/analysis/extractCapabilities.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAIrE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,mBAAmB,CAC/B,UAAyB,EACzB,OAAuB,EACvB,OAA6D,WAAW;IAExE,MAAM,YAAY,GAEd;QACA,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AAK,EAAE,QAAQ;QACf,cAAc,EAAE,iBAAiB;KACpC,CAAC;IACF,MAAM,IAAI,GAAiB,YAAY,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,GAAG,CAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5C,MAAM,KAAK,GAAG,CAAC,IAAa,EAAQ,EAAE;QAClC,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;gBACzB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,CAAC;QACL,CAAC;QACD,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC;IACF,KAAK,CAAC,KAAK,CAAC,CAAC;IAEb,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACzC,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,160 @@
1
+ import type { JsonValue, OutputDeclaration } from "@invinite-org/chartlang-core";
2
+ import ts from "typescript";
3
+ import { type CompileDiagnostic } from "../diagnostics.js";
4
+ import type { StructuralBindingInfo } from "./structuralChecks.js";
5
+ /**
6
+ * Producer reference recorded on a consumer-side `const` binding. The
7
+ * same-file variant carries the local binding name; the cross-file
8
+ * variant carries the resolved POSIX path + ES-module export name.
9
+ *
10
+ * @since 0.7
11
+ * @stable
12
+ * @example
13
+ * const r: ProducerRef = { kind: "same-file", bindingName: "baseTrend" };
14
+ * void r;
15
+ */
16
+ export type ProducerRef = Readonly<{
17
+ kind: "same-file";
18
+ bindingName: string;
19
+ }> | Readonly<{
20
+ kind: "cross-file";
21
+ sourcePath: string;
22
+ exportName: string;
23
+ }>;
24
+ /**
25
+ * One dep-graph edge — consumer binding → producer with the merged
26
+ * effective inputs the bundler needs to fold into the producer's
27
+ * compiled module at emit time.
28
+ *
29
+ * @since 0.7
30
+ * @stable
31
+ * @example
32
+ * declare const dummyOutputs: ReadonlyArray<OutputDeclaration>;
33
+ * const e: DepConsumesEntry = {
34
+ * localId: "fastTrend",
35
+ * producerRef: { kind: "same-file", bindingName: "baseTrend" },
36
+ * outputs: dummyOutputs,
37
+ * effectiveInputs: { length: 20 },
38
+ * };
39
+ * void e;
40
+ */
41
+ export type DepConsumesEntry = Readonly<{
42
+ readonly localId: string;
43
+ readonly producerRef: ProducerRef;
44
+ readonly outputs: ReadonlyArray<OutputDeclaration>;
45
+ readonly effectiveInputs: Readonly<Record<string, JsonValue>>;
46
+ }>;
47
+ /**
48
+ * One exported (drawn) indicator the file declares. `exportName` is
49
+ * `"default"` for `export default`, the identifier text otherwise.
50
+ *
51
+ * @since 0.7
52
+ * @stable
53
+ * @example
54
+ * // declare const callExpression: ts.CallExpression;
55
+ * const d: DrawnScript = {
56
+ * exportName: "default",
57
+ * bindingName: "default",
58
+ * defineCall: undefined as unknown as ts.CallExpression,
59
+ * outputs: [],
60
+ * consumes: [],
61
+ * };
62
+ * void d;
63
+ */
64
+ export type DrawnScript = Readonly<{
65
+ readonly exportName: string;
66
+ readonly bindingName: string;
67
+ readonly defineCall: ts.CallExpression;
68
+ readonly outputs: ReadonlyArray<OutputDeclaration>;
69
+ readonly consumes: ReadonlyArray<DepConsumesEntry>;
70
+ }>;
71
+ /**
72
+ * One private (data-only) dep binding the file declares. `defineCall`
73
+ * is `null` when the dep is a cross-file binding (the AST node lives
74
+ * in the producer's source file).
75
+ *
76
+ * @since 0.7
77
+ * @stable
78
+ * @example
79
+ * const d: PrivateDep = {
80
+ * localId: "fastTrend",
81
+ * producerRef: { kind: "same-file", bindingName: "baseTrend" },
82
+ * effectiveInputs: { length: 20 },
83
+ * defineCall: null,
84
+ * outputs: [],
85
+ * consumes: [],
86
+ * };
87
+ * void d;
88
+ */
89
+ export type PrivateDep = Readonly<{
90
+ readonly localId: string;
91
+ readonly producerRef: ProducerRef;
92
+ readonly effectiveInputs: Readonly<Record<string, JsonValue>>;
93
+ readonly defineCall: ts.CallExpression | null;
94
+ readonly outputs: ReadonlyArray<OutputDeclaration>;
95
+ readonly consumes: ReadonlyArray<DepConsumesEntry>;
96
+ }>;
97
+ /**
98
+ * Producer snapshot returned by `resolveProducer` for cross-file
99
+ * `import X from "./Y.chart"` consumer references.
100
+ *
101
+ * @since 0.7
102
+ * @stable
103
+ * @example
104
+ * const snap: ProducerSnapshot = { name: "trend", outputs: [], inputs: {} };
105
+ * void snap;
106
+ */
107
+ export type ProducerSnapshot = Readonly<{
108
+ readonly name: string;
109
+ readonly outputs: ReadonlyArray<OutputDeclaration>;
110
+ readonly inputs: Readonly<Record<string, unknown>>;
111
+ }>;
112
+ /**
113
+ * Callback the bundler supplies so the analysis pass can recursively
114
+ * compile sibling `.chart.ts` files. Returns `null` when the producer
115
+ * cannot be resolved (cycle, unknown path, no `defineIndicator(...)`).
116
+ *
117
+ * @since 0.7
118
+ * @stable
119
+ * @example
120
+ * const r: ResolveProducer = () => null;
121
+ * void r;
122
+ */
123
+ export type ResolveProducer = (sourcePath: string, exportName: string) => ProducerSnapshot | null;
124
+ /**
125
+ * The compiled dep-graph artefact returned by `extractDependencyGraph`.
126
+ * `drawn` + `privateDeps` are the indexed binding sets; `diagnostics`
127
+ * is the union of every per-binding diagnostic surfaced during
128
+ * walking + validation.
129
+ *
130
+ * @since 0.7
131
+ * @stable
132
+ * @example
133
+ * const g: DepGraph = { drawn: [], privateDeps: [], diagnostics: [] };
134
+ * void g;
135
+ */
136
+ export type DepGraph = Readonly<{
137
+ readonly drawn: ReadonlyArray<DrawnScript>;
138
+ readonly privateDeps: ReadonlyArray<PrivateDep>;
139
+ readonly diagnostics: ReadonlyArray<CompileDiagnostic>;
140
+ }>;
141
+ /**
142
+ * Run the dependency-graph analysis pass over a `.chart.ts` source
143
+ * file. Sweeps the AST four times — outputs, withInputs chains,
144
+ * consumer `.output(...)` calls, cycle detection — and returns a
145
+ * frozen `DepGraph` plus the diagnostics surfaced along the way.
146
+ *
147
+ * `resolveProducer` is a caller-supplied callback that the bundler
148
+ * (Task 3) wires to a recursive compile entry point. In Task 2 the
149
+ * pass works against `() => null` for cross-file edges; tests pass
150
+ * mocked snapshots instead.
151
+ *
152
+ * @since 0.7
153
+ * @stable
154
+ * @example
155
+ * // const graph = extractDependencyGraph(sf, checker, "demo.chart.ts", bindings, () => null);
156
+ * const fn: typeof extractDependencyGraph = extractDependencyGraph;
157
+ * void fn;
158
+ */
159
+ export declare function extractDependencyGraph(sourceFile: ts.SourceFile, checker: ts.TypeChecker, sourcePath: string, structuralBindings: ReadonlyArray<StructuralBindingInfo>, resolveProducer: ResolveProducer): DepGraph;
160
+ //# sourceMappingURL=extractDependencyGraph.d.ts.map
@@ -0,0 +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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