@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
|
@@ -0,0 +1,256 @@
|
|
|
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 { createHash } from "node:crypto";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { dirname, isAbsolute, relative, resolve as resolvePath } from "node:path";
|
|
6
|
+
import ts from "typescript";
|
|
7
|
+
const LRU_LIMIT = 256;
|
|
8
|
+
/**
|
|
9
|
+
* Build a Promise-cached, cycle-safe cross-file `.chart.ts` resolver. Each
|
|
10
|
+
* unique absolute path is compiled at most once per resolver instance.
|
|
11
|
+
* Cycles (`A` imports `B` imports `A`) surface as `null` so the calling
|
|
12
|
+
* compile pass can raise `dep-cycle` at the consumer's call site.
|
|
13
|
+
*
|
|
14
|
+
* The resolver delegates the actual compile to a caller-supplied
|
|
15
|
+
* {@link CompileProducerCallback} so this module stays free of the
|
|
16
|
+
* compile pipeline's import graph — testable in isolation.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.7
|
|
19
|
+
* @stable
|
|
20
|
+
* @example
|
|
21
|
+
* // const resolve = createProducerResolver({ rootDir: cwd }, compileFn);
|
|
22
|
+
* // const producer = await resolve("./base.chart", "consumer.chart.ts");
|
|
23
|
+
* const fn: typeof createProducerResolver = createProducerResolver;
|
|
24
|
+
* void fn;
|
|
25
|
+
*/
|
|
26
|
+
export function createProducerResolver(opts, compileProducer) {
|
|
27
|
+
const rootAbsolute = isAbsolute(opts.rootDir)
|
|
28
|
+
? opts.rootDir
|
|
29
|
+
: resolvePath(process.cwd(), opts.rootDir);
|
|
30
|
+
const cache = new Map();
|
|
31
|
+
const insertionOrder = [];
|
|
32
|
+
// Track per-resolve-chain ancestry. Each compileProducer for file X
|
|
33
|
+
// adds X to its descendants' chains via a per-promise registry so a
|
|
34
|
+
// genuine cycle (X → Y → X) is detected without false-positiving on
|
|
35
|
+
// concurrent sibling compiles (X → Y and X → Z, sharing producer Y).
|
|
36
|
+
const ancestryByAbsolute = new Map();
|
|
37
|
+
function resolveCrossFileProducer(importPath, fromSourcePath) {
|
|
38
|
+
const absolute = resolveImportPath(importPath, fromSourcePath, rootAbsolute);
|
|
39
|
+
if (absolute === null)
|
|
40
|
+
return Promise.resolve(null);
|
|
41
|
+
// Cycle: the file we'd compile is already an ancestor of the
|
|
42
|
+
// file currently driving the resolve. Returns null so the
|
|
43
|
+
// caller surfaces `dep-cycle` at the call site.
|
|
44
|
+
const fromAbsolute = isAbsolute(fromSourcePath)
|
|
45
|
+
? fromSourcePath
|
|
46
|
+
: resolvePath(rootAbsolute, fromSourcePath);
|
|
47
|
+
const ancestors = ancestryByAbsolute.get(fromAbsolute);
|
|
48
|
+
if (ancestors !== undefined && (ancestors.has(absolute) || fromAbsolute === absolute)) {
|
|
49
|
+
return Promise.resolve(null);
|
|
50
|
+
}
|
|
51
|
+
const cached = cache.get(absolute);
|
|
52
|
+
if (cached !== undefined)
|
|
53
|
+
return cached;
|
|
54
|
+
const childAncestry = new Set(ancestors ?? []);
|
|
55
|
+
childAncestry.add(fromAbsolute);
|
|
56
|
+
ancestryByAbsolute.set(absolute, childAncestry);
|
|
57
|
+
const pending = (async () => {
|
|
58
|
+
try {
|
|
59
|
+
let source;
|
|
60
|
+
try {
|
|
61
|
+
source = await readFile(absolute, "utf8");
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
// Hand the absolute path to `compileProducer` so the
|
|
67
|
+
// recursive `compile` invocation can resolve nested
|
|
68
|
+
// cross-file imports from the producer's real location
|
|
69
|
+
// without going through the (process-cwd-dependent)
|
|
70
|
+
// posix-relative form. The compiler's callsite-id slot
|
|
71
|
+
// ids still derive from this path verbatim.
|
|
72
|
+
const artefacts = await compileProducer(source, absolute);
|
|
73
|
+
if (artefacts === null)
|
|
74
|
+
return null;
|
|
75
|
+
const hash = hashSourcePath(absolute);
|
|
76
|
+
const rewrittenSource = rewriteProducerSource(artefacts.transformedSource, hash, artefacts.specifierToHash ?? new Map());
|
|
77
|
+
const drawnByExportName = new Map();
|
|
78
|
+
drawnByExportName.set("default", artefacts.manifest);
|
|
79
|
+
for (const sibling of artefacts.siblings) {
|
|
80
|
+
if (sibling.exportName !== undefined) {
|
|
81
|
+
drawnByExportName.set(sibling.exportName, sibling);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return Object.freeze({
|
|
85
|
+
sourcePath: absolute,
|
|
86
|
+
manifest: artefacts.manifest,
|
|
87
|
+
drawnByExportName,
|
|
88
|
+
moduleSource: artefacts.moduleSource,
|
|
89
|
+
rewrittenSource,
|
|
90
|
+
hash,
|
|
91
|
+
transitiveProducers: Object.freeze((artefacts.transitiveProducers ?? []).slice()),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
ancestryByAbsolute.delete(absolute);
|
|
96
|
+
}
|
|
97
|
+
})();
|
|
98
|
+
cache.set(absolute, pending);
|
|
99
|
+
insertionOrder.push(absolute);
|
|
100
|
+
while (insertionOrder.length > LRU_LIMIT) {
|
|
101
|
+
const oldest = insertionOrder.shift();
|
|
102
|
+
if (oldest !== undefined && oldest !== absolute) {
|
|
103
|
+
cache.delete(oldest);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return pending;
|
|
107
|
+
}
|
|
108
|
+
return resolveCrossFileProducer;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Compute the stable 12-hex-char identifier the bundler uses to namespace
|
|
112
|
+
* each inlined producer's locals (`__producer_<hash>__default`,
|
|
113
|
+
* `__producer_<hash>__<name>`). Driven off the producer's absolute path
|
|
114
|
+
* so two consumers in the same project share the same identifier for
|
|
115
|
+
* the same producer — esbuild's tree-shake then dedups the inline.
|
|
116
|
+
*
|
|
117
|
+
* @since 0.7
|
|
118
|
+
* @stable
|
|
119
|
+
* @example
|
|
120
|
+
* // const id = hashSourcePath("/repo/src/base.chart.ts");
|
|
121
|
+
* // id === "a1b2c3d4e5f6"
|
|
122
|
+
* const fn: typeof hashSourcePath = hashSourcePath;
|
|
123
|
+
* void fn;
|
|
124
|
+
*/
|
|
125
|
+
export function hashSourcePath(absolutePath) {
|
|
126
|
+
const normalised = absolutePath.replace(/\\/g, "/");
|
|
127
|
+
return createHash("sha256").update(normalised).digest("hex").slice(0, 12);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Rewrite a producer's printed TS source into a self-contained IIFE
|
|
131
|
+
* block that exposes one `__producer_<hash>__default` const. Strips
|
|
132
|
+
* `@invinite-org/chartlang-core` imports (the consumer already pulled
|
|
133
|
+
* the symbols in), lowers cross-file `.chart` imports to
|
|
134
|
+
* `const <name> = __producer_<nestedhash>__default;` so the inlined
|
|
135
|
+
* dep is read from the consumer's already-inlined namespace, replaces
|
|
136
|
+
* `export default <X>` with `return <X>;`, and wraps everything in an
|
|
137
|
+
* IIFE so private same-file consts stay scoped — preventing name
|
|
138
|
+
* collisions across producers that happen to share local identifiers.
|
|
139
|
+
*
|
|
140
|
+
* `specifierToHash` maps the producer's own cross-file import
|
|
141
|
+
* specifiers to the nested producers' stable hashes. Empty when the
|
|
142
|
+
* producer has no cross-file imports.
|
|
143
|
+
*
|
|
144
|
+
* @since 0.7
|
|
145
|
+
* @stable
|
|
146
|
+
* @example
|
|
147
|
+
* // const src = rewriteProducerSource(
|
|
148
|
+
* // 'export default defineIndicator({});',
|
|
149
|
+
* // 'a1b2c3',
|
|
150
|
+
* // new Map(),
|
|
151
|
+
* // );
|
|
152
|
+
* // src includes "const __producer_a1b2c3__default = (() => { ... })();"
|
|
153
|
+
* const fn: typeof rewriteProducerSource = rewriteProducerSource;
|
|
154
|
+
* void fn;
|
|
155
|
+
*/
|
|
156
|
+
export function rewriteProducerSource(source, hash, specifierToHash = new Map()) {
|
|
157
|
+
const sourceFile = ts.createSourceFile("producer.ts", source, ts.ScriptTarget.ES2022, true, ts.ScriptKind.TS);
|
|
158
|
+
const printer = ts.createPrinter({
|
|
159
|
+
removeComments: false,
|
|
160
|
+
newLine: ts.NewLineKind.LineFeed,
|
|
161
|
+
});
|
|
162
|
+
// Imports of `@invinite-org/chartlang-core` (and other host-supplied
|
|
163
|
+
// bare specifiers) are hoisted to the top of the rewritten output as
|
|
164
|
+
// top-level `import` statements so esbuild dedupes them against the
|
|
165
|
+
// consumer's own imports. Without hoisting, the producer's body
|
|
166
|
+
// references (`input.int(...)`, `ta.ema(...)`, etc.) would be unbound
|
|
167
|
+
// when the consumer omits those symbols from its own import line —
|
|
168
|
+
// a real bug surfaced by the dep-cross-file conformance scenario.
|
|
169
|
+
// Producer-side `.chart` imports stay lowered inside the IIFE body
|
|
170
|
+
// as `const <name> = __producer_<nestedHash>__default;` so the
|
|
171
|
+
// top-level inlined producer is read from the consumer's namespace.
|
|
172
|
+
const hoistedImports = [];
|
|
173
|
+
const bodyLines = [];
|
|
174
|
+
let defaultExpr = null;
|
|
175
|
+
const fullText = sourceFile.text;
|
|
176
|
+
for (const statement of sourceFile.statements) {
|
|
177
|
+
if (ts.isImportDeclaration(statement)) {
|
|
178
|
+
const specifier = statement.moduleSpecifier;
|
|
179
|
+
/* v8 ignore next */
|
|
180
|
+
if (!ts.isStringLiteral(specifier))
|
|
181
|
+
continue;
|
|
182
|
+
const text = specifier.text;
|
|
183
|
+
const nestedHash = specifierToHash.get(text);
|
|
184
|
+
if (nestedHash !== undefined) {
|
|
185
|
+
const clause = statement.importClause;
|
|
186
|
+
const defaultName = clause?.name?.text;
|
|
187
|
+
if (defaultName !== undefined) {
|
|
188
|
+
bodyLines.push(`const ${defaultName} = __producer_${nestedHash}__default;`);
|
|
189
|
+
}
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
// Non-chart import (e.g. `@invinite-org/chartlang-core`): hoist
|
|
193
|
+
// verbatim so esbuild dedupes against the consumer's imports.
|
|
194
|
+
hoistedImports.push(fullText.slice(statement.getStart(sourceFile), statement.getEnd()));
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (ts.isExportDeclaration(statement))
|
|
198
|
+
continue;
|
|
199
|
+
if (ts.isExportAssignment(statement)) {
|
|
200
|
+
defaultExpr = printer.printNode(ts.EmitHint.Expression, statement.expression, sourceFile);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (ts.isVariableStatement(statement)) {
|
|
204
|
+
const isExported = statement.modifiers?.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword);
|
|
205
|
+
if (isExported === true) {
|
|
206
|
+
bodyLines.push(rewriteVariableStatement(statement, hash, sourceFile, printer));
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
bodyLines.push(fullText.slice(statement.getStart(sourceFile), statement.getEnd()));
|
|
211
|
+
}
|
|
212
|
+
const returnLine = defaultExpr === null ? "return undefined;" : `return ${defaultExpr};`;
|
|
213
|
+
const iife = `const __producer_${hash}__default = (() => {\n${bodyLines.join("\n")}\n${returnLine}\n})();`;
|
|
214
|
+
return hoistedImports.length === 0 ? iife : `${hoistedImports.join("\n")}\n${iife}`;
|
|
215
|
+
}
|
|
216
|
+
function rewriteVariableStatement(statement, hash, sourceFile, printer) {
|
|
217
|
+
const declarations = statement.declarationList.declarations
|
|
218
|
+
.map((decl) => {
|
|
219
|
+
const nameNode = decl.name;
|
|
220
|
+
if (!ts.isIdentifier(nameNode))
|
|
221
|
+
return null;
|
|
222
|
+
const initializer = decl.initializer;
|
|
223
|
+
if (initializer === undefined)
|
|
224
|
+
return null;
|
|
225
|
+
const initText = printer.printNode(ts.EmitHint.Expression, initializer, sourceFile);
|
|
226
|
+
return `const __producer_${hash}__${nameNode.text} = ${initText};`;
|
|
227
|
+
})
|
|
228
|
+
.filter((line) => line !== null);
|
|
229
|
+
return declarations.join("\n");
|
|
230
|
+
}
|
|
231
|
+
function resolveImportPath(importPath, fromSourcePath, rootAbsolute) {
|
|
232
|
+
let normalised;
|
|
233
|
+
if (importPath.endsWith(".chart.ts")) {
|
|
234
|
+
normalised = importPath;
|
|
235
|
+
}
|
|
236
|
+
else if (importPath.endsWith(".chart")) {
|
|
237
|
+
normalised = `${importPath}.ts`;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
// `fromSourcePath` may be absolute (driven by `compileFile`'s
|
|
243
|
+
// absolute resolution) or relative to the process cwd (driven by
|
|
244
|
+
// `compileProject` passing posix-relative paths). Resolve against
|
|
245
|
+
// cwd so both forms work.
|
|
246
|
+
const fromAbsolute = isAbsolute(fromSourcePath)
|
|
247
|
+
? fromSourcePath
|
|
248
|
+
: resolvePath(process.cwd(), fromSourcePath);
|
|
249
|
+
const fromDir = dirname(fromAbsolute);
|
|
250
|
+
const absolute = isAbsolute(normalised) ? normalised : resolvePath(fromDir, normalised);
|
|
251
|
+
const rel = relative(rootAbsolute, absolute);
|
|
252
|
+
if (rel.startsWith("..") || isAbsolute(rel))
|
|
253
|
+
return null;
|
|
254
|
+
return absolute;
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=resolveProducer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveProducer.js","sourceRoot":"","sources":["../../src/dependency/resolveProducer.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAElF,OAAO,EAAE,MAAM,YAAY,CAAC;AAmI5B,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CAClC,IAAmC,EACnC,eAAwC;IAExC,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAA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AChB,CAAC;IACD,8DAA8D;IAC9D,iEAAiE;IACjE,kEAAkE;IAClE,0BAA0B;IAC1B,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,CAAC;QAC3C,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACxF,MAAM,GAAG,GAAG,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC7C,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACzD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -5,13 +5,17 @@ import type ts from "typescript";
|
|
|
5
5
|
* filtering stays compatible across versions.
|
|
6
6
|
*
|
|
7
7
|
* Phase 1 ships eight emittable codes plus Phase 4's
|
|
8
|
-
* `request.security` and input-extraction codes.
|
|
8
|
+
* `request.security` and input-extraction codes. Phase 7 adds
|
|
9
|
+
* `multiple-default-exports`, `non-const-define-binding`, and the six
|
|
10
|
+
* `dep-*` codes for indicator-composition analysis (plus
|
|
11
|
+
* `duplicate-output-title` for clashing `plot(value, { title })`
|
|
12
|
+
* declarations in the same script).
|
|
9
13
|
*
|
|
10
14
|
* @since 0.1
|
|
11
15
|
* @example
|
|
12
16
|
* const code: CompileDiagnosticCode = "unbounded-loop";
|
|
13
17
|
*/
|
|
14
|
-
export type CompileDiagnosticCode = "unbounded-loop" | "recursion-not-allowed" | "hostile-global" | "stateful-call-inside-loop" | "stateful-call-element-access" | "request-security-interval-not-literal" | "dynamic-series-index" | "callsite-id-conflict" | "missing-default-export" | "api-version-mismatch" | "input-default-not-literal" | "unknown-input-kind" | "multiple-input-interval" | "requires-intervals-not-literal" | "alert-condition-not-literal" | "alert-condition-field-not-literal" | "lower-tf-not-lower" | "request-lower-tf-interval-not-literal" | "type-error";
|
|
18
|
+
export type CompileDiagnosticCode = "unbounded-loop" | "recursion-not-allowed" | "hostile-global" | "stateful-call-inside-loop" | "stateful-call-element-access" | "request-security-interval-not-literal" | "dynamic-series-index" | "callsite-id-conflict" | "missing-default-export" | "api-version-mismatch" | "input-default-not-literal" | "unknown-input-kind" | "multiple-input-interval" | "requires-intervals-not-literal" | "alert-condition-not-literal" | "alert-condition-field-not-literal" | "lower-tf-not-lower" | "request-lower-tf-interval-not-literal" | "type-error" | "multiple-default-exports" | "non-const-define-binding" | "dep-cycle" | "dep-unknown-output" | "dep-invalid-input-override" | "dep-dynamic" | "dep-output-not-titled" | "duplicate-output-title";
|
|
15
19
|
/**
|
|
16
20
|
* Single diagnostic the compiler emits while transforming or analysing a
|
|
17
21
|
* `.chart.ts` source. The shape is intentionally small — file/line/column and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,qBAAqB,GAC3B,gBAAgB,GAChB,uBAAuB,GACvB,gBAAgB,GAChB,2BAA2B,GAC3B,8BAA8B,GAC9B,uCAAuC,GACvC,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,sBAAsB,GACtB,2BAA2B,GAC3B,oBAAoB,GACpB,yBAAyB,GACzB,gCAAgC,GAChC,6BA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version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AA8E/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAQhC;IACG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC;IAC5E,MAAM,IAAI,GAAG;QACT,QAAQ;QACR,IAAI;QACJ,OAAO;QACP,IAAI;QACJ,IAAI,EAAE,IAAI,GAAG,CAAC;QACd,MAAM,EAAE,SAAS,GAAG,CAAC;KACxB,CAAC;IACF,IAAI,cAAc,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACtC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,SAAS,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC3E,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QACnF,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI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AAI,IAAI,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,KAAK,GAA6C,IAAI,CAAC;IAC7D,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { CompileError, compile, compileFile, compileProject, transformAndAnalyse, walkChartFiles, writeAtomic, } from "./api.js";
|
|
2
2
|
export type { CompileFileOptions, CompileOptions, CompiledScript, TransformAndAnalyseOptions, TransformAndAnalyseResult, } from "./api.js";
|
|
3
3
|
export { bundleModule, formatManifestAssignment } from "./bundle.js";
|
|
4
|
-
export type { BundleModuleOptions, BundleModuleResult } from "./bundle.js";
|
|
4
|
+
export type { BundleModuleOptions, BundleModuleResult, InlinedProducer, } from "./bundle.js";
|
|
5
|
+
export { createProducerResolver, hashSourcePath, rewriteProducerSource, } from "./dependency/index.js";
|
|
6
|
+
export type { CompiledProducerArtefacts, CompileProducerCallback, CreateProducerResolverOptions, ProducerCompiled, ResolveCrossFileProducer, } from "./dependency/index.js";
|
|
5
7
|
export type { CompileDiagnostic, CompileDiagnosticCode } from "./diagnostics.js";
|
|
6
8
|
export { emitTypes } from "./typesEmit.js";
|
|
7
9
|
export type { EmitTypesOptions } from "./typesEmit.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,YAAY,EACZ,OAAO,EACP,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,WAAW,GACd,MAAM,UAAU,CAAC;AAClB,YAAY,EACR,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,yBAAyB,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACrE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,YAAY,EACZ,OAAO,EACP,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,WAAW,GACd,MAAM,UAAU,CAAC;AAClB,YAAY,EACR,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,yBAAyB,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACrE,YAAY,EACR,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,sBAAsB,EACtB,cAAc,EACd,qBAAqB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACR,yBAAyB,EACzB,uBAAuB,EACvB,6BAA6B,EAC7B,gBAAgB,EAChB,wBAAwB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
3
|
export { CompileError, compile, compileFile, compileProject, transformAndAnalyse, walkChartFiles, writeAtomic, } from "./api.js";
|
|
4
4
|
export { bundleModule, formatManifestAssignment } from "./bundle.js";
|
|
5
|
+
export { createProducerResolver, hashSourcePath, rewriteProducerSource, } from "./dependency/index.js";
|
|
5
6
|
export { emitTypes } from "./typesEmit.js";
|
|
6
7
|
export { resolveCalleeName } from "./transformers/resolveCallee.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EACH,YAAY,EACZ,OAAO,EACP,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,WAAW,GACd,MAAM,UAAU,CAAC;AAQlB,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EACH,YAAY,EACZ,OAAO,EACP,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,WAAW,GACd,MAAM,UAAU,CAAC;AAQlB,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAMrE,OAAO,EACH,sBAAsB,EACtB,cAAc,EACd,qBAAqB,GACxB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AlertConditionDefinition, CapabilityId, ScriptManifest } from "@invinite-org/chartlang-core";
|
|
1
|
+
import type { AlertConditionDefinition, CapabilityId, DependencyDeclaration, OutputDeclaration, PlotSlotDescriptor, ScriptManifest } from "@invinite-org/chartlang-core";
|
|
2
2
|
type ValueFormat = "price" | "volume" | "percent" | "compact";
|
|
3
3
|
type ScaleAxis = "price" | "left" | "right" | "new";
|
|
4
4
|
type ManifestInputDescriptors = Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
@@ -28,6 +28,7 @@ export declare function buildManifest(args: {
|
|
|
28
28
|
readonly seriesCapacities: Readonly<Record<string, number>>;
|
|
29
29
|
readonly maxLookback: number;
|
|
30
30
|
readonly inputs: ManifestInputDescriptors;
|
|
31
|
+
readonly overlay?: boolean;
|
|
31
32
|
readonly maxBarsBack?: number;
|
|
32
33
|
readonly format?: ValueFormat;
|
|
33
34
|
readonly precision?: number;
|
|
@@ -35,6 +36,12 @@ export declare function buildManifest(args: {
|
|
|
35
36
|
readonly requiresIntervals?: ReadonlyArray<string>;
|
|
36
37
|
readonly shortName?: string;
|
|
37
38
|
readonly alertConditions?: ReadonlyArray<AlertConditionDefinition>;
|
|
39
|
+
readonly dependencies?: ReadonlyArray<DependencyDeclaration>;
|
|
40
|
+
readonly outputs?: ReadonlyArray<OutputDeclaration>;
|
|
41
|
+
readonly plots?: ReadonlyArray<PlotSlotDescriptor>;
|
|
42
|
+
readonly exportName?: string;
|
|
43
|
+
readonly isDrawn?: boolean;
|
|
44
|
+
readonly siblings?: ReadonlyArray<ScriptManifest>;
|
|
38
45
|
}): ScriptManifest;
|
|
39
46
|
export {};
|
|
40
47
|
//# sourceMappingURL=manifest.d.ts.map
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,wBAAwB,EACxB,YAAY,EACZ,cAAc,EACjB,MAAM,8BAA8B,CAAC;AAEtC,KAAK,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAC9D,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AACpD,KAAK,wBAAwB,GAAG,QAAQ,CAAC,MAAM,CAAC,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,eAAe,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;IACnE,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACnD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACrD,GAAG,cAAc,CAqFjB"}
|
package/dist/manifest.js
CHANGED
|
@@ -35,6 +35,26 @@ export function buildManifest(args) {
|
|
|
35
35
|
description: condition.description,
|
|
36
36
|
defaultMessage: condition.defaultMessage,
|
|
37
37
|
})));
|
|
38
|
+
const dependencies = args.dependencies === undefined || args.dependencies.length === 0
|
|
39
|
+
? undefined
|
|
40
|
+
: Object.freeze(args.dependencies.map((dep) => Object.freeze({
|
|
41
|
+
localId: dep.localId,
|
|
42
|
+
producerName: dep.producerName,
|
|
43
|
+
producerSourcePath: dep.producerSourcePath,
|
|
44
|
+
producerExportName: dep.producerExportName,
|
|
45
|
+
effectiveInputs: Object.freeze({ ...dep.effectiveInputs }),
|
|
46
|
+
outputs: Object.freeze(dep.outputs.map((o) => Object.freeze({ title: o.title, kind: o.kind }))),
|
|
47
|
+
isDrawn: dep.isDrawn,
|
|
48
|
+
})));
|
|
49
|
+
const outputs = args.outputs === undefined || args.outputs.length === 0
|
|
50
|
+
? undefined
|
|
51
|
+
: Object.freeze(args.outputs.map((o) => Object.freeze({ title: o.title, kind: o.kind })));
|
|
52
|
+
const plots = args.plots === undefined || args.plots.length === 0
|
|
53
|
+
? undefined
|
|
54
|
+
: Object.freeze(args.plots.map((s) => Object.freeze({ ...s })));
|
|
55
|
+
const siblings = args.siblings === undefined || args.siblings.length === 0
|
|
56
|
+
? undefined
|
|
57
|
+
: Object.freeze(args.siblings.slice());
|
|
38
58
|
return Object.freeze({
|
|
39
59
|
apiVersion: 1,
|
|
40
60
|
kind: args.kind,
|
|
@@ -45,6 +65,7 @@ export function buildManifest(args) {
|
|
|
45
65
|
userPickableInterval: args.userPickableInterval,
|
|
46
66
|
seriesCapacities,
|
|
47
67
|
maxLookback: args.maxLookback,
|
|
68
|
+
...(args.overlay === undefined ? {} : { overlay: args.overlay }),
|
|
48
69
|
...(args.maxBarsBack === undefined ? {} : { maxBarsBack: args.maxBarsBack }),
|
|
49
70
|
...(args.format === undefined ? {} : { format: args.format }),
|
|
50
71
|
...(args.precision === undefined ? {} : { precision: args.precision }),
|
|
@@ -52,6 +73,12 @@ export function buildManifest(args) {
|
|
|
52
73
|
...(requiresIntervals === undefined ? {} : { requiresIntervals }),
|
|
53
74
|
...(args.shortName === undefined ? {} : { shortName: args.shortName }),
|
|
54
75
|
...(alertConditions === undefined ? {} : { alertConditions }),
|
|
76
|
+
...(dependencies === undefined ? {} : { dependencies }),
|
|
77
|
+
...(outputs === undefined ? {} : { outputs }),
|
|
78
|
+
...(plots === undefined ? {} : { plots }),
|
|
79
|
+
...(args.exportName === undefined ? {} : { exportName: args.exportName }),
|
|
80
|
+
...(args.isDrawn === undefined ? {} : { isDrawn: args.isDrawn }),
|
|
81
|
+
...(siblings === undefined ? {} : { siblings }),
|
|
55
82
|
});
|
|
56
83
|
}
|
|
57
84
|
//# sourceMappingURL=manifest.js.map
|
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAe/D;;;;;;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CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;KAClD,CAAC,CAAC;AACP,CAAC"}
|
package/dist/program.d.ts
CHANGED
|
@@ -64,5 +64,6 @@ export type ProgramForSource = Readonly<{
|
|
|
64
64
|
*/
|
|
65
65
|
export declare function createProgramForSource(source: string, opts: {
|
|
66
66
|
readonly sourcePath: string;
|
|
67
|
+
readonly chartImports?: ReadonlyArray<string>;
|
|
67
68
|
}): ProgramForSource;
|
|
68
69
|
//# sourceMappingURL=program.d.ts.map
|
package/dist/program.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AA00C3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,eAYjC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACpC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IACpB,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IAC1B,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;CAC3B,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACjD,GACF,gBAAgB,CAsFlB"}
|
package/dist/program.js
CHANGED
|
@@ -710,7 +710,6 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
710
710
|
| "step-line"
|
|
711
711
|
| "horizontal-line"
|
|
712
712
|
| "histogram"
|
|
713
|
-
| "bars"
|
|
714
713
|
| "area"
|
|
715
714
|
| "filled-band"
|
|
716
715
|
| "label"
|
|
@@ -785,6 +784,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
785
784
|
title?: string;
|
|
786
785
|
lineWidth?: number;
|
|
787
786
|
lineStyle?: LineStyle;
|
|
787
|
+
pane?: "overlay" | "new" | string;
|
|
788
788
|
}>;
|
|
789
789
|
export function plot(value: number | Series<number>, opts?: PlotOpts): void;
|
|
790
790
|
export function hline(price: number, opts?: HLineOpts): void;
|
|
@@ -808,12 +808,17 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
808
808
|
volume: ReadonlyArray<number | null>;
|
|
809
809
|
}>;
|
|
810
810
|
}>;
|
|
811
|
+
export type RunnerSnapshot = Readonly<{
|
|
812
|
+
slots: Readonly<Record<string, JsonValue>>;
|
|
813
|
+
}>;
|
|
811
814
|
export type StateSnapshot = Readonly<{
|
|
812
815
|
lastBarTime: number;
|
|
813
816
|
streams: Readonly<Record<string, StreamSnapshot>>;
|
|
814
|
-
slots: Readonly<Record<string, JsonValue>>;
|
|
815
817
|
savedAt: number;
|
|
816
818
|
snapshotVersion: 1;
|
|
819
|
+
primary: RunnerSnapshot;
|
|
820
|
+
siblings?: Readonly<Record<string, RunnerSnapshot>>;
|
|
821
|
+
dependencies?: Readonly<Record<string, RunnerSnapshot>>;
|
|
817
822
|
}>;
|
|
818
823
|
export type StateStoreKey = Readonly<{
|
|
819
824
|
scriptHash: string;
|
|
@@ -1022,6 +1027,24 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1022
1027
|
}>;
|
|
1023
1028
|
export const request: RequestNamespace;
|
|
1024
1029
|
export function intervalToSeconds(d: IntervalDescriptor): number;
|
|
1030
|
+
export type OutputDeclaration = Readonly<{
|
|
1031
|
+
readonly title: string;
|
|
1032
|
+
readonly kind: "series-number";
|
|
1033
|
+
}>;
|
|
1034
|
+
export type PlotSlotDescriptor = Readonly<{
|
|
1035
|
+
readonly slotId: string;
|
|
1036
|
+
readonly kind: PlotKind;
|
|
1037
|
+
readonly title?: string;
|
|
1038
|
+
}>;
|
|
1039
|
+
export type DependencyDeclaration = Readonly<{
|
|
1040
|
+
readonly localId: string;
|
|
1041
|
+
readonly producerName: string;
|
|
1042
|
+
readonly producerSourcePath: string;
|
|
1043
|
+
readonly producerExportName: string;
|
|
1044
|
+
readonly effectiveInputs: Readonly<Record<string, JsonValue>>;
|
|
1045
|
+
readonly outputs: ReadonlyArray<OutputDeclaration>;
|
|
1046
|
+
readonly isDrawn: boolean;
|
|
1047
|
+
}>;
|
|
1025
1048
|
export type ScriptManifest = {
|
|
1026
1049
|
readonly apiVersion: 1;
|
|
1027
1050
|
readonly kind: "indicator" | "drawing" | "alert" | "alertCondition";
|
|
@@ -1032,6 +1055,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1032
1055
|
readonly userPickableInterval: boolean;
|
|
1033
1056
|
readonly seriesCapacities: Readonly<Record<string, number>>;
|
|
1034
1057
|
readonly maxLookback: number;
|
|
1058
|
+
readonly overlay?: boolean;
|
|
1035
1059
|
readonly maxDrawings?: DrawingCounts;
|
|
1036
1060
|
readonly maxBarsBack?: number;
|
|
1037
1061
|
readonly format?: ValueFormat;
|
|
@@ -1040,6 +1064,12 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1040
1064
|
readonly shortName?: string;
|
|
1041
1065
|
readonly requiresIntervals?: ReadonlyArray<string>;
|
|
1042
1066
|
readonly alertConditions?: ReadonlyArray<AlertConditionDefinition>;
|
|
1067
|
+
readonly dependencies?: ReadonlyArray<DependencyDeclaration>;
|
|
1068
|
+
readonly outputs?: ReadonlyArray<OutputDeclaration>;
|
|
1069
|
+
readonly plots?: ReadonlyArray<PlotSlotDescriptor>;
|
|
1070
|
+
readonly exportName?: string;
|
|
1071
|
+
readonly siblings?: ReadonlyArray<ScriptManifest>;
|
|
1072
|
+
readonly isDrawn?: boolean;
|
|
1043
1073
|
};
|
|
1044
1074
|
export type AlertConditionDescriptor = Readonly<{
|
|
1045
1075
|
title: string;
|
|
@@ -1259,7 +1289,26 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1259
1289
|
export type CompiledScriptObject = {
|
|
1260
1290
|
readonly manifest: ScriptManifest;
|
|
1261
1291
|
readonly compute: ComputeFn;
|
|
1292
|
+
readonly output: (name: string) => Series<number>;
|
|
1293
|
+
readonly withInputs: (
|
|
1294
|
+
overrides: Readonly<Record<string, unknown>>,
|
|
1295
|
+
) => CompiledScriptObject;
|
|
1262
1296
|
};
|
|
1297
|
+
export type CompiledScriptBundle = Readonly<{
|
|
1298
|
+
readonly primary: CompiledScriptObject;
|
|
1299
|
+
readonly siblings: ReadonlyArray<{
|
|
1300
|
+
readonly exportName: string;
|
|
1301
|
+
readonly compiled: CompiledScriptObject;
|
|
1302
|
+
}>;
|
|
1303
|
+
readonly dependencies: ReadonlyArray<{
|
|
1304
|
+
readonly localId: string;
|
|
1305
|
+
readonly compiled: CompiledScriptObject;
|
|
1306
|
+
readonly inputOverrides?: Readonly<Record<string, unknown>>;
|
|
1307
|
+
}>;
|
|
1308
|
+
}>;
|
|
1309
|
+
export function isCompiledScriptBundle(
|
|
1310
|
+
v: CompiledScriptObject | CompiledScriptBundle,
|
|
1311
|
+
): v is CompiledScriptBundle;
|
|
1263
1312
|
export type DefineIndicatorOpts = Readonly<{
|
|
1264
1313
|
name: string;
|
|
1265
1314
|
apiVersion: 1;
|
|
@@ -1267,6 +1316,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1267
1316
|
inputs?: InputSchema;
|
|
1268
1317
|
compute: ComputeFn;
|
|
1269
1318
|
maxDrawings?: DrawingCounts;
|
|
1319
|
+
outputs?: ReadonlyArray<OutputDeclaration>;
|
|
1270
1320
|
}> & ScriptOverrides;
|
|
1271
1321
|
export type DefineAlertOpts = Readonly<{
|
|
1272
1322
|
name: string;
|
|
@@ -1357,9 +1407,29 @@ export const COMPILER_OPTIONS = {
|
|
|
1357
1407
|
*/
|
|
1358
1408
|
export function createProgramForSource(source, opts) {
|
|
1359
1409
|
const sourcePath = normalisePath(opts.sourcePath);
|
|
1360
|
-
const VIRTUAL_FILE_SET = new Set([sourcePath, CORE_MODULE_PATH]);
|
|
1361
1410
|
const sourceFile = ts.createSourceFile(sourcePath, source, ts.ScriptTarget.ES2022, true, ts.ScriptKind.TS);
|
|
1362
1411
|
const shimFile = ts.createSourceFile(CORE_MODULE_PATH, CORE_AMBIENT_SHIM, ts.ScriptTarget.ES2022, true, ts.ScriptKind.TS);
|
|
1412
|
+
// Synthesise an ambient declaration for every `.chart` / `.chart.ts`
|
|
1413
|
+
// import the caller pre-scanned. Each module exports a default
|
|
1414
|
+
// `CompiledScriptObject` so consumer-side typecheck passes; the
|
|
1415
|
+
// analysis pass walks the real `ProducerSnapshot` for output-title
|
|
1416
|
+
// validation (see `extractDependencyGraph.ts`).
|
|
1417
|
+
const chartImports = opts.chartImports ?? [];
|
|
1418
|
+
const chartShimPath = "/__chartlang__/chart-imports.d.ts";
|
|
1419
|
+
const VIRTUAL_FILE_SET = new Set([sourcePath, CORE_MODULE_PATH]);
|
|
1420
|
+
let chartShimFile;
|
|
1421
|
+
if (chartImports.length > 0) {
|
|
1422
|
+
VIRTUAL_FILE_SET.add(chartShimPath);
|
|
1423
|
+
const body = chartImports
|
|
1424
|
+
.map((specifier) => `
|
|
1425
|
+
declare module ${JSON.stringify(specifier)} {
|
|
1426
|
+
import type { CompiledScriptObject } from "@invinite-org/chartlang-core";
|
|
1427
|
+
const value: CompiledScriptObject;
|
|
1428
|
+
export default value;
|
|
1429
|
+
}`)
|
|
1430
|
+
.join("\n");
|
|
1431
|
+
chartShimFile = ts.createSourceFile(chartShimPath, body, ts.ScriptTarget.ES2022, true, ts.ScriptKind.TS);
|
|
1432
|
+
}
|
|
1363
1433
|
const fallbackHost = ts.createCompilerHost(COMPILER_OPTIONS, true);
|
|
1364
1434
|
const host = {
|
|
1365
1435
|
...fallbackHost,
|
|
@@ -1368,14 +1438,20 @@ export function createProgramForSource(source, opts) {
|
|
|
1368
1438
|
return sourceFile;
|
|
1369
1439
|
if (fileName === CORE_MODULE_PATH)
|
|
1370
1440
|
return shimFile;
|
|
1441
|
+
if (fileName === chartShimPath && chartShimFile !== undefined) {
|
|
1442
|
+
return chartShimFile;
|
|
1443
|
+
}
|
|
1371
1444
|
return fallbackHost.getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
1372
1445
|
},
|
|
1373
1446
|
fileExists(fileName) {
|
|
1374
1447
|
return VIRTUAL_FILE_SET.has(fileName) || fallbackHost.fileExists(fileName);
|
|
1375
1448
|
},
|
|
1376
1449
|
};
|
|
1450
|
+
const rootNames = [sourcePath, CORE_MODULE_PATH];
|
|
1451
|
+
if (chartShimFile !== undefined)
|
|
1452
|
+
rootNames.push(chartShimPath);
|
|
1377
1453
|
const program = ts.createProgram({
|
|
1378
|
-
rootNames
|
|
1454
|
+
rootNames,
|
|
1379
1455
|
options: COMPILER_OPTIONS,
|
|
1380
1456
|
host,
|
|
1381
1457
|
});
|