@invinite-org/chartlang-compiler 1.0.1 → 1.2.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 +107 -0
- package/README.md +3 -0
- package/dist/analysis/extractCapabilities.d.ts +5 -1
- package/dist/analysis/extractCapabilities.d.ts.map +1 -1
- package/dist/analysis/extractCapabilities.js +6 -2
- package/dist/analysis/extractCapabilities.js.map +1 -1
- package/dist/analysis/extractDependencyGraph.d.ts +160 -0
- package/dist/analysis/extractDependencyGraph.d.ts.map +1 -0
- package/dist/analysis/extractDependencyGraph.js +690 -0
- package/dist/analysis/extractDependencyGraph.js.map +1 -0
- package/dist/analysis/extractInputs.d.ts +5 -1
- package/dist/analysis/extractInputs.d.ts.map +1 -1
- package/dist/analysis/extractInputs.js +6 -2
- package/dist/analysis/extractInputs.js.map +1 -1
- package/dist/analysis/extractMaxLookback.d.ts +6 -1
- package/dist/analysis/extractMaxLookback.d.ts.map +1 -1
- package/dist/analysis/extractMaxLookback.js +10 -5
- package/dist/analysis/extractMaxLookback.js.map +1 -1
- package/dist/analysis/forbiddenConstructs.d.ts +1 -2
- package/dist/analysis/forbiddenConstructs.d.ts.map +1 -1
- package/dist/analysis/forbiddenConstructs.js +4 -2
- package/dist/analysis/forbiddenConstructs.js.map +1 -1
- package/dist/analysis/index.d.ts +3 -1
- package/dist/analysis/index.d.ts.map +1 -1
- package/dist/analysis/index.js +1 -0
- package/dist/analysis/index.js.map +1 -1
- package/dist/analysis/structuralChecks.d.ts +65 -9
- package/dist/analysis/structuralChecks.d.ts.map +1 -1
- package/dist/analysis/structuralChecks.js +111 -22
- package/dist/analysis/structuralChecks.js.map +1 -1
- package/dist/api.d.ts +52 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +485 -35
- package/dist/api.js.map +1 -1
- package/dist/bundle.d.ts +91 -3
- package/dist/bundle.d.ts.map +1 -1
- package/dist/bundle.js +88 -5
- package/dist/bundle.js.map +1 -1
- package/dist/dependency/index.d.ts +3 -0
- package/dist/dependency/index.d.ts.map +1 -0
- package/dist/dependency/index.js +4 -0
- package/dist/dependency/index.js.map +1 -0
- package/dist/dependency/resolveProducer.d.ts +183 -0
- package/dist/dependency/resolveProducer.d.ts.map +1 -0
- package/dist/dependency/resolveProducer.js +256 -0
- package/dist/dependency/resolveProducer.js.map +1 -0
- package/dist/diagnostics.d.ts +6 -2
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +8 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +27 -0
- package/dist/manifest.js.map +1 -1
- package/dist/program.d.ts +1 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +80 -4
- package/dist/program.js.map +1 -1
- package/dist/transformers/callsiteIdInjection.d.ts +3 -2
- package/dist/transformers/callsiteIdInjection.d.ts.map +1 -1
- package/dist/transformers/callsiteIdInjection.js +16 -1
- package/dist/transformers/callsiteIdInjection.js.map +1 -1
- package/dist/transformers/index.d.ts +2 -0
- package/dist/transformers/index.d.ts.map +1 -1
- package/dist/transformers/index.js +1 -0
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/plotKindFromCallsite.d.ts +43 -0
- package/dist/transformers/plotKindFromCallsite.d.ts.map +1 -0
- package/dist/transformers/plotKindFromCallsite.js +103 -0
- package/dist/transformers/plotKindFromCallsite.js.map +1 -0
- package/dist/transformers/rewriteDependencyAccessors.d.ts +65 -0
- package/dist/transformers/rewriteDependencyAccessors.d.ts.map +1 -0
- package/dist/transformers/rewriteDependencyAccessors.js +204 -0
- package/dist/transformers/rewriteDependencyAccessors.js.map +1 -0
- package/dist/typesEmit.d.ts +14 -11
- package/dist/typesEmit.d.ts.map +1 -1
- package/dist/typesEmit.js +91 -7
- package/dist/typesEmit.js.map +1 -1
- package/package.json +2 -2
package/dist/program.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAE3D;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAE3D;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;IAC5B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StatefulPrimitiveEntry } from "@invinite-org/chartlang-core";
|
|
1
|
+
import type { PlotSlotDescriptor, StatefulPrimitiveEntry } from "@invinite-org/chartlang-core";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import { type CompileDiagnostic } from "../diagnostics.js";
|
|
4
4
|
/**
|
|
@@ -22,7 +22,7 @@ export type InjectCallsiteIdsResult = Readonly<{
|
|
|
22
22
|
}>;
|
|
23
23
|
/**
|
|
24
24
|
* Inject a `__slot` string-literal first argument into every stateful
|
|
25
|
-
* primitive call. Slot id format
|
|
25
|
+
* primitive call. Slot id format:
|
|
26
26
|
* `<sourcePath>:<line>:<col>#<callIndex>`. `callIndex` is hardcoded to `0`
|
|
27
27
|
* for hand-written code (Phase 1 reserves non-zero for future macros).
|
|
28
28
|
*
|
|
@@ -44,5 +44,6 @@ export declare function injectCallsiteIds(sourceFile: ts.SourceFile, checker: ts
|
|
|
44
44
|
readonly sourcePath: string;
|
|
45
45
|
readonly statefulByName: ReadonlyMap<string, StatefulPrimitiveEntry>;
|
|
46
46
|
readonly slotsSeen?: Map<string, ts.CallExpression>;
|
|
47
|
+
readonly plotSlots?: PlotSlotDescriptor[];
|
|
47
48
|
}): InjectCallsiteIdsResult;
|
|
48
49
|
//# sourceMappingURL=callsiteIdInjection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callsiteIdInjection.d.ts","sourceRoot":"","sources":["../../src/transformers/callsiteIdInjection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"callsiteIdInjection.d.ts","sourceRoot":"","sources":["../../src/transformers/callsiteIdInjection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,KAAK,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAI7E;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC3C,WAAW,EAAE,EAAE,CAAC,UAAU,CAAC;IAC3B,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACjD,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC7B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACrE,QAAQ,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC7C,GACF,uBAAuB,CAmGzB"}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
import { createDiagnostic } from "../diagnostics.js";
|
|
5
|
+
import { plotKindFromCallsite, readLiteralTitle } from "./plotKindFromCallsite.js";
|
|
5
6
|
import { resolveCalleeName, resolveCoreSymbolForElementAccess } from "./resolveCallee.js";
|
|
6
7
|
/**
|
|
7
8
|
* Inject a `__slot` string-literal first argument into every stateful
|
|
8
|
-
* primitive call. Slot id format
|
|
9
|
+
* primitive call. Slot id format:
|
|
9
10
|
* `<sourcePath>:<line>:<col>#<callIndex>`. `callIndex` is hardcoded to `0`
|
|
10
11
|
* for hand-written code (Phase 1 reserves non-zero for future macros).
|
|
11
12
|
*
|
|
@@ -25,6 +26,7 @@ import { resolveCalleeName, resolveCoreSymbolForElementAccess } from "./resolveC
|
|
|
25
26
|
*/
|
|
26
27
|
export function injectCallsiteIds(sourceFile, checker, opts) {
|
|
27
28
|
const { sourcePath, statefulByName } = opts;
|
|
29
|
+
const plotSlots = opts.plotSlots;
|
|
28
30
|
const slotsSeen = opts.slotsSeen ?? new Map();
|
|
29
31
|
const diagnostics = [];
|
|
30
32
|
const factory = (context) => {
|
|
@@ -67,6 +69,19 @@ export function injectCallsiteIds(sourceFile, checker, opts) {
|
|
|
67
69
|
return ts.visitEachChild(node, visit, context);
|
|
68
70
|
}
|
|
69
71
|
slotsSeen.set(slotId, node);
|
|
72
|
+
if (plotSlots !== undefined &&
|
|
73
|
+
(calleeName === "plot" || calleeName === "hline")) {
|
|
74
|
+
const optsArg = node.arguments[1];
|
|
75
|
+
// best-effort dynamic-kind fallback: a callsite whose
|
|
76
|
+
// `style` is non-literal is still listed as "line".
|
|
77
|
+
const kind = plotKindFromCallsite(calleeName, optsArg) ?? "line";
|
|
78
|
+
const title = readLiteralTitle(optsArg);
|
|
79
|
+
plotSlots.push(Object.freeze({
|
|
80
|
+
slotId,
|
|
81
|
+
kind,
|
|
82
|
+
...(title === undefined ? {} : { title }),
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
70
85
|
const visitedArguments = node.arguments.map((argument) => ts.visitNode(argument, visit, ts.isExpression));
|
|
71
86
|
const updatedArguments = ts.factory.createNodeArray([
|
|
72
87
|
ts.factory.createStringLiteral(slotId),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callsiteIdInjection.js","sourceRoot":"","sources":["../../src/transformers/callsiteIdInjection.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAA0B,gBAAgB,EAAE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Aa,EACb,IAAI,CAAC,aAAa,EAClB,gBAAgB,CACnB,CAAC;gBACN,CAAC;YACL,CAAC;YACD,OAAO,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,YAAY,CAAkB,CAAC;IACjF,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,OAAO,EAAE,CAAC;IACjB,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,WAAW;QACX,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;KAClD,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { resolveCalleeName } from "./resolveCallee.js";
|
|
2
2
|
export { injectCallsiteIds } from "./callsiteIdInjection.js";
|
|
3
3
|
export type { InjectCallsiteIdsResult } from "./callsiteIdInjection.js";
|
|
4
|
+
export { rewriteDependencyAccessors } from "./rewriteDependencyAccessors.js";
|
|
5
|
+
export type { RewriteDependencyAccessorsResult } from "./rewriteDependencyAccessors.js";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,YAAY,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
3
|
export { resolveCalleeName } from "./resolveCallee.js";
|
|
4
4
|
export { injectCallsiteIds } from "./callsiteIdInjection.js";
|
|
5
|
+
export { rewriteDependencyAccessors } from "./rewriteDependencyAccessors.js";
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { PlotKind } from "@invinite-org/chartlang-core";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
/**
|
|
4
|
+
* Derive the statically-known {@link PlotKind} for a plotting callsite from
|
|
5
|
+
* its callee name and opts argument. The chartlang plot surface has no
|
|
6
|
+
* `plot.*` member API — the kind is selected at the callsite via the opts
|
|
7
|
+
* object literal's `style.kind` property (mirrored by the runtime's
|
|
8
|
+
* `buildStyle`). Returns:
|
|
9
|
+
*
|
|
10
|
+
* - `"horizontal-line"` for `hline`.
|
|
11
|
+
* - `"line"` for a bare `plot` with no `style` (no opts, opts without
|
|
12
|
+
* `style`, or a non-object opts).
|
|
13
|
+
* - the literal `style.kind` value for `plot(x, { style: { kind: "<lit>" } })`
|
|
14
|
+
* when it is a string literal naming a `PlotKind` member.
|
|
15
|
+
* - `undefined` when the kind is not statically determinable: a dynamic
|
|
16
|
+
* `style` (`{ style: someVar }`), a dynamic `kind` (`{ style: { kind:
|
|
17
|
+
* someVar } }`), or a string literal that is not a `PlotKind` member.
|
|
18
|
+
* The caller falls back to `"line"` (best-effort) so the slot is still
|
|
19
|
+
* listed.
|
|
20
|
+
*
|
|
21
|
+
* @since 0.8
|
|
22
|
+
* @example
|
|
23
|
+
* // const kind = plotKindFromCallsite("plot", optsObjectLiteralNode);
|
|
24
|
+
* // kind === "histogram" | "line" | undefined | ...
|
|
25
|
+
* const fn: typeof plotKindFromCallsite = plotKindFromCallsite;
|
|
26
|
+
* void fn;
|
|
27
|
+
*/
|
|
28
|
+
export declare function plotKindFromCallsite(calleeName: string, optsArg: ts.Expression | undefined): PlotKind | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Read a string-literal `title` from a plotting callsite's opts object
|
|
31
|
+
* literal. Returns `undefined` for a missing, dynamic, or non-string
|
|
32
|
+
* `title` so the manifest omits the field rather than recording a
|
|
33
|
+
* placeholder.
|
|
34
|
+
*
|
|
35
|
+
* @since 0.8
|
|
36
|
+
* @example
|
|
37
|
+
* // const title = readLiteralTitle(optsObjectLiteralNode);
|
|
38
|
+
* // title === "Vol" | undefined
|
|
39
|
+
* const fn: typeof readLiteralTitle = readLiteralTitle;
|
|
40
|
+
* void fn;
|
|
41
|
+
*/
|
|
42
|
+
export declare function readLiteralTitle(optsArg: ts.Expression | undefined): string | undefined;
|
|
43
|
+
//# sourceMappingURL=plotKindFromCallsite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plotKindFromCallsite.d.ts","sourceRoot":"","sources":["../../src/transformers/plotKindFromCallsite.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,MAAM,YAAY,CAAC;AAyC5B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,EAAE,CAAC,UAAU,GAAG,SAAS,GACnC,QAAQ,GAAG,SAAS,CAatB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAMvF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
const PLOT_KINDS = new Set([
|
|
5
|
+
"line",
|
|
6
|
+
"step-line",
|
|
7
|
+
"horizontal-line",
|
|
8
|
+
"histogram",
|
|
9
|
+
"area",
|
|
10
|
+
"filled-band",
|
|
11
|
+
"label",
|
|
12
|
+
"marker",
|
|
13
|
+
"shape",
|
|
14
|
+
"character",
|
|
15
|
+
"arrow",
|
|
16
|
+
"candle-override",
|
|
17
|
+
"bar-override",
|
|
18
|
+
"bg-color",
|
|
19
|
+
"bar-color",
|
|
20
|
+
"horizontal-histogram",
|
|
21
|
+
]);
|
|
22
|
+
function isPlotKind(value) {
|
|
23
|
+
return PLOT_KINDS.has(value);
|
|
24
|
+
}
|
|
25
|
+
function findProperty(obj, name) {
|
|
26
|
+
for (const property of obj.properties) {
|
|
27
|
+
if (ts.isPropertyAssignment(property) &&
|
|
28
|
+
ts.isIdentifier(property.name) &&
|
|
29
|
+
property.name.text === name) {
|
|
30
|
+
return property;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Derive the statically-known {@link PlotKind} for a plotting callsite from
|
|
37
|
+
* its callee name and opts argument. The chartlang plot surface has no
|
|
38
|
+
* `plot.*` member API — the kind is selected at the callsite via the opts
|
|
39
|
+
* object literal's `style.kind` property (mirrored by the runtime's
|
|
40
|
+
* `buildStyle`). Returns:
|
|
41
|
+
*
|
|
42
|
+
* - `"horizontal-line"` for `hline`.
|
|
43
|
+
* - `"line"` for a bare `plot` with no `style` (no opts, opts without
|
|
44
|
+
* `style`, or a non-object opts).
|
|
45
|
+
* - the literal `style.kind` value for `plot(x, { style: { kind: "<lit>" } })`
|
|
46
|
+
* when it is a string literal naming a `PlotKind` member.
|
|
47
|
+
* - `undefined` when the kind is not statically determinable: a dynamic
|
|
48
|
+
* `style` (`{ style: someVar }`), a dynamic `kind` (`{ style: { kind:
|
|
49
|
+
* someVar } }`), or a string literal that is not a `PlotKind` member.
|
|
50
|
+
* The caller falls back to `"line"` (best-effort) so the slot is still
|
|
51
|
+
* listed.
|
|
52
|
+
*
|
|
53
|
+
* @since 0.8
|
|
54
|
+
* @example
|
|
55
|
+
* // const kind = plotKindFromCallsite("plot", optsObjectLiteralNode);
|
|
56
|
+
* // kind === "histogram" | "line" | undefined | ...
|
|
57
|
+
* const fn: typeof plotKindFromCallsite = plotKindFromCallsite;
|
|
58
|
+
* void fn;
|
|
59
|
+
*/
|
|
60
|
+
export function plotKindFromCallsite(calleeName, optsArg) {
|
|
61
|
+
if (calleeName === "hline")
|
|
62
|
+
return "horizontal-line";
|
|
63
|
+
if (calleeName !== "plot")
|
|
64
|
+
return undefined;
|
|
65
|
+
if (optsArg === undefined || !ts.isObjectLiteralExpression(optsArg))
|
|
66
|
+
return "line";
|
|
67
|
+
const styleProp = findProperty(optsArg, "style");
|
|
68
|
+
if (styleProp === undefined)
|
|
69
|
+
return "line";
|
|
70
|
+
const style = styleProp.initializer;
|
|
71
|
+
if (!ts.isObjectLiteralExpression(style))
|
|
72
|
+
return undefined;
|
|
73
|
+
const kindProp = findProperty(style, "kind");
|
|
74
|
+
if (kindProp === undefined)
|
|
75
|
+
return undefined;
|
|
76
|
+
const kind = kindProp.initializer;
|
|
77
|
+
if (!ts.isStringLiteral(kind))
|
|
78
|
+
return undefined;
|
|
79
|
+
return isPlotKind(kind.text) ? kind.text : undefined;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Read a string-literal `title` from a plotting callsite's opts object
|
|
83
|
+
* literal. Returns `undefined` for a missing, dynamic, or non-string
|
|
84
|
+
* `title` so the manifest omits the field rather than recording a
|
|
85
|
+
* placeholder.
|
|
86
|
+
*
|
|
87
|
+
* @since 0.8
|
|
88
|
+
* @example
|
|
89
|
+
* // const title = readLiteralTitle(optsObjectLiteralNode);
|
|
90
|
+
* // title === "Vol" | undefined
|
|
91
|
+
* const fn: typeof readLiteralTitle = readLiteralTitle;
|
|
92
|
+
* void fn;
|
|
93
|
+
*/
|
|
94
|
+
export function readLiteralTitle(optsArg) {
|
|
95
|
+
if (optsArg === undefined || !ts.isObjectLiteralExpression(optsArg))
|
|
96
|
+
return undefined;
|
|
97
|
+
const titleProp = findProperty(optsArg, "title");
|
|
98
|
+
if (titleProp === undefined)
|
|
99
|
+
return undefined;
|
|
100
|
+
const title = titleProp.initializer;
|
|
101
|
+
return ts.isStringLiteral(title) ? title.text : undefined;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=plotKindFromCallsite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plotKindFromCallsite.js","sourceRoot":"","sources":["../../src/transformers/plotKindFromCallsite.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA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AAI,CAAC,EAAE,CAAC,yBAAyB,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3D,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC;IAClC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAChD,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAkC;IAC/D,IAAI,OAAO,KAAK,SAAS,IAAI,CAAC,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IACtF,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjD,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC;IACpC,OAAO,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import type { DepGraph } from "../analysis/extractDependencyGraph.js";
|
|
3
|
+
import type { CompileDiagnostic } from "../diagnostics.js";
|
|
4
|
+
/**
|
|
5
|
+
* Result of `rewriteDependencyAccessors`. `transformed` is the new
|
|
6
|
+
* source file where every consumer-side `<binding>.output("title")`
|
|
7
|
+
* call has been replaced with the synthesised
|
|
8
|
+
* `__chartlang_depOutput("slotId", "localId", "title")` call the
|
|
9
|
+
* runtime's dep executor (Phase 7 / Task 4) consumes.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.7
|
|
12
|
+
* @stable
|
|
13
|
+
* @example
|
|
14
|
+
* const r: RewriteDependencyAccessorsResult = {
|
|
15
|
+
* transformed: undefined as unknown as ts.SourceFile,
|
|
16
|
+
* diagnostics: [],
|
|
17
|
+
* };
|
|
18
|
+
* void r;
|
|
19
|
+
*/
|
|
20
|
+
export type RewriteDependencyAccessorsResult = Readonly<{
|
|
21
|
+
readonly transformed: ts.SourceFile;
|
|
22
|
+
readonly diagnostics: ReadonlyArray<CompileDiagnostic>;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Rewrite every consumer-side `<binding>.output("title")` call into
|
|
26
|
+
* `__chartlang_depOutput("slotId", "localId", "title")`. The receiver
|
|
27
|
+
* traces back to a binding declared in the file's
|
|
28
|
+
* {@link DepGraph}; the slot id follows the existing
|
|
29
|
+
* `<sourcePath>:<line>:<col>#0` format (Phase 1 §5.5) read from the
|
|
30
|
+
* **input** source file before any rewrite. Bindings that are not
|
|
31
|
+
* part of the dep graph (zero consumes, unknown receivers) are
|
|
32
|
+
* left untouched — they would already have raised diagnostics during
|
|
33
|
+
* `extractDependencyGraph`.
|
|
34
|
+
*
|
|
35
|
+
* The same pass injects each producer binding's statically-resolved
|
|
36
|
+
* titled `outputs` into its `defineIndicator({...})` opts literal so
|
|
37
|
+
* the runtime object built by `defineIndicator` carries
|
|
38
|
+
* `manifest.outputs` directly. Without this, a sibling- or dep-mounted
|
|
39
|
+
* producer's `manifest.outputs` is `undefined` at runtime — the host
|
|
40
|
+
* never allocates a {@link DepOutputStore} ring buffer for it and the
|
|
41
|
+
* consumer's `.output("title")` reads NaN every bar (Phase-7
|
|
42
|
+
* composition bug). The compiler already computes these outputs in
|
|
43
|
+
* `extractDependencyGraph`; here they are baked onto the producer
|
|
44
|
+
* object so every host path (worker, quickjs, conformance) wires the
|
|
45
|
+
* store with zero assembler changes. The injection is scoped to
|
|
46
|
+
* bindings that are producers within a composition graph — private
|
|
47
|
+
* deps and named-export siblings always, the default export only when
|
|
48
|
+
* the file participates in composition (multi-export or has private
|
|
49
|
+
* deps) or is itself consumed cross-file — so a standalone
|
|
50
|
+
* single-export script with no deps stays byte-identical.
|
|
51
|
+
*
|
|
52
|
+
* Runs **before** `injectCallsiteIds` so the synthesised
|
|
53
|
+
* `__chartlang_depOutput` carries a slot id read from the original
|
|
54
|
+
* source positions.
|
|
55
|
+
*
|
|
56
|
+
* @since 0.7
|
|
57
|
+
* @stable
|
|
58
|
+
* @example
|
|
59
|
+
* // Input: fastTrend.output("line")
|
|
60
|
+
* // Output: __chartlang_depOutput("demo.chart.ts:6:14#0", "fastTrend", "line")
|
|
61
|
+
* const fn: typeof rewriteDependencyAccessors = rewriteDependencyAccessors;
|
|
62
|
+
* void fn;
|
|
63
|
+
*/
|
|
64
|
+
export declare function rewriteDependencyAccessors(sourceFile: ts.SourceFile, depGraph: DepGraph, sourcePath: string): RewriteDependencyAccessorsResult;
|
|
65
|
+
//# sourceMappingURL=rewriteDependencyAccessors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewriteDependencyAccessors.d.ts","sourceRoot":"","sources":["../../src/transformers/rewriteDependencyAccessors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,gCAAgC,GAAG,QAAQ,CAAC;IACpD,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,UAAU,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC1D,CAAC,CAAC;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,0BAA0B,CACtC,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,GACnB,gCAAgC,CAgFlC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
const DEP_OUTPUT_HELPER = "__chartlang_depOutput";
|
|
5
|
+
/**
|
|
6
|
+
* Rewrite every consumer-side `<binding>.output("title")` call into
|
|
7
|
+
* `__chartlang_depOutput("slotId", "localId", "title")`. The receiver
|
|
8
|
+
* traces back to a binding declared in the file's
|
|
9
|
+
* {@link DepGraph}; the slot id follows the existing
|
|
10
|
+
* `<sourcePath>:<line>:<col>#0` format (Phase 1 §5.5) read from the
|
|
11
|
+
* **input** source file before any rewrite. Bindings that are not
|
|
12
|
+
* part of the dep graph (zero consumes, unknown receivers) are
|
|
13
|
+
* left untouched — they would already have raised diagnostics during
|
|
14
|
+
* `extractDependencyGraph`.
|
|
15
|
+
*
|
|
16
|
+
* The same pass injects each producer binding's statically-resolved
|
|
17
|
+
* titled `outputs` into its `defineIndicator({...})` opts literal so
|
|
18
|
+
* the runtime object built by `defineIndicator` carries
|
|
19
|
+
* `manifest.outputs` directly. Without this, a sibling- or dep-mounted
|
|
20
|
+
* producer's `manifest.outputs` is `undefined` at runtime — the host
|
|
21
|
+
* never allocates a {@link DepOutputStore} ring buffer for it and the
|
|
22
|
+
* consumer's `.output("title")` reads NaN every bar (Phase-7
|
|
23
|
+
* composition bug). The compiler already computes these outputs in
|
|
24
|
+
* `extractDependencyGraph`; here they are baked onto the producer
|
|
25
|
+
* object so every host path (worker, quickjs, conformance) wires the
|
|
26
|
+
* store with zero assembler changes. The injection is scoped to
|
|
27
|
+
* bindings that are producers within a composition graph — private
|
|
28
|
+
* deps and named-export siblings always, the default export only when
|
|
29
|
+
* the file participates in composition (multi-export or has private
|
|
30
|
+
* deps) or is itself consumed cross-file — so a standalone
|
|
31
|
+
* single-export script with no deps stays byte-identical.
|
|
32
|
+
*
|
|
33
|
+
* Runs **before** `injectCallsiteIds` so the synthesised
|
|
34
|
+
* `__chartlang_depOutput` carries a slot id read from the original
|
|
35
|
+
* source positions.
|
|
36
|
+
*
|
|
37
|
+
* @since 0.7
|
|
38
|
+
* @stable
|
|
39
|
+
* @example
|
|
40
|
+
* // Input: fastTrend.output("line")
|
|
41
|
+
* // Output: __chartlang_depOutput("demo.chart.ts:6:14#0", "fastTrend", "line")
|
|
42
|
+
* const fn: typeof rewriteDependencyAccessors = rewriteDependencyAccessors;
|
|
43
|
+
* void fn;
|
|
44
|
+
*/
|
|
45
|
+
export function rewriteDependencyAccessors(sourceFile, depGraph, sourcePath) {
|
|
46
|
+
const knownLocalIds = new Set();
|
|
47
|
+
for (const drawn of depGraph.drawn)
|
|
48
|
+
knownLocalIds.add(drawn.bindingName);
|
|
49
|
+
for (const dep of depGraph.privateDeps)
|
|
50
|
+
knownLocalIds.add(dep.localId);
|
|
51
|
+
const outputsByDefineCall = collectProducerOutputs(depGraph);
|
|
52
|
+
// `withInputs`-derived aliases (synthetic private deps with no
|
|
53
|
+
// `defineCall` of their own). Every such alias's declaration is
|
|
54
|
+
// rewritten from `const <alias> = <root>.withInputs({...})...;` to
|
|
55
|
+
// `const <alias> = <root>;` so the runtime sentinel never fires
|
|
56
|
+
// when the bundle is loaded. The merged effective inputs flow into
|
|
57
|
+
// the dep runner through the manifest's `dependencies` entry; the
|
|
58
|
+
// alias binding itself just needs to be a `CompiledScriptObject`
|
|
59
|
+
// reference.
|
|
60
|
+
const aliasLocalIds = new Set();
|
|
61
|
+
for (const dep of depGraph.privateDeps) {
|
|
62
|
+
if (dep.defineCall === null)
|
|
63
|
+
aliasLocalIds.add(dep.localId);
|
|
64
|
+
}
|
|
65
|
+
const factory = (context) => {
|
|
66
|
+
const visit = (node) => {
|
|
67
|
+
if (ts.isCallExpression(node)) {
|
|
68
|
+
const outputs = outputsByDefineCall.get(node);
|
|
69
|
+
if (outputs !== undefined) {
|
|
70
|
+
const injected = injectOutputsIntoDefineCall(node, outputs);
|
|
71
|
+
return ts.visitEachChild(injected, visit, context);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (ts.isVariableDeclaration(node) &&
|
|
75
|
+
ts.isIdentifier(node.name) &&
|
|
76
|
+
aliasLocalIds.has(node.name.text) &&
|
|
77
|
+
node.initializer !== undefined) {
|
|
78
|
+
const root = resolveChainRoot(node.initializer);
|
|
79
|
+
if (root !== null) {
|
|
80
|
+
return ts.factory.updateVariableDeclaration(node, node.name, node.exclamationToken, node.type, ts.factory.createIdentifier(root.text));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (ts.isCallExpression(node) &&
|
|
84
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
85
|
+
node.expression.name.text === "output") {
|
|
86
|
+
const arg = node.arguments[0];
|
|
87
|
+
if (arg !== undefined && ts.isStringLiteral(arg)) {
|
|
88
|
+
const receiverRoot = resolveReceiverRoot(node.expression.expression);
|
|
89
|
+
if (receiverRoot !== null && knownLocalIds.has(receiverRoot.text)) {
|
|
90
|
+
const start = node.getStart(sourceFile);
|
|
91
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);
|
|
92
|
+
const slotId = `${sourcePath}:${line + 1}:${character + 1}#0`;
|
|
93
|
+
return ts.factory.createCallExpression(ts.factory.createIdentifier(DEP_OUTPUT_HELPER), undefined, [
|
|
94
|
+
ts.factory.createStringLiteral(slotId),
|
|
95
|
+
ts.factory.createStringLiteral(receiverRoot.text),
|
|
96
|
+
ts.factory.createStringLiteral(arg.text),
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return ts.visitEachChild(node, visit, context);
|
|
102
|
+
};
|
|
103
|
+
return (file) => ts.visitNode(file, visit, ts.isSourceFile);
|
|
104
|
+
};
|
|
105
|
+
const result = ts.transform(sourceFile, [factory]);
|
|
106
|
+
const transformed = result.transformed[0];
|
|
107
|
+
result.dispose();
|
|
108
|
+
return Object.freeze({
|
|
109
|
+
transformed,
|
|
110
|
+
diagnostics: Object.freeze([]),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Walk back from a `<root>.withInputs({...}).withInputs({...})` chain
|
|
115
|
+
* to its rooted identifier. The analysis pass already validates every
|
|
116
|
+
* alias's chain shape (`dep-dynamic` errors abort the rewrite long
|
|
117
|
+
* before we reach this function), so only the happy path is exercised
|
|
118
|
+
* in production; the defensive `null` branches keep the rewriter
|
|
119
|
+
* conservative if a future caller misuses it.
|
|
120
|
+
*/
|
|
121
|
+
function resolveChainRoot(expression) {
|
|
122
|
+
let current = expression;
|
|
123
|
+
while (ts.isCallExpression(current)) {
|
|
124
|
+
const callee = current.expression;
|
|
125
|
+
/* v8 ignore next 2 */
|
|
126
|
+
if (!ts.isPropertyAccessExpression(callee))
|
|
127
|
+
return null;
|
|
128
|
+
if (callee.name.text !== "withInputs")
|
|
129
|
+
return null;
|
|
130
|
+
current = callee.expression;
|
|
131
|
+
}
|
|
132
|
+
/* v8 ignore next 2 */
|
|
133
|
+
if (!ts.isIdentifier(current))
|
|
134
|
+
return null;
|
|
135
|
+
return current;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Map each producer binding's original `defineIndicator(...)` call node
|
|
139
|
+
* to the titled outputs that must be baked onto its runtime manifest.
|
|
140
|
+
*
|
|
141
|
+
* A binding is in scope when it has a real `defineCall` (withInputs
|
|
142
|
+
* aliases have `null`) and declares at least one titled `plot(...)`
|
|
143
|
+
* output. Every drawn binding — named-export sibling AND default — is a
|
|
144
|
+
* potential producer: a same-file sibling can be consumed by the
|
|
145
|
+
* default, and a single-export default can be consumed cross-file
|
|
146
|
+
* (`import baseTrend from "./base-trend.chart"`). The compiler cannot
|
|
147
|
+
* know during a producer file's own compile whether its default will be
|
|
148
|
+
* imported elsewhere, so the default is always baked when it declares
|
|
149
|
+
* titled outputs. This keeps cross-file producers self-describing
|
|
150
|
+
* without an assembler change.
|
|
151
|
+
*
|
|
152
|
+
* Output-free bindings (no titled `plot`) are never touched, so a
|
|
153
|
+
* standalone script that only emits untitled plots stays byte-identical.
|
|
154
|
+
*/
|
|
155
|
+
function collectProducerOutputs(depGraph) {
|
|
156
|
+
const map = new Map();
|
|
157
|
+
for (const dep of depGraph.privateDeps) {
|
|
158
|
+
if (dep.defineCall !== null && dep.outputs.length > 0) {
|
|
159
|
+
map.set(dep.defineCall, dep.outputs);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
for (const drawn of depGraph.drawn) {
|
|
163
|
+
if (drawn.outputs.length > 0)
|
|
164
|
+
map.set(drawn.defineCall, drawn.outputs);
|
|
165
|
+
}
|
|
166
|
+
return map;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Append an `outputs: [{ title, kind }, ...]` property assignment to the
|
|
170
|
+
* `defineIndicator({...})` opts object literal. The analysis pass
|
|
171
|
+
* guarantees a producer binding's `defineCall` carries an object-literal
|
|
172
|
+
* first argument, so the non-object-literal branch is defensive only.
|
|
173
|
+
*/
|
|
174
|
+
function injectOutputsIntoDefineCall(call, outputs) {
|
|
175
|
+
const arg = call.arguments[0];
|
|
176
|
+
/* v8 ignore next 3 */
|
|
177
|
+
if (arg === undefined || !ts.isObjectLiteralExpression(arg)) {
|
|
178
|
+
return call;
|
|
179
|
+
}
|
|
180
|
+
const outputsLiteral = ts.factory.createArrayLiteralExpression(outputs.map((output) => ts.factory.createObjectLiteralExpression([
|
|
181
|
+
ts.factory.createPropertyAssignment("title", ts.factory.createStringLiteral(output.title)),
|
|
182
|
+
ts.factory.createPropertyAssignment("kind", ts.factory.createStringLiteral(output.kind)),
|
|
183
|
+
], false)), false);
|
|
184
|
+
const updatedArg = ts.factory.updateObjectLiteralExpression(arg, [
|
|
185
|
+
...arg.properties,
|
|
186
|
+
ts.factory.createPropertyAssignment("outputs", outputsLiteral),
|
|
187
|
+
]);
|
|
188
|
+
return ts.factory.updateCallExpression(call, call.expression, call.typeArguments, [
|
|
189
|
+
updatedArg,
|
|
190
|
+
...call.arguments.slice(1),
|
|
191
|
+
]);
|
|
192
|
+
}
|
|
193
|
+
function resolveReceiverRoot(receiver) {
|
|
194
|
+
// extractDependencyGraph validates that every `.output(...)` call
|
|
195
|
+
// reaching the rewriter has a bare identifier receiver (or a
|
|
196
|
+
// withInputs-aliased binding name we already collapsed in the
|
|
197
|
+
// graph). The defensive null return is exercised by the
|
|
198
|
+
// "leaves unknown .output() receivers untouched" test case where
|
|
199
|
+
// the receiver type isn't an Identifier (it's a PropertyAccess).
|
|
200
|
+
if (ts.isIdentifier(receiver))
|
|
201
|
+
return receiver;
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=rewriteDependencyAccessors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewriteDependencyAccessors.js","sourceRoot":"","sources":["../../src/transformers/rewriteDependencyAccessors.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,MAAM,YAAY,CAAC;AA0B5B,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,0BAA0B,CACtC,UAAyB,EACzB,QAAkB,EAClB,UAAkB;IAElB,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IACxC,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,KAAK;QAAE,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACzE,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,WAAW;QAAE,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,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MAAM,EACN,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,CAC9C;KACJ,EACD,KAAK,CACR,CACJ,EACD,KAAK,CACR,CAAC;IACF,MAAM,UAAU,GAAG,EAAE,CAAC,OAAO,CAAC,6BAA6B,CAAC,GAAG,EAAE;QAC7D,GAAG,GAAG,CAAC,UAAU;QACjB,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC,SAAS,EAAE,cAAc,CAAC;KACjE,CAAC,CAAC;IACH,OAAO,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE;QAC9E,UAAU;QACV,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;KAC7B,CAAC,CAAC;AACP,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAuB;IAChD,kEAAkE;IAClE,6DAA6D;IAC7D,8DAA8D;IAC9D,wDAAwD;IACxD,iEAAiE;IACjE,iEAAiE;IACjE,IAAI,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC/C,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
package/dist/typesEmit.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ScriptManifest } from "@invinite-org/chartlang-core";
|
|
2
2
|
/**
|
|
3
|
-
* Options accepted by `emitTypes`. `manifest`
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Options accepted by `emitTypes`. `manifest` accepts either a single
|
|
4
|
+
* `ScriptManifest` (single-script files) or an array of manifests for
|
|
5
|
+
* multi-export indicator-composition files. `sourcePath` is reserved so a
|
|
6
|
+
* future generator can embed it into the declarations as a comment when
|
|
7
|
+
* source navigation surfaces land.
|
|
7
8
|
*
|
|
8
9
|
* @since 0.1
|
|
9
10
|
* @example
|
|
@@ -14,15 +15,17 @@ import type { ScriptManifest } from "@invinite-org/chartlang-core";
|
|
|
14
15
|
* void opts;
|
|
15
16
|
*/
|
|
16
17
|
export type EmitTypesOptions = Readonly<{
|
|
17
|
-
manifest: ScriptManifest
|
|
18
|
+
manifest: ScriptManifest | ReadonlyArray<ScriptManifest>;
|
|
18
19
|
sourcePath: string;
|
|
19
20
|
}>;
|
|
20
21
|
/**
|
|
21
|
-
* Generate the
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* Generate the `.d.ts` sibling for a compiled script. Single-script files
|
|
23
|
+
* with no `outputs` / `dependencies` emit the Phase-1 minimal declarations
|
|
24
|
+
* byte-identically so existing snapshot tests stay green. Multi-export
|
|
25
|
+
* files (array input) or single-export files carrying `outputs` /
|
|
26
|
+
* `dependencies` emit per-binding typed declarations — `output<K extends
|
|
27
|
+
* "title1" | "title2">(name: K): Series<number>` overloads + `withInputs`
|
|
28
|
+
* typed against the binding's `inputs` schema.
|
|
26
29
|
*
|
|
27
30
|
* @since 0.1
|
|
28
31
|
* @example
|
|
@@ -31,5 +34,5 @@ export type EmitTypesOptions = Readonly<{
|
|
|
31
34
|
* const fn: typeof emitTypes = emitTypes;
|
|
32
35
|
* void fn;
|
|
33
36
|
*/
|
|
34
|
-
export declare function emitTypes(
|
|
37
|
+
export declare function emitTypes(opts: EmitTypesOptions): string;
|
|
35
38
|
//# sourceMappingURL=typesEmit.d.ts.map
|
package/dist/typesEmit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesEmit.d.ts","sourceRoot":"","sources":["../src/typesEmit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE
|
|
1
|
+
{"version":3,"file":"typesEmit.d.ts","sourceRoot":"","sources":["../src/typesEmit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACpC,QAAQ,EAAE,cAAc,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAUxD"}
|