@invinite-org/chartlang-runtime 1.0.2 → 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 (86) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/README.md +9 -0
  3. package/dist/createScriptRunner.d.ts +55 -4
  4. package/dist/createScriptRunner.d.ts.map +1 -1
  5. package/dist/createScriptRunner.js +103 -35
  6. package/dist/createScriptRunner.js.map +1 -1
  7. package/dist/dep/DepOutputStore.d.ts +92 -0
  8. package/dist/dep/DepOutputStore.d.ts.map +1 -0
  9. package/dist/dep/DepOutputStore.js +0 -0
  10. package/dist/dep/DepOutputStore.js.map +1 -0
  11. package/dist/dep/DepRunner.d.ts +146 -0
  12. package/dist/dep/DepRunner.d.ts.map +1 -0
  13. package/dist/dep/DepRunner.js +243 -0
  14. package/dist/dep/DepRunner.js.map +1 -0
  15. package/dist/dep/depOutput.d.ts +50 -0
  16. package/dist/dep/depOutput.d.ts.map +1 -0
  17. package/dist/dep/depOutput.js +92 -0
  18. package/dist/dep/depOutput.js.map +1 -0
  19. package/dist/dep/emissionFilter.d.ts +70 -0
  20. package/dist/dep/emissionFilter.d.ts.map +1 -0
  21. package/dist/dep/emissionFilter.js +105 -0
  22. package/dist/dep/emissionFilter.js.map +1 -0
  23. package/dist/dep/index.d.ts +8 -0
  24. package/dist/dep/index.d.ts.map +1 -0
  25. package/dist/dep/index.js +7 -0
  26. package/dist/dep/index.js.map +1 -0
  27. package/dist/emit/applyPlotOverride.d.ts +24 -0
  28. package/dist/emit/applyPlotOverride.d.ts.map +1 -0
  29. package/dist/emit/applyPlotOverride.js +48 -0
  30. package/dist/emit/applyPlotOverride.js.map +1 -0
  31. package/dist/emit/hline.d.ts +6 -4
  32. package/dist/emit/hline.d.ts.map +1 -1
  33. package/dist/emit/hline.js +5 -2
  34. package/dist/emit/hline.js.map +1 -1
  35. package/dist/emit/index.d.ts +2 -1
  36. package/dist/emit/index.d.ts.map +1 -1
  37. package/dist/emit/index.js +2 -1
  38. package/dist/emit/index.js.map +1 -1
  39. package/dist/emit/paneResolver.d.ts +52 -11
  40. package/dist/emit/paneResolver.d.ts.map +1 -1
  41. package/dist/emit/paneResolver.js +69 -26
  42. package/dist/emit/paneResolver.js.map +1 -1
  43. package/dist/emit/plot.d.ts.map +1 -1
  44. package/dist/emit/plot.js +2 -1
  45. package/dist/emit/plot.js.map +1 -1
  46. package/dist/execution/dispose.d.ts.map +1 -1
  47. package/dist/execution/dispose.js +7 -0
  48. package/dist/execution/dispose.js.map +1 -1
  49. package/dist/execution/onBarClose.d.ts +9 -13
  50. package/dist/execution/onBarClose.d.ts.map +1 -1
  51. package/dist/execution/onBarClose.js +28 -59
  52. package/dist/execution/onBarClose.js.map +1 -1
  53. package/dist/execution/onBarTick.d.ts +4 -10
  54. package/dist/execution/onBarTick.d.ts.map +1 -1
  55. package/dist/execution/onBarTick.js +24 -57
  56. package/dist/execution/onBarTick.js.map +1 -1
  57. package/dist/execution/runComputeStep.d.ts +68 -0
  58. package/dist/execution/runComputeStep.d.ts.map +1 -0
  59. package/dist/execution/runComputeStep.js +96 -0
  60. package/dist/execution/runComputeStep.js.map +1 -0
  61. package/dist/index.d.ts +3 -1
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +2 -1
  64. package/dist/index.js.map +1 -1
  65. package/dist/internal.d.ts +12 -0
  66. package/dist/internal.d.ts.map +1 -0
  67. package/dist/internal.js +14 -0
  68. package/dist/internal.js.map +1 -0
  69. package/dist/persistentStateStore.runtime.d.ts +18 -4
  70. package/dist/persistentStateStore.runtime.d.ts.map +1 -1
  71. package/dist/persistentStateStore.runtime.js +111 -18
  72. package/dist/persistentStateStore.runtime.js.map +1 -1
  73. package/dist/persistentStateStore.validate.d.ts +11 -1
  74. package/dist/persistentStateStore.validate.d.ts.map +1 -1
  75. package/dist/persistentStateStore.validate.js +32 -3
  76. package/dist/persistentStateStore.validate.js.map +1 -1
  77. package/dist/runtimeContext.d.ts +62 -4
  78. package/dist/runtimeContext.d.ts.map +1 -1
  79. package/dist/runtimeContext.js.map +1 -1
  80. package/dist/state/stateNamespace.d.ts.map +1 -1
  81. package/dist/state/stateNamespace.js +13 -2
  82. package/dist/state/stateNamespace.js.map +1 -1
  83. package/dist/stateStore.d.ts +6 -3
  84. package/dist/stateStore.d.ts.map +1 -1
  85. package/dist/stateStore.js.map +1 -1
  86. package/package.json +7 -3
@@ -0,0 +1,146 @@
1
+ import type { Capabilities } from "@invinite-org/chartlang-adapter-kit";
2
+ import type { Bar, CompiledScriptObject } from "@invinite-org/chartlang-core";
3
+ import type { RunnerState } from "../createScriptRunner.js";
4
+ import type { StreamState } from "../streamState.js";
5
+ import type { EventKind } from "../views/index.js";
6
+ import type { DepOutputStore } from "./DepOutputStore.js";
7
+ /**
8
+ * One mounted private dep — a `const X = defineIndicator(...)` binding
9
+ * that another script in the same compiled bundle references via
10
+ * `X.output("title")`. Owns its own `RunnerState`; shares the parent's
11
+ * `mainStream` + `secondaryStreams`. Plot emissions are dropped from
12
+ * the parent's queue and captured into the shared
13
+ * {@link DepOutputStore}.
14
+ *
15
+ * @since 0.7
16
+ * @stable
17
+ * @example
18
+ * // const dep = createDepRunner({ compiled, localId: "fast", ... });
19
+ * // await runDepStep(dep, parent, rawBar, "close", false);
20
+ * const x: number = 1;
21
+ * void x;
22
+ */
23
+ export type DepRunner = Readonly<{
24
+ readonly kind: "dep";
25
+ readonly localId: string;
26
+ readonly slotIdPrefix: string;
27
+ readonly declaredOutputs: ReadonlyArray<string>;
28
+ readonly state: RunnerState;
29
+ }>;
30
+ /**
31
+ * One mounted drawn sibling — a `export const X = defineIndicator(...)`
32
+ * binding whose emissions ARE forwarded to the parent's queue, with
33
+ * slot ids prefixed by `export:<exportName>/`. Siblings can also expose
34
+ * outputs consumed by the primary or by other siblings.
35
+ *
36
+ * @since 0.7
37
+ * @stable
38
+ * @example
39
+ * // const sib = createSiblingRunner({ compiled, exportName: "slow", ... });
40
+ * // await runSiblingStep(sib, parent, rawBar, "close", false);
41
+ * const x: number = 1;
42
+ * void x;
43
+ */
44
+ export type SiblingRunner = Readonly<{
45
+ readonly kind: "sibling";
46
+ readonly exportName: string;
47
+ readonly slotIdPrefix: string;
48
+ readonly declaredOutputs: ReadonlyArray<string>;
49
+ readonly state: RunnerState;
50
+ }>;
51
+ /**
52
+ * Constructor arguments for {@link createDepRunner} /
53
+ * {@link createSiblingRunner}.
54
+ *
55
+ * `mainStream` + `secondaryStreams` are SHARED with the parent runner
56
+ * (same OHLCV history); `depOutputStore` is also shared so every
57
+ * sibling + dep + primary read from the same store. `inputOverrides`
58
+ * is the merged effective-inputs record the compiler attached to the
59
+ * dep's `DependencyDeclaration`.
60
+ *
61
+ * @since 0.7
62
+ * @stable
63
+ * @example
64
+ * // const args: CreateDepRunnerArgs = {
65
+ * // compiled, localId: "x",
66
+ * // parentCapabilities, mainStream, secondaryStreams,
67
+ * // depOutputStore, inputOverrides: {}, now: Date.now,
68
+ * // };
69
+ * const x: number = 1;
70
+ * void x;
71
+ */
72
+ export type CreateDepRunnerArgs = Readonly<{
73
+ readonly compiled: CompiledScriptObject;
74
+ readonly parentCapabilities: Capabilities;
75
+ readonly mainStream: StreamState;
76
+ readonly secondaryStreams: Map<string, StreamState>;
77
+ readonly depOutputStore: DepOutputStore;
78
+ readonly inputOverrides: Readonly<Record<string, unknown>>;
79
+ readonly now: () => number;
80
+ }>;
81
+ /**
82
+ * Construct a {@link DepRunner} for one private dep entry of a
83
+ * `CompiledScriptBundle`. The runner shares the parent's `mainStream`
84
+ * + `secondaryStreams`, owns a fresh `inMemoryStateStore`, and feeds
85
+ * its plot emissions into the shared `DepOutputStore`.
86
+ *
87
+ * @since 0.7
88
+ * @stable
89
+ * @example
90
+ * // const dep = createDepRunner({ compiled, localId: "fast",
91
+ * // parentCapabilities, mainStream, secondaryStreams,
92
+ * // depOutputStore, inputOverrides: { length: 20 }, now: Date.now });
93
+ * const x: number = 1;
94
+ * void x;
95
+ */
96
+ export declare function createDepRunner(args: CreateDepRunnerArgs & {
97
+ readonly localId: string;
98
+ }): DepRunner;
99
+ /**
100
+ * Construct a {@link SiblingRunner} for one drawn named-export entry of
101
+ * a `CompiledScriptBundle`. Shares streams + store with the parent;
102
+ * emissions forward to the parent with `export:<exportName>/` slot-id
103
+ * prefixes.
104
+ *
105
+ * @since 0.7
106
+ * @stable
107
+ * @example
108
+ * // const sib = createSiblingRunner({ compiled, exportName: "slow", ... });
109
+ * const x: number = 1;
110
+ * void x;
111
+ */
112
+ export declare function createSiblingRunner(args: CreateDepRunnerArgs & {
113
+ readonly exportName: string;
114
+ }): SiblingRunner;
115
+ /**
116
+ * Drive one bar of execution for a {@link DepRunner}. Runs the dep's
117
+ * `compute`, captures its titled-plot output into the shared
118
+ * `DepOutputStore` via {@link applyDepEmissionPolicy}, namespaces
119
+ * diagnostics with `dep:<localId>/`, and on halt sets
120
+ * `parentState.depErroredThisBar = true` so the parent's primary
121
+ * step drops its emissions for the bar (per task spec §6).
122
+ *
123
+ * @since 0.7
124
+ * @stable
125
+ * @example
126
+ * // await runDepStep(dep, parent, rawBar, "close", false);
127
+ * const x: number = 1;
128
+ * void x;
129
+ */
130
+ export declare function runDepStep(dep: DepRunner, parentState: RunnerState, rawBar: Bar, eventKind: EventKind, isTick: boolean): Promise<void>;
131
+ /**
132
+ * Drive one bar of execution for a {@link SiblingRunner}. Same shape
133
+ * as {@link runDepStep} but the sibling's emissions are forwarded to
134
+ * the parent with `export:<exportName>/` slot-id prefixes, and a
135
+ * sibling halt does NOT clear the primary's emissions — only the
136
+ * sibling's own bar emissions are lost.
137
+ *
138
+ * @since 0.7
139
+ * @stable
140
+ * @example
141
+ * // await runSiblingStep(sibling, parent, rawBar, "close", false);
142
+ * const x: number = 1;
143
+ * void x;
144
+ */
145
+ export declare function runSiblingStep(sibling: SiblingRunner, parentState: RunnerState, rawBar: Bar, eventKind: EventKind, isTick: boolean): Promise<void>;
146
+ //# sourceMappingURL=DepRunner.d.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,CAAC;IACxC,QAAQ,CAAC,kBAAkB,EAAE,YAAY,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpD,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;CAC9B,CAAC,CAAC;AA6FH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC3B,IAAI,EAAE,mBAAmB,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACzD,SAAS,CASX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,mBAAmB,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC5D,aAAa,CASf;AAuCD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAC5B,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,GAAG,EACX,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,OAAO,GAChB,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAChC,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,GAAG,EACX,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,OAAO,GAChB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
@@ -0,0 +1,243 @@
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 { pushDiagnostic } from "../emit/emissionsQueue.js";
4
+ import { resolveDefaultPane, resolveScriptPane } from "../emit/paneResolver.js";
5
+ import { resetBarEmissions, runComputeBody } from "../execution/runComputeStep.js";
6
+ import { resolveInputs } from "../inputs/resolveInputs.js";
7
+ import { inMemoryStateStore } from "../stateStore.js";
8
+ import { createRuntimeViews } from "../views/index.js";
9
+ import { applyDepEmissionPolicy, } from "./emissionFilter.js";
10
+ function freshEmissions(barIndex) {
11
+ return {
12
+ plots: [],
13
+ drawings: [],
14
+ alerts: [],
15
+ alertConditions: [],
16
+ logs: [],
17
+ diagnostics: [],
18
+ fromBar: barIndex,
19
+ toBar: barIndex,
20
+ };
21
+ }
22
+ function buildSubRunnerState(args, slotIdPrefix, isDep) {
23
+ const stateStore = inMemoryStateStore();
24
+ const emissions = freshEmissions(0);
25
+ const alertConditions = new Map((args.compiled.manifest.alertConditions ?? []).map((c) => [c.id, c]));
26
+ const state = {
27
+ manifest: args.compiled.manifest,
28
+ compute: args.compiled.compute,
29
+ capabilities: args.parentCapabilities,
30
+ stateStore,
31
+ persistenceIntervalMs: Number.POSITIVE_INFINITY,
32
+ now: args.now,
33
+ mainStream: args.mainStream,
34
+ runtimeContext: {
35
+ stream: args.mainStream,
36
+ stateStore,
37
+ lastPersistTime: 0,
38
+ capabilities: args.parentCapabilities,
39
+ emissions,
40
+ barIndex: () => state.barIndex,
41
+ isTick: false,
42
+ drawingSlots: new Map(),
43
+ drawingSubIdCounters: new Map(),
44
+ drawingBucketCounters: {
45
+ lines: 0,
46
+ labels: 0,
47
+ boxes: 0,
48
+ polylines: 0,
49
+ other: 0,
50
+ },
51
+ scriptMaxDrawings: args.compiled.manifest.maxDrawings ?? null,
52
+ stateSlots: new Map(),
53
+ secondaryStreams: args.secondaryStreams,
54
+ requestSecurityBars: new Map(),
55
+ requestSecurityAlignments: new Map(),
56
+ requestSecurityAscendingBars: new Map(),
57
+ requestLowerTfViews: new Map(),
58
+ diagnosedRequestKeys: new Set(),
59
+ alertConditions,
60
+ diagnosedAlertConditionKeys: new Set(),
61
+ logBudget: 0,
62
+ logBudgetExceededDiagnosed: false,
63
+ resolvedInputs: Object.freeze({}),
64
+ defaultPane: resolveDefaultPane(args.compiled.manifest),
65
+ scriptPane: resolveScriptPane(args.compiled.manifest),
66
+ // Overrides target the primary script's slots only in v1;
67
+ // dep-output plots are not host-overridable.
68
+ plotOverrides: Object.freeze({}),
69
+ diagnosedInputKeys: new Set(),
70
+ views: createRuntimeViews(),
71
+ slotIdPrefix,
72
+ isDep,
73
+ depOutputStore: args.depOutputStore,
74
+ },
75
+ emissions,
76
+ depRunners: [],
77
+ siblingRunners: [],
78
+ depOutputStore: args.depOutputStore,
79
+ depErroredThisBar: false,
80
+ barIndex: 0,
81
+ };
82
+ state.runtimeContext.resolvedInputs = resolveInputs(args.compiled.manifest, args.inputOverrides, state.runtimeContext);
83
+ return state;
84
+ }
85
+ function declaredOutputTitles(compiled) {
86
+ return (compiled.manifest.outputs ?? []).map((o) => o.title);
87
+ }
88
+ /**
89
+ * Construct a {@link DepRunner} for one private dep entry of a
90
+ * `CompiledScriptBundle`. The runner shares the parent's `mainStream`
91
+ * + `secondaryStreams`, owns a fresh `inMemoryStateStore`, and feeds
92
+ * its plot emissions into the shared `DepOutputStore`.
93
+ *
94
+ * @since 0.7
95
+ * @stable
96
+ * @example
97
+ * // const dep = createDepRunner({ compiled, localId: "fast",
98
+ * // parentCapabilities, mainStream, secondaryStreams,
99
+ * // depOutputStore, inputOverrides: { length: 20 }, now: Date.now });
100
+ * const x: number = 1;
101
+ * void x;
102
+ */
103
+ export function createDepRunner(args) {
104
+ const slotIdPrefix = `dep:${args.localId}/`;
105
+ return Object.freeze({
106
+ kind: "dep",
107
+ localId: args.localId,
108
+ slotIdPrefix,
109
+ declaredOutputs: declaredOutputTitles(args.compiled),
110
+ state: buildSubRunnerState(args, slotIdPrefix, true),
111
+ });
112
+ }
113
+ /**
114
+ * Construct a {@link SiblingRunner} for one drawn named-export entry of
115
+ * a `CompiledScriptBundle`. Shares streams + store with the parent;
116
+ * emissions forward to the parent with `export:<exportName>/` slot-id
117
+ * prefixes.
118
+ *
119
+ * @since 0.7
120
+ * @stable
121
+ * @example
122
+ * // const sib = createSiblingRunner({ compiled, exportName: "slow", ... });
123
+ * const x: number = 1;
124
+ * void x;
125
+ */
126
+ export function createSiblingRunner(args) {
127
+ const slotIdPrefix = `export:${args.exportName}/`;
128
+ return Object.freeze({
129
+ kind: "sibling",
130
+ exportName: args.exportName,
131
+ slotIdPrefix,
132
+ declaredOutputs: declaredOutputTitles(args.compiled),
133
+ state: buildSubRunnerState(args, slotIdPrefix, false),
134
+ });
135
+ }
136
+ function depRunnerLike(dep) {
137
+ return {
138
+ kind: "dep",
139
+ localId: dep.localId,
140
+ slotIdPrefix: dep.slotIdPrefix,
141
+ declaredOutputs: dep.declaredOutputs,
142
+ emissions: dep.state.emissions,
143
+ };
144
+ }
145
+ function siblingRunnerLike(sib) {
146
+ return {
147
+ kind: "sibling",
148
+ exportName: sib.exportName,
149
+ slotIdPrefix: sib.slotIdPrefix,
150
+ declaredOutputs: sib.declaredOutputs,
151
+ emissions: sib.state.emissions,
152
+ };
153
+ }
154
+ async function executeSubStep(state, eventKind, isTick) {
155
+ resetBarEmissions(state);
156
+ try {
157
+ const outcome = await runComputeBody({ state, eventKind, isTick });
158
+ return outcome.kind === "halt"
159
+ ? { halted: true, message: outcome.message }
160
+ : { halted: false, message: "" };
161
+ }
162
+ catch (err) {
163
+ const message = err instanceof Error ? err.message : String(err);
164
+ return { halted: true, message };
165
+ }
166
+ }
167
+ /**
168
+ * Drive one bar of execution for a {@link DepRunner}. Runs the dep's
169
+ * `compute`, captures its titled-plot output into the shared
170
+ * `DepOutputStore` via {@link applyDepEmissionPolicy}, namespaces
171
+ * diagnostics with `dep:<localId>/`, and on halt sets
172
+ * `parentState.depErroredThisBar = true` so the parent's primary
173
+ * step drops its emissions for the bar (per task spec §6).
174
+ *
175
+ * @since 0.7
176
+ * @stable
177
+ * @example
178
+ * // await runDepStep(dep, parent, rawBar, "close", false);
179
+ * const x: number = 1;
180
+ * void x;
181
+ */
182
+ export async function runDepStep(dep, parentState, rawBar, eventKind, isTick) {
183
+ if (parentState.depOutputStore === null) {
184
+ throw new Error("runDepStep called on a runner with no dep output store");
185
+ }
186
+ void rawBar;
187
+ const result = await executeSubStep(dep.state, eventKind, isTick);
188
+ if (result.halted) {
189
+ // Use an empty slot id so the filter's prefix call produces the
190
+ // runner's slotIdPrefix (`dep:<localId>/`) — preserves the
191
+ // distinguished slotId in the parent's diagnostic queue.
192
+ pushDiagnostic(dep.state.emissions, {
193
+ kind: "diagnostic",
194
+ severity: "error",
195
+ code: "dep-error",
196
+ message: result.message,
197
+ slotId: "",
198
+ bar: dep.state.barIndex,
199
+ });
200
+ parentState.depErroredThisBar = true;
201
+ }
202
+ if (!isTick) {
203
+ dep.state.barIndex += 1;
204
+ }
205
+ applyDepEmissionPolicy(depRunnerLike(dep), parentState.emissions, parentState.depOutputStore);
206
+ }
207
+ /**
208
+ * Drive one bar of execution for a {@link SiblingRunner}. Same shape
209
+ * as {@link runDepStep} but the sibling's emissions are forwarded to
210
+ * the parent with `export:<exportName>/` slot-id prefixes, and a
211
+ * sibling halt does NOT clear the primary's emissions — only the
212
+ * sibling's own bar emissions are lost.
213
+ *
214
+ * @since 0.7
215
+ * @stable
216
+ * @example
217
+ * // await runSiblingStep(sibling, parent, rawBar, "close", false);
218
+ * const x: number = 1;
219
+ * void x;
220
+ */
221
+ export async function runSiblingStep(sibling, parentState, rawBar, eventKind, isTick) {
222
+ if (parentState.depOutputStore === null) {
223
+ throw new Error("runSiblingStep called on a runner with no dep output store");
224
+ }
225
+ void rawBar;
226
+ const result = await executeSubStep(sibling.state, eventKind, isTick);
227
+ if (result.halted) {
228
+ pushDiagnostic(sibling.state.emissions, {
229
+ kind: "diagnostic",
230
+ severity: "error",
231
+ code: "dep-error",
232
+ message: result.message,
233
+ slotId: "",
234
+ bar: sibling.state.barIndex,
235
+ });
236
+ // sibling halt does NOT set parentState.depErroredThisBar.
237
+ }
238
+ if (!isTick) {
239
+ sibling.state.barIndex += 1;
240
+ }
241
+ applyDepEmissionPolicy(siblingRunnerLike(sibling), parentState.emissions, parentState.depOutputStore);
242
+ }
243
+ //# sourceMappingURL=DepRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DepRunner.js","sourceRoot":"","sources":["../../src/dep/DepRunner.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAM/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAGH,sBAAsB,GACzB,MAAM,qBAAqB,CAAC;AA+E7B,SAAS,cAAc,CAAC,QAAgB;IACpC,OAAO;QACH,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,eAAe,EAAE,EAAE;QACnB,IAAI,EAAE,EAAE;QACR,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,QAAQ;QACjB,KAAK,EAAE,QAAQ;KAClB,CAAC;AACN,CAAC;AAED,SAAS,mBAAmB,CACxB,IAAyB,EACzB,YAAoB,EACpB,KAAc;IAEd,MAAM,UAAU,GAAG,kBAAkB,EAAE,CAAC;IACxC,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,eAAe,GAAG,IAAI,GAAG,CAC3B,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,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;QACV,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,sBAAsB,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;AAClG,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,OAAsB,EACtB,WAAwB,EACxB,MAAW,EACX,SAAoB,EACpB,MAAe;IAEf,IAAI,WAAW,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,CAAC;IACD,KAAK,MAAM,CAAC;IACZ,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACtE,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAChB,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE;YACpC,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,MAAM,EAAE,EAAE;YACV,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ;SAC9B,CAAC,CAAC;QACH,2DAA2D;IAC/D,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC;IAChC,CAAC;IACD,sBAAsB,CAClB,iBAAiB,CAAC,OAAO,CAAC,EAC1B,WAAW,CAAC,SAAS,EACrB,WAAW,CAAC,cAAc,CAC7B,CAAC;AACN,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { Series } from "@invinite-org/chartlang-core";
2
+ /**
3
+ * The well-known property on `globalThis` the compiler-emitted bundle's
4
+ * inline shim looks for. Set once by {@link installDepOutputGlobal}.
5
+ *
6
+ * @since 0.7
7
+ * @stable
8
+ * @example
9
+ * // import { DEP_OUTPUT_GLOBAL_KEY } from "@invinite-org/chartlang-runtime/internal";
10
+ * // const fn = (globalThis as Record<string, unknown>)[DEP_OUTPUT_GLOBAL_KEY];
11
+ * // void fn;
12
+ */
13
+ export declare const DEP_OUTPUT_GLOBAL_KEY: "__chartlang_depOutput";
14
+ /**
15
+ * Runtime helper invoked by the compiler-emitted bundle in place of
16
+ * every consumer-side `<binding>.output("title")` call. Tasks 2 + 3
17
+ * rewrite each call site to
18
+ * `__chartlang_depOutput(slotId, localId, title)`; the runtime returns
19
+ * the producer's stable `Series<number>` view from the active runner's
20
+ * `DepOutputStore`.
21
+ *
22
+ * The helper is exposed via the `@invinite-org/chartlang-runtime/internal`
23
+ * subpath only — user scripts can't import it. {@link installDepOutputGlobal}
24
+ * also assigns it to `globalThis.__chartlang_depOutput` so the bundle's
25
+ * inline shim picks it up automatically.
26
+ *
27
+ * @since 0.7
28
+ * @stable
29
+ * @example
30
+ * // import { __chartlang_depOutput } from "@invinite-org/chartlang-runtime/internal";
31
+ * // const line = __chartlang_depOutput("demo.chart.ts:5:13#0", "fast", "line");
32
+ * // void line;
33
+ */
34
+ export declare function __chartlang_depOutput(slotId: string, localId: string, title: string): Series<number>;
35
+ /**
36
+ * Install {@link __chartlang_depOutput} on `globalThis` under the
37
+ * {@link DEP_OUTPUT_GLOBAL_KEY} property. Compiler-emitted bundles
38
+ * reference the global via an inline shim; the runtime calls
39
+ * `installDepOutputGlobal` from `createScriptRunner` when mounting a
40
+ * `CompiledScriptBundle`. The assignment is idempotent — subsequent
41
+ * calls leave the existing value untouched.
42
+ *
43
+ * @since 0.7
44
+ * @stable
45
+ * @example
46
+ * // import { installDepOutputGlobal } from "@invinite-org/chartlang-runtime/internal";
47
+ * // installDepOutputGlobal();
48
+ */
49
+ export declare function installDepOutputGlobal(): void;
50
+ //# sourceMappingURL=depOutput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depOutput.d.ts","sourceRoot":"","sources":["../../src/dep/depOutput.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAO3D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,EAAG,uBAAgC,CAAC;AAatE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,CAAC,CAsBhB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAK7C"}
@@ -0,0 +1,92 @@
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 { pushDiagnostic } from "../emit/emissionsQueue.js";
4
+ import { Float64RingBuffer } from "../ringBuffer.js";
5
+ import { ACTIVE_RUNTIME_CONTEXT } from "../runtimeContext.js";
6
+ import { makeSeriesView } from "../seriesView.js";
7
+ /**
8
+ * The well-known property on `globalThis` the compiler-emitted bundle's
9
+ * inline shim looks for. Set once by {@link installDepOutputGlobal}.
10
+ *
11
+ * @since 0.7
12
+ * @stable
13
+ * @example
14
+ * // import { DEP_OUTPUT_GLOBAL_KEY } from "@invinite-org/chartlang-runtime/internal";
15
+ * // const fn = (globalThis as Record<string, unknown>)[DEP_OUTPUT_GLOBAL_KEY];
16
+ * // void fn;
17
+ */
18
+ export const DEP_OUTPUT_GLOBAL_KEY = "__chartlang_depOutput";
19
+ const OUTSIDE_CTX_MESSAGE = "__chartlang_depOutput called outside an active script step";
20
+ const NO_STORE_MESSAGE = "__chartlang_depOutput called on a runner with no dep output store";
21
+ /**
22
+ * Sentinel `Series<number>` whose every read returns `NaN`. Returned by
23
+ * the helper when the consumer asks for an output that the producer
24
+ * never declared (compile-time error from Task 2; runtime sanity
25
+ * fallback). The buffer never receives a write, so all reads stay NaN.
26
+ */
27
+ const NAN_SERIES = makeSeriesView(new Float64RingBuffer(1));
28
+ /**
29
+ * Runtime helper invoked by the compiler-emitted bundle in place of
30
+ * every consumer-side `<binding>.output("title")` call. Tasks 2 + 3
31
+ * rewrite each call site to
32
+ * `__chartlang_depOutput(slotId, localId, title)`; the runtime returns
33
+ * the producer's stable `Series<number>` view from the active runner's
34
+ * `DepOutputStore`.
35
+ *
36
+ * The helper is exposed via the `@invinite-org/chartlang-runtime/internal`
37
+ * subpath only — user scripts can't import it. {@link installDepOutputGlobal}
38
+ * also assigns it to `globalThis.__chartlang_depOutput` so the bundle's
39
+ * inline shim picks it up automatically.
40
+ *
41
+ * @since 0.7
42
+ * @stable
43
+ * @example
44
+ * // import { __chartlang_depOutput } from "@invinite-org/chartlang-runtime/internal";
45
+ * // const line = __chartlang_depOutput("demo.chart.ts:5:13#0", "fast", "line");
46
+ * // void line;
47
+ */
48
+ export function __chartlang_depOutput(slotId, localId, title) {
49
+ const ctx = ACTIVE_RUNTIME_CONTEXT.current;
50
+ if (ctx === null) {
51
+ throw new Error(OUTSIDE_CTX_MESSAGE);
52
+ }
53
+ const store = ctx.depOutputStore;
54
+ if (store === undefined || store === null) {
55
+ throw new Error(NO_STORE_MESSAGE);
56
+ }
57
+ try {
58
+ return store.read(localId, title);
59
+ }
60
+ catch {
61
+ pushDiagnostic(ctx.emissions, {
62
+ kind: "diagnostic",
63
+ severity: "error",
64
+ code: "dep-unknown-output",
65
+ message: `dep "${localId}" did not declare output "${title}"`,
66
+ slotId,
67
+ bar: ctx.barIndex(),
68
+ });
69
+ return NAN_SERIES;
70
+ }
71
+ }
72
+ /**
73
+ * Install {@link __chartlang_depOutput} on `globalThis` under the
74
+ * {@link DEP_OUTPUT_GLOBAL_KEY} property. Compiler-emitted bundles
75
+ * reference the global via an inline shim; the runtime calls
76
+ * `installDepOutputGlobal` from `createScriptRunner` when mounting a
77
+ * `CompiledScriptBundle`. The assignment is idempotent — subsequent
78
+ * calls leave the existing value untouched.
79
+ *
80
+ * @since 0.7
81
+ * @stable
82
+ * @example
83
+ * // import { installDepOutputGlobal } from "@invinite-org/chartlang-runtime/internal";
84
+ * // installDepOutputGlobal();
85
+ */
86
+ export function installDepOutputGlobal() {
87
+ const holder = globalThis;
88
+ if (holder[DEP_OUTPUT_GLOBAL_KEY] === undefined) {
89
+ holder[DEP_OUTPUT_GLOBAL_KEY] = __chartlang_depOutput;
90
+ }
91
+ }
92
+ //# sourceMappingURL=depOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depOutput.js","sourceRoot":"","sources":["../../src/dep/depOutput.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAgC,CAAC;AAEtE,MAAM,mBAAmB,GAAG,4DAA4D,CAAC;AACzF,MAAM,gBAAgB,GAAG,mEAAmE,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,UAAU,GAAmB,cAAc,CAAS,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CACjC,MAAc,EACd,OAAe,EACf,KAAa;IAEb,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC;IAC3C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,cAAc,CAAC;IACjC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACL,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE;YAC1B,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,QAAQ,OAAO,6BAA6B,KAAK,GAAG;YAC7D,MAAM;YACN,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;SACtB,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACtB,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB;IAClC,MAAM,MAAM,GAAG,UAAqC,CAAC;IACrD,IAAI,MAAM,CAAC,qBAAqB,CAAC,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;IAC1D,CAAC;AACL,CAAC"}
@@ -0,0 +1,70 @@
1
+ import type { MutableRunnerEmissions } from "../runtimeContext.js";
2
+ import type { DepOutputStore } from "./DepOutputStore.js";
3
+ /**
4
+ * View of a `DepRunner` the emission filter reads. Carries the
5
+ * dep-specific slot-id prefix, the declared output titles (for NaN
6
+ * padding), and the runner's own emission queue.
7
+ *
8
+ * @since 0.7
9
+ * @stable
10
+ * @example
11
+ * const v: DepRunnerLike = {
12
+ * kind: "dep",
13
+ * localId: "fastTrend",
14
+ * slotIdPrefix: "dep:fastTrend/",
15
+ * declaredOutputs: ["line"],
16
+ * emissions: { plots: [], drawings: [], alerts: [], alertConditions: [], logs: [], diagnostics: [], fromBar: 0, toBar: 0 },
17
+ * };
18
+ * void v;
19
+ */
20
+ export type DepRunnerLike = Readonly<{
21
+ readonly kind: "dep";
22
+ readonly localId: string;
23
+ readonly slotIdPrefix: string;
24
+ readonly declaredOutputs: ReadonlyArray<string>;
25
+ readonly emissions: MutableRunnerEmissions;
26
+ }>;
27
+ /**
28
+ * View of a `SiblingRunner` the emission filter reads. Same shape as
29
+ * `DepRunnerLike` but keyed by the sibling's exported binding name and
30
+ * with a different slot-id prefix.
31
+ *
32
+ * @since 0.7
33
+ * @stable
34
+ * @example
35
+ * const v: SiblingRunnerLike = {
36
+ * kind: "sibling",
37
+ * exportName: "slowTrend",
38
+ * slotIdPrefix: "export:slowTrend/",
39
+ * declaredOutputs: ["line"],
40
+ * emissions: { plots: [], drawings: [], alerts: [], alertConditions: [], logs: [], diagnostics: [], fromBar: 0, toBar: 0 },
41
+ * };
42
+ * void v;
43
+ */
44
+ export type SiblingRunnerLike = Readonly<{
45
+ readonly kind: "sibling";
46
+ readonly exportName: string;
47
+ readonly slotIdPrefix: string;
48
+ readonly declaredOutputs: ReadonlyArray<string>;
49
+ readonly emissions: MutableRunnerEmissions;
50
+ }>;
51
+ /**
52
+ * Apply the dep / sibling emission policy. Captures titled plots into
53
+ * the shared {@link DepOutputStore}, drops private-dep visuals, prefixes
54
+ * sibling emissions with `export:<exportName>/`, and namespaces every
55
+ * diagnostic with the runner's slot-id prefix. Always resets the
56
+ * runner's queue at the end so the next bar starts clean.
57
+ *
58
+ * Per-bar NaN padding: for every declared output that the runner did
59
+ * NOT call `plot(value, { title: "<output>" })` on this bar, the
60
+ * filter appends a NaN to the store so the consumer's series stays
61
+ * continuous (NaN gaps where the producer skipped).
62
+ *
63
+ * @since 0.7
64
+ * @stable
65
+ * @example
66
+ * // import { applyDepEmissionPolicy } from "@invinite-org/chartlang-runtime";
67
+ * // applyDepEmissionPolicy(dep, parentEmissions, depOutputStore);
68
+ */
69
+ export declare function applyDepEmissionPolicy(runner: DepRunnerLike | SiblingRunnerLike, parentEmissions: MutableRunnerEmissions, depOutputStore: DepOutputStore): void;
70
+ //# sourceMappingURL=emissionFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emissionFilter.d.ts","sourceRoot":"","sources":["../../src/dep/emissionFilter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAChD,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;CAC9C,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAChD,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;CAC9C,CAAC,CAAC;AAuBH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,aAAa,GAAG,iBAAiB,EACzC,eAAe,EAAE,sBAAsB,EACvC,cAAc,EAAE,cAAc,GAC/B,IAAI,CAwEN"}