@invinite-org/chartlang-compiler 1.1.0 → 1.2.1
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 +14 -0
- package/dist/analysis/extractAlertConditions.js.map +1 -1
- package/dist/analysis/extractCapabilities.js.map +1 -1
- package/dist/analysis/extractDependencyGraph.js.map +1 -1
- package/dist/analysis/extractInputs.js.map +1 -1
- package/dist/analysis/extractMaxLookback.js.map +1 -1
- package/dist/analysis/extractRequestedIntervals.js.map +1 -1
- package/dist/analysis/extractRequiresIntervals.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 +1 -2
- package/dist/analysis/forbiddenConstructs.js.map +1 -1
- package/dist/analysis/index.js.map +1 -1
- package/dist/analysis/statefulCallInLoop.js.map +1 -1
- package/dist/analysis/structuralChecks.d.ts +1 -1
- package/dist/analysis/structuralChecks.js.map +1 -1
- package/dist/analysis/validateLowerTfIntervals.js.map +1 -1
- package/dist/api.d.ts +12 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1 -0
- package/dist/api.js.map +1 -1
- package/dist/bundle.d.ts +1 -0
- package/dist/bundle.d.ts.map +1 -1
- package/dist/bundle.js +29 -0
- package/dist/bundle.js.map +1 -1
- package/dist/dependency/index.js.map +1 -1
- package/dist/dependency/resolveProducer.js.map +1 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/manifest.js.map +1 -1
- package/dist/program.js.map +1 -1
- package/dist/transformers/callsiteIdInjection.d.ts +1 -1
- package/dist/transformers/callsiteIdInjection.js +1 -1
- package/dist/transformers/callsiteIdInjection.js.map +1 -1
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/plotKindFromCallsite.js.map +1 -1
- package/dist/transformers/resolveCallee.js.map +1 -1
- package/dist/transformers/rewriteDependencyAccessors.js.map +1 -1
- package/dist/typesEmit.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +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,CAAC,OAAO,CAAC;QACzC,CAAC,CAAC,IAAI,CAAC,OAAO;QACd,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4C,CAAC;IAClE,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,oEAAoE;IACpE,oEAAoE;IACpE,oEAAoE;IACpE,qEAAqE;IACrE,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAA+B,CAAC;IAElE,SAAS,wBAAwB,CAC7B,UAAkB,EAClB,cAAsB;QAEtB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,UAAU,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QAC7E,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEpD,6DAA6D;QAC7D,0DAA0D;QAC1D,gDAAgD;QAChD,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,C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AAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACrD,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,iBAAiB,CACtB,UAAkB,EAClB,cAAsB,EACtB,YAAoB;IAEpB,IAAI,UAAkB,CAAC;IACvB,IAAI,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnC,UAAU,GAAG,UAAU,CAAC;IAC5B,CAAC;SAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvC,UAAU,GAAG,GAAG,UAAU,KAAK,CAAC;IACpC,CAAC;SAAM,CAAC;QACJ,OAAO,IAAI,CAAC;IAChB,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","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport { dirname, isAbsolute, relative, resolve as resolvePath } from \"node:path\";\nimport type { ScriptManifest } from \"@invinite-org/chartlang-core\";\nimport ts from \"typescript\";\n\n/**\n * Producer compiled snapshot returned by {@link ResolveCrossFileProducer}.\n * Carries the producer's manifest, every drawn export's manifest indexed\n * by `exportName`, and the producer's `rewrittenSource` — TS source with\n * top-level `import` statements stripped and every `export default <X>`\n * or `export const <name> = <X>` lowered to `const __producer_<hash>__<…> = <X>`.\n * The consumer's bundler concatenates `rewrittenSource` ahead of the\n * consumer's own transformed source so esbuild can tree-shake the\n * combined module.\n *\n * @since 0.7\n * @stable\n * @example\n * const c: ProducerCompiled = {\n * sourcePath: \"base.chart.ts\",\n * manifest: {} as ScriptManifest,\n * drawnByExportName: new Map(),\n * moduleSource: \"\",\n * rewrittenSource: \"\",\n * hash: \"\",\n * };\n * void c;\n */\nexport type ProducerCompiled = Readonly<{\n readonly sourcePath: string;\n readonly manifest: ScriptManifest;\n readonly drawnByExportName: ReadonlyMap<string, ScriptManifest>;\n readonly moduleSource: string;\n readonly rewrittenSource: string;\n readonly hash: string;\n /**\n * Transitive producers this producer itself imports — keyed by hash\n * so the top-level consumer can dedup the inline-once invariant\n * across the whole project's diamond shape.\n *\n * @since 0.7\n */\n readonly transitiveProducers: ReadonlyArray<ProducerCompiled>;\n}>;\n\n/**\n * Resolve a cross-file producer reference (`import X from \"./Y.chart\"`)\n * to its compiled snapshot. Returns `null` when the path is not a\n * `.chart.ts` file, escapes the resolver's `rootDir`, can't be read,\n * forms a cycle, or fails to compile.\n *\n * @since 0.7\n * @stable\n * @example\n * const r: ResolveCrossFileProducer = async () => null;\n * void r;\n */\nexport type ResolveCrossFileProducer = (\n importPath: string,\n fromSourcePath: string,\n) => Promise<ProducerCompiled | null>;\n\n/**\n * Options accepted by {@link createProducerResolver}. `rootDir` is the\n * absolute base directory that constrains every cross-file walk —\n * imports resolving outside this tree return `null`.\n *\n * @since 0.7\n * @stable\n * @example\n * const opts: CreateProducerResolverOptions = { rootDir: \"/repo\" };\n * void opts;\n */\nexport type CreateProducerResolverOptions = Readonly<{\n readonly rootDir: string;\n}>;\n\n/**\n * Compile callback the resolver delegates the actual producer compilation\n * to. Keeps the resolver decoupled from `compile`'s import graph so the\n * resolver module can be unit-tested in isolation.\n *\n * @since 0.7\n * @stable\n * @example\n * const c: CompileProducerCallback = async () => null;\n * void c;\n */\nexport type CompileProducerCallback = (\n source: string,\n sourcePath: string,\n) => Promise<CompiledProducerArtefacts | null>;\n\n/**\n * Artefacts the {@link CompileProducerCallback} hands back for a single\n * producer file. Mirrors the public `CompileResult` shape but drops\n * sourcemaps and types (the resolver only needs the JS + manifests).\n *\n * @since 0.7\n * @stable\n * @example\n * const a: CompiledProducerArtefacts = {\n * moduleSource: \"\",\n * transformedSource: \"\",\n * manifest: {} as ScriptManifest,\n * siblings: [],\n * };\n * void a;\n */\nexport type CompiledProducerArtefacts = Readonly<{\n readonly moduleSource: string;\n readonly transformedSource: string;\n readonly manifest: ScriptManifest;\n readonly siblings: ReadonlyArray<ScriptManifest>;\n /**\n * Transitive producers this producer pulled in via its own\n * `import X from \"./Y.chart\"` lines. Each entry is the\n * `ProducerCompiled` snapshot the resolver previously returned.\n *\n * @since 0.7\n */\n readonly transitiveProducers?: ReadonlyArray<ProducerCompiled>;\n /**\n * Mapping from the producer's own `.chart` import specifiers to\n * the resolved producer's hash. Used by the resolver to rewrite\n * cross-file imports inside the producer's IIFE so transitive deps\n * are read from the consumer's namespace instead of left as bare\n * `import` lines.\n *\n * @since 0.7\n */\n readonly specifierToHash?: ReadonlyMap<string, string>;\n}>;\n\nconst LRU_LIMIT = 256;\n\n/**\n * Build a Promise-cached, cycle-safe cross-file `.chart.ts` resolver. Each\n * unique absolute path is compiled at most once per resolver instance.\n * Cycles (`A` imports `B` imports `A`) surface as `null` so the calling\n * compile pass can raise `dep-cycle` at the consumer's call site.\n *\n * The resolver delegates the actual compile to a caller-supplied\n * {@link CompileProducerCallback} so this module stays free of the\n * compile pipeline's import graph — testable in isolation.\n *\n * @since 0.7\n * @stable\n * @example\n * // const resolve = createProducerResolver({ rootDir: cwd }, compileFn);\n * // const producer = await resolve(\"./base.chart\", \"consumer.chart.ts\");\n * const fn: typeof createProducerResolver = createProducerResolver;\n * void fn;\n */\nexport function createProducerResolver(\n opts: CreateProducerResolverOptions,\n compileProducer: CompileProducerCallback,\n): ResolveCrossFileProducer {\n const rootAbsolute = isAbsolute(opts.rootDir)\n ? opts.rootDir\n : resolvePath(process.cwd(), opts.rootDir);\n const cache = new Map<string, Promise<ProducerCompiled | null>>();\n const insertionOrder: string[] = [];\n // Track per-resolve-chain ancestry. Each compileProducer for file X\n // adds X to its descendants' chains via a per-promise registry so a\n // genuine cycle (X → Y → X) is detected without false-positiving on\n // concurrent sibling compiles (X → Y and X → Z, sharing producer Y).\n const ancestryByAbsolute = new Map<string, ReadonlySet<string>>();\n\n function resolveCrossFileProducer(\n importPath: string,\n fromSourcePath: string,\n ): Promise<ProducerCompiled | null> {\n const absolute = resolveImportPath(importPath, fromSourcePath, rootAbsolute);\n if (absolute === null) return Promise.resolve(null);\n\n // Cycle: the file we'd compile is already an ancestor of the\n // file currently driving the resolve. Returns null so the\n // caller surfaces `dep-cycle` at the call site.\n const fromAbsolute = isAbsolute(fromSourcePath)\n ? fromSourcePath\n : resolvePath(rootAbsolute, fromSourcePath);\n const ancestors = ancestryByAbsolute.get(fromAbsolute);\n if (ancestors !== undefined && (ancestors.has(absolute) || fromAbsolute === absolute)) {\n return Promise.resolve(null);\n }\n\n const cached = cache.get(absolute);\n if (cached !== undefined) return cached;\n\n const childAncestry = new Set<string>(ancestors ?? []);\n childAncestry.add(fromAbsolute);\n ancestryByAbsolute.set(absolute, childAncestry);\n\n const pending = (async (): Promise<ProducerCompiled | null> => {\n try {\n let source: string;\n try {\n source = await readFile(absolute, \"utf8\");\n } catch {\n return null;\n }\n // Hand the absolute path to `compileProducer` so the\n // recursive `compile` invocation can resolve nested\n // cross-file imports from the producer's real location\n // without going through the (process-cwd-dependent)\n // posix-relative form. The compiler's callsite-id slot\n // ids still derive from this path verbatim.\n const artefacts = await compileProducer(source, absolute);\n if (artefacts === null) return null;\n const hash = hashSourcePath(absolute);\n const rewrittenSource = rewriteProducerSource(\n artefacts.transformedSource,\n hash,\n artefacts.specifierToHash ?? new Map(),\n );\n const drawnByExportName = new Map<string, ScriptManifest>();\n drawnByExportName.set(\"default\", artefacts.manifest);\n for (const sibling of artefacts.siblings) {\n if (sibling.exportName !== undefined) {\n drawnByExportName.set(sibling.exportName, sibling);\n }\n }\n return Object.freeze({\n sourcePath: absolute,\n manifest: artefacts.manifest,\n drawnByExportName,\n moduleSource: artefacts.moduleSource,\n rewrittenSource,\n hash,\n transitiveProducers: Object.freeze(\n (artefacts.transitiveProducers ?? []).slice(),\n ),\n });\n } finally {\n ancestryByAbsolute.delete(absolute);\n }\n })();\n\n cache.set(absolute, pending);\n insertionOrder.push(absolute);\n while (insertionOrder.length > LRU_LIMIT) {\n const oldest = insertionOrder.shift();\n if (oldest !== undefined && oldest !== absolute) {\n cache.delete(oldest);\n }\n }\n return pending;\n }\n\n return resolveCrossFileProducer;\n}\n\n/**\n * Compute the stable 12-hex-char identifier the bundler uses to namespace\n * each inlined producer's locals (`__producer_<hash>__default`,\n * `__producer_<hash>__<name>`). Driven off the producer's absolute path\n * so two consumers in the same project share the same identifier for\n * the same producer — esbuild's tree-shake then dedups the inline.\n *\n * @since 0.7\n * @stable\n * @example\n * // const id = hashSourcePath(\"/repo/src/base.chart.ts\");\n * // id === \"a1b2c3d4e5f6\"\n * const fn: typeof hashSourcePath = hashSourcePath;\n * void fn;\n */\nexport function hashSourcePath(absolutePath: string): string {\n const normalised = absolutePath.replace(/\\\\/g, \"/\");\n return createHash(\"sha256\").update(normalised).digest(\"hex\").slice(0, 12);\n}\n\n/**\n * Rewrite a producer's printed TS source into a self-contained IIFE\n * block that exposes one `__producer_<hash>__default` const. Strips\n * `@invinite-org/chartlang-core` imports (the consumer already pulled\n * the symbols in), lowers cross-file `.chart` imports to\n * `const <name> = __producer_<nestedhash>__default;` so the inlined\n * dep is read from the consumer's already-inlined namespace, replaces\n * `export default <X>` with `return <X>;`, and wraps everything in an\n * IIFE so private same-file consts stay scoped — preventing name\n * collisions across producers that happen to share local identifiers.\n *\n * `specifierToHash` maps the producer's own cross-file import\n * specifiers to the nested producers' stable hashes. Empty when the\n * producer has no cross-file imports.\n *\n * @since 0.7\n * @stable\n * @example\n * // const src = rewriteProducerSource(\n * // 'export default defineIndicator({});',\n * // 'a1b2c3',\n * // new Map(),\n * // );\n * // src includes \"const __producer_a1b2c3__default = (() => { ... })();\"\n * const fn: typeof rewriteProducerSource = rewriteProducerSource;\n * void fn;\n */\nexport function rewriteProducerSource(\n source: string,\n hash: string,\n specifierToHash: ReadonlyMap<string, string> = new Map(),\n): string {\n const sourceFile = ts.createSourceFile(\n \"producer.ts\",\n source,\n ts.ScriptTarget.ES2022,\n true,\n ts.ScriptKind.TS,\n );\n const printer = ts.createPrinter({\n removeComments: false,\n newLine: ts.NewLineKind.LineFeed,\n });\n\n // Imports of `@invinite-org/chartlang-core` (and other host-supplied\n // bare specifiers) are hoisted to the top of the rewritten output as\n // top-level `import` statements so esbuild dedupes them against the\n // consumer's own imports. Without hoisting, the producer's body\n // references (`input.int(...)`, `ta.ema(...)`, etc.) would be unbound\n // when the consumer omits those symbols from its own import line —\n // a real bug surfaced by the dep-cross-file conformance scenario.\n // Producer-side `.chart` imports stay lowered inside the IIFE body\n // as `const <name> = __producer_<nestedHash>__default;` so the\n // top-level inlined producer is read from the consumer's namespace.\n const hoistedImports: string[] = [];\n const bodyLines: string[] = [];\n let defaultExpr: string | null = null;\n const fullText = sourceFile.text;\n for (const statement of sourceFile.statements) {\n if (ts.isImportDeclaration(statement)) {\n const specifier = statement.moduleSpecifier;\n /* v8 ignore next */\n if (!ts.isStringLiteral(specifier)) continue;\n const text = specifier.text;\n const nestedHash = specifierToHash.get(text);\n if (nestedHash !== undefined) {\n const clause = statement.importClause;\n const defaultName = clause?.name?.text;\n if (defaultName !== undefined) {\n bodyLines.push(`const ${defaultName} = __producer_${nestedHash}__default;`);\n }\n continue;\n }\n // Non-chart import (e.g. `@invinite-org/chartlang-core`): hoist\n // verbatim so esbuild dedupes against the consumer's imports.\n hoistedImports.push(fullText.slice(statement.getStart(sourceFile), statement.getEnd()));\n continue;\n }\n if (ts.isExportDeclaration(statement)) continue;\n if (ts.isExportAssignment(statement)) {\n defaultExpr = printer.printNode(\n ts.EmitHint.Expression,\n statement.expression,\n sourceFile,\n );\n continue;\n }\n if (ts.isVariableStatement(statement)) {\n const isExported = statement.modifiers?.some(\n (mod) => mod.kind === ts.SyntaxKind.ExportKeyword,\n );\n if (isExported === true) {\n bodyLines.push(rewriteVariableStatement(statement, hash, sourceFile, printer));\n continue;\n }\n }\n bodyLines.push(fullText.slice(statement.getStart(sourceFile), statement.getEnd()));\n }\n\n const returnLine = defaultExpr === null ? \"return undefined;\" : `return ${defaultExpr};`;\n const iife = `const __producer_${hash}__default = (() => {\\n${bodyLines.join(\"\\n\")}\\n${returnLine}\\n})();`;\n return hoistedImports.length === 0 ? iife : `${hoistedImports.join(\"\\n\")}\\n${iife}`;\n}\n\nfunction rewriteVariableStatement(\n statement: ts.VariableStatement,\n hash: string,\n sourceFile: ts.SourceFile,\n printer: ts.Printer,\n): string {\n const declarations = statement.declarationList.declarations\n .map((decl) => {\n const nameNode = decl.name;\n if (!ts.isIdentifier(nameNode)) return null;\n const initializer = decl.initializer;\n if (initializer === undefined) return null;\n const initText = printer.printNode(ts.EmitHint.Expression, initializer, sourceFile);\n return `const __producer_${hash}__${nameNode.text} = ${initText};`;\n })\n .filter((line): line is string => line !== null);\n return declarations.join(\"\\n\");\n}\n\nfunction resolveImportPath(\n importPath: string,\n fromSourcePath: string,\n rootAbsolute: string,\n): string | null {\n let normalised: string;\n if (importPath.endsWith(\".chart.ts\")) {\n normalised = importPath;\n } else if (importPath.endsWith(\".chart\")) {\n normalised = `${importPath}.ts`;\n } else {\n return null;\n }\n // `fromSourcePath` may be absolute (driven by `compileFile`'s\n // absolute resolution) or relative to the process cwd (driven by\n // `compileProject` passing posix-relative paths). Resolve against\n // cwd so both forms work.\n const fromAbsolute = isAbsolute(fromSourcePath)\n ? fromSourcePath\n : resolvePath(process.cwd(), fromSourcePath);\n const fromDir = dirname(fromAbsolute);\n const absolute = isAbsolute(normalised) ? normalised : resolvePath(fromDir, normalised);\n const rel = relative(rootAbsolute, absolute);\n if (rel.startsWith(\"..\") || isAbsolute(rel)) return null;\n return absolute;\n}\n"]}
|
package/dist/diagnostics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,CA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C,6BAA6B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACjF,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,KAAK,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE;QAC3C,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,IAAI,GAAG,CAAC;QACd,MAAM,EAAE,SAAS,GAAG,CAAC;KACxB,CAAC,CAAC;AACP,CAAC;AAED,SAAS,wBAAwB,CAAC,OAA2C;IACzE,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,MAAM,KAAK,GAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,IAAI,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","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type ts from \"typescript\";\n\n/**\n * Stable identifier for every diagnostic the compiler can emit. New codes are\n * added at the end; existing codes never change meaning so consumer-side\n * filtering stays compatible across versions.\n *\n * Phase 1 ships eight emittable codes plus Phase 4's\n * `request.security` and input-extraction codes. Phase 7 adds\n * `multiple-default-exports`, `non-const-define-binding`, and the six\n * `dep-*` codes for indicator-composition analysis (plus\n * `duplicate-output-title` for clashing `plot(value, { title })`\n * declarations in the same script).\n *\n * @since 0.1\n * @example\n * const code: CompileDiagnosticCode = \"unbounded-loop\";\n */\nexport type CompileDiagnosticCode =\n | \"unbounded-loop\"\n | \"recursion-not-allowed\"\n | \"hostile-global\"\n | \"stateful-call-inside-loop\"\n | \"stateful-call-element-access\"\n | \"request-security-interval-not-literal\"\n | \"dynamic-series-index\"\n | \"callsite-id-conflict\"\n | \"missing-default-export\"\n | \"api-version-mismatch\"\n | \"input-default-not-literal\"\n | \"unknown-input-kind\"\n | \"multiple-input-interval\"\n | \"requires-intervals-not-literal\"\n | \"alert-condition-not-literal\"\n | \"alert-condition-field-not-literal\"\n | \"lower-tf-not-lower\"\n | \"request-lower-tf-interval-not-literal\"\n | \"type-error\"\n | \"multiple-default-exports\"\n | \"non-const-define-binding\"\n | \"dep-cycle\"\n | \"dep-unknown-output\"\n | \"dep-invalid-input-override\"\n | \"dep-dynamic\"\n | \"dep-output-not-titled\"\n | \"duplicate-output-title\";\n\n/**\n * Single diagnostic the compiler emits while transforming or analysing a\n * `.chart.ts` source. The shape is intentionally small — file/line/column and\n * a stable code — so callers (CLI, editor, host) can format errors uniformly.\n *\n * `severity` distinguishes hard errors (abort `compile`) from warnings\n * (surface to the user but still produce a manifest).\n *\n * @since 0.1\n * @example\n * const d: CompileDiagnostic = {\n * severity: \"error\",\n * code: \"unbounded-loop\",\n * message: \"while loops are not allowed\",\n * file: \"demo.chart.ts\",\n * line: 5,\n * column: 1,\n * };\n */\nexport type CompileDiagnostic = {\n readonly severity: \"error\" | \"warning\";\n readonly code: CompileDiagnosticCode;\n readonly message: string;\n readonly file: string;\n readonly line: number;\n readonly column: number;\n readonly nodeText?: string;\n};\n\n/**\n * Build a frozen `CompileDiagnostic` from a TypeScript node. Reads the node's\n * starting position against the supplied source file, converts to 1-based\n * line/column, and truncates the source snippet to a single line so terminal\n * output stays compact.\n *\n * @since 0.1\n * @example\n * // Inside an analysis pass:\n * // diagnostics.push(createDiagnostic({\n * // severity: \"error\", code: \"unbounded-loop\",\n * // message: \"while loops are not allowed\",\n * // file: sourcePath, node, sourceFile,\n * // }));\n * const fake = { severity: \"error\" as const };\n * void fake;\n */\nexport function createDiagnostic(args: {\n readonly severity: \"error\" | \"warning\";\n readonly code: CompileDiagnosticCode;\n readonly message: string;\n readonly file: string;\n readonly node: ts.Node;\n readonly sourceFile: ts.SourceFile;\n readonly includeSnippet?: boolean;\n}): CompileDiagnostic {\n const { severity, code, message, file, node, sourceFile, includeSnippet } = args;\n const start = node.getStart(sourceFile);\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);\n const base = {\n severity,\n code,\n message,\n file,\n line: line + 1,\n column: character + 1,\n };\n if (includeSnippet) {\n const text = node.getText(sourceFile);\n const newlineIndex = text.indexOf(\"\\n\");\n const firstLine = newlineIndex === -1 ? text : text.slice(0, newlineIndex);\n const snippet = firstLine.length > 80 ? `${firstLine.slice(0, 77)}...` : firstLine;\n return Object.freeze({ ...base, nodeText: snippet });\n }\n return Object.freeze(base);\n}\n\n/**\n * Build a frozen `CompileDiagnostic` from a raw TypeScript `ts.Diagnostic`.\n * Used by the `compile()` pipeline to surface semantic type-checker errors\n * (TS2322, TS2345, …) under the `type-error` code. Carries the original\n * `TS<code>` numeric prefix in the message so editor consumers can route\n * to the TypeScript documentation if they want.\n *\n * Diagnostics without a `file` (global-scope, project-shape) are mapped to\n * the script's `sourcePath` at line/column `1:1` so callers always get a\n * stable location they can attribute to the user's source. The message is\n * flattened across `DiagnosticMessageChain` nodes.\n *\n * @since 0.7\n * @example\n * // const compileDiagnostic = mapTsDiagnostic(tsDiagnostic, \"demo.chart.ts\");\n * const fn: typeof mapTsDiagnostic = mapTsDiagnostic;\n * void fn;\n */\nexport function mapTsDiagnostic(diagnostic: ts.Diagnostic, sourcePath: string): CompileDiagnostic {\n const message = flattenDiagnosticMessage(diagnostic.messageText);\n const file = diagnostic.file;\n if (file === undefined || diagnostic.start === undefined) {\n return Object.freeze({\n severity: \"error\",\n code: \"type-error\",\n message: `TS${diagnostic.code}: ${message}`,\n file: sourcePath,\n line: 1,\n column: 1,\n });\n }\n const { line, character } = file.getLineAndCharacterOfPosition(diagnostic.start);\n return Object.freeze({\n severity: \"error\",\n code: \"type-error\",\n message: `TS${diagnostic.code}: ${message}`,\n file: sourcePath,\n line: line + 1,\n column: character + 1,\n });\n}\n\nfunction flattenDiagnosticMessage(message: string | ts.DiagnosticMessageChain): string {\n if (typeof message === \"string\") return message;\n const parts: string[] = [message.messageText];\n const next = message.next;\n if (next === undefined) return parts.join(\" \");\n const queue: ReadonlyArray<ts.DiagnosticMessageChain> = next;\n for (const chain of queue) {\n parts.push(flattenDiagnosticMessage(chain));\n }\n return parts.join(\" \");\n}\n"]}
|
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;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"}
|
|
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","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nexport {\n CompileError,\n compile,\n compileFile,\n compileProject,\n transformAndAnalyse,\n walkChartFiles,\n writeAtomic,\n} from \"./api.js\";\nexport type {\n CompileFileOptions,\n CompileOptions,\n CompiledScript,\n TransformAndAnalyseOptions,\n TransformAndAnalyseResult,\n} from \"./api.js\";\nexport { bundleModule, formatManifestAssignment } from \"./bundle.js\";\nexport type {\n BundleModuleOptions,\n BundleModuleResult,\n InlinedProducer,\n} from \"./bundle.js\";\nexport {\n createProducerResolver,\n hashSourcePath,\n rewriteProducerSource,\n} from \"./dependency/index.js\";\nexport type {\n CompiledProducerArtefacts,\n CompileProducerCallback,\n CreateProducerResolverOptions,\n ProducerCompiled,\n ResolveCrossFileProducer,\n} from \"./dependency/index.js\";\nexport type { CompileDiagnostic, CompileDiagnosticCode } from \"./diagnostics.js\";\nexport { emitTypes } from \"./typesEmit.js\";\nexport type { EmitTypesOptions } from \"./typesEmit.js\";\nexport { resolveCalleeName } from \"./transformers/resolveCallee.js\";\n"]}
|
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;AAe/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAC,IAuB7B;IACG,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9D,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1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":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type {\n AlertConditionDefinition,\n CapabilityId,\n DependencyDeclaration,\n OutputDeclaration,\n PlotSlotDescriptor,\n ScriptManifest,\n} from \"@invinite-org/chartlang-core\";\n\ntype ValueFormat = \"price\" | \"volume\" | \"percent\" | \"compact\";\ntype ScaleAxis = \"price\" | \"left\" | \"right\" | \"new\";\ntype ManifestInputDescriptors = Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n\n/**\n * Build a recursively-frozen `ScriptManifest` from the compiler's\n * extraction passes. Every array, every nested record, and the outer\n * object itself are frozen so the runtime can structurally clone the\n * manifest without worrying about post-build mutation.\n *\n * @since 0.1\n * @example\n * // const manifest = buildManifest({\n * // name: \"EMA(20)\", kind: \"indicator\",\n * // capabilities: [\"alerts\", \"indicators\"],\n * // requestedIntervals: [], userPickableInterval: false,\n * // seriesCapacities: {}, maxLookback: 0, inputs: {},\n * // });\n * const fn: typeof buildManifest = buildManifest;\n * void fn;\n */\nexport function buildManifest(args: {\n readonly name: string;\n readonly kind: \"indicator\" | \"drawing\" | \"alert\" | \"alertCondition\";\n readonly capabilities: ReadonlyArray<CapabilityId>;\n readonly requestedIntervals: ReadonlyArray<string>;\n readonly userPickableInterval: boolean;\n readonly seriesCapacities: Readonly<Record<string, number>>;\n readonly maxLookback: number;\n readonly inputs: ManifestInputDescriptors;\n readonly overlay?: boolean;\n readonly maxBarsBack?: number;\n readonly format?: ValueFormat;\n readonly precision?: number;\n readonly scale?: ScaleAxis;\n readonly requiresIntervals?: ReadonlyArray<string>;\n readonly shortName?: string;\n readonly alertConditions?: ReadonlyArray<AlertConditionDefinition>;\n readonly dependencies?: ReadonlyArray<DependencyDeclaration>;\n readonly outputs?: ReadonlyArray<OutputDeclaration>;\n readonly plots?: ReadonlyArray<PlotSlotDescriptor>;\n readonly exportName?: string;\n readonly isDrawn?: boolean;\n readonly siblings?: ReadonlyArray<ScriptManifest>;\n}): ScriptManifest {\n const capabilities = Object.freeze(args.capabilities.slice());\n const requestedIntervals = Object.freeze(args.requestedIntervals.slice());\n const seriesCapacities = Object.freeze({ ...args.seriesCapacities });\n const inputEntries = Object.entries(args.inputs).map(\n ([key, value]) => [key, Object.freeze({ ...value })] as const,\n );\n const inputs = Object.freeze(Object.fromEntries(inputEntries));\n const scriptInputs = inputs as ScriptManifest[\"inputs\"];\n const requiresIntervals =\n args.requiresIntervals === undefined\n ? undefined\n : Object.freeze(args.requiresIntervals.slice());\n const alertConditions =\n args.alertConditions === undefined\n ? undefined\n : Object.freeze(\n args.alertConditions.map((condition) =>\n Object.freeze({\n id: condition.id,\n title: condition.title,\n description: condition.description,\n defaultMessage: condition.defaultMessage,\n }),\n ),\n );\n const dependencies =\n args.dependencies === undefined || args.dependencies.length === 0\n ? undefined\n : Object.freeze(\n args.dependencies.map((dep) =>\n Object.freeze({\n localId: dep.localId,\n producerName: dep.producerName,\n producerSourcePath: dep.producerSourcePath,\n producerExportName: dep.producerExportName,\n effectiveInputs: Object.freeze({ ...dep.effectiveInputs }),\n outputs: Object.freeze(\n dep.outputs.map((o) =>\n Object.freeze({ title: o.title, kind: o.kind }),\n ),\n ),\n isDrawn: dep.isDrawn,\n }),\n ),\n );\n const outputs =\n args.outputs === undefined || args.outputs.length === 0\n ? undefined\n : Object.freeze(\n args.outputs.map((o) => Object.freeze({ title: o.title, kind: o.kind })),\n );\n const plots =\n args.plots === undefined || args.plots.length === 0\n ? undefined\n : Object.freeze(args.plots.map((s) => Object.freeze({ ...s })));\n const siblings =\n args.siblings === undefined || args.siblings.length === 0\n ? undefined\n : Object.freeze(args.siblings.slice());\n return Object.freeze({\n apiVersion: 1 as const,\n kind: args.kind,\n name: args.name,\n inputs: scriptInputs,\n capabilities,\n requestedIntervals,\n userPickableInterval: args.userPickableInterval,\n seriesCapacities,\n maxLookback: args.maxLookback,\n ...(args.overlay === undefined ? {} : { overlay: args.overlay }),\n ...(args.maxBarsBack === undefined ? {} : { maxBarsBack: args.maxBarsBack }),\n ...(args.format === undefined ? {} : { format: args.format }),\n ...(args.precision === undefined ? {} : { precision: args.precision }),\n ...(args.scale === undefined ? {} : { scale: args.scale }),\n ...(requiresIntervals === undefined ? {} : { requiresIntervals }),\n ...(args.shortName === undefined ? {} : { shortName: args.shortName }),\n ...(alertConditions === undefined ? {} : { alertConditions }),\n ...(dependencies === undefined ? {} : { dependencies }),\n ...(outputs === undefined ? {} : { outputs }),\n ...(plots === undefined ? {} : { plots }),\n ...(args.exportName === undefined ? {} : { exportName: args.exportName }),\n ...(args.isDrawn === undefined ? {} : { isDrawn: args.isDrawn }),\n ...(siblings === undefined ? {} : { siblings }),\n });\n}\n"]}
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACtD,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport ts from \"typescript\";\n\n/**\n * Virtual on-disk path the in-memory `@invinite-org/chartlang-core` ambient\n * declaration file is served from. Kept stable so the analysis passes can\n * detect callee declarations coming from core (vs. user-shadowed names).\n *\n * @since 0.1\n * @example\n * import { CORE_MODULE_PATH } from \"@invinite-org/chartlang-compiler/program\";\n * void CORE_MODULE_PATH;\n */\nexport const CORE_MODULE_PATH = \"/__chartlang__/core.d.ts\";\n\n/**\n * Ambient `.d.ts` shim covering the exact `@invinite-org/chartlang-core`\n * surface the compiler needs for symbol resolution. Lives in-memory so the\n * compiler is deterministic and host-machine independent — no on-disk\n * resolution of `workspace:*` packages required.\n *\n * The shim mirrors the runtime types; it does NOT carry the throw-sentinel\n * bodies the real callable holes ship. That doesn't matter — the compiler\n * only does static analysis; it never executes script source.\n */\nconst CORE_AMBIENT_SHIM = `\ndeclare module \"@invinite-org/chartlang-core\" {\n export type Time = number;\n export type Price = number;\n export type Volume = number;\n export type Color = string;\n export type GradientStop = Readonly<{ at: number; color: Color }>;\n export type LineStyle = \"solid\" | \"dashed\" | \"dotted\";\n export type AlertSeverity = \"info\" | \"warning\" | \"critical\";\n export type CapabilityId = \"indicators\" | \"drawings\" | \"alerts\" | \"alertConditions\";\n export type IntervalDescriptor = Readonly<{\n readonly value: string;\n readonly label: string;\n readonly group: string;\n readonly intervalSeconds?: number;\n }>;\n export type ValueFormat = \"price\" | \"volume\" | \"percent\" | \"compact\";\n export type ScaleAxis = \"price\" | \"left\" | \"right\" | \"new\";\n export type DrawingCounts = {\n readonly lines: number;\n readonly labels: number;\n readonly boxes: number;\n readonly polylines: number;\n readonly other: number;\n };\n export type ScriptOverrides = Readonly<{\n maxBarsBack?: number;\n format?: ValueFormat;\n precision?: number;\n scale?: ScaleAxis;\n requiresIntervals?: ReadonlyArray<string>;\n shortName?: string;\n }>;\n export type BarViewport = Readonly<{\n readonly fromTime: Time;\n readonly toTime: Time;\n }>;\n export type Bar = {\n readonly time: Time;\n readonly open: Price;\n readonly high: Price;\n readonly low: Price;\n readonly close: Price;\n readonly volume: Volume;\n readonly symbol: string;\n readonly interval: string;\n readonly hl2: Price;\n readonly hlc3: Price;\n readonly ohlc4: Price;\n readonly hlcc4: Price;\n readonly viewport?: BarViewport;\n };\n export type Series<T> = {\n readonly current: T;\n readonly [n: number]: T;\n readonly length: number;\n };\n /**\n * A \\`ta.*\\` source-position argument. The runtime\n * (\\`packages/runtime/src/ta/lib/sourceValue.ts\\`) accepts either a\n * series reference or a scalar; the script-author surface mirrors\n * that contract so \\`ta.ema(bar.close, 12)\\` (scalar) and\n * \\`ta.ema(other, 12)\\` (series) both typecheck.\n */\n export type ScalarOrSeries = Series<number> | number;\n export type SmaOpts = Readonly<{ offset?: number }>;\n export type EmaOpts = Readonly<{ offset?: number }>;\n export type StdevOpts = Readonly<{ biased?: boolean; offset?: number }>;\n export type BbOpts = Readonly<{ multiplier?: number; offset?: number }>;\n export type RsiOpts = Readonly<{ offset?: number }>;\n export type MacdOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type AtrOpts = Readonly<{ offset?: number }>;\n export type CrossoverOpts = Readonly<{ offset?: number }>;\n export type CrossunderOpts = Readonly<{ offset?: number }>;\n export type HighestOpts = Readonly<{ offset?: number }>;\n export type LowestOpts = Readonly<{ offset?: number }>;\n export type ChangeOpts = Readonly<{ length?: number; offset?: number }>;\n export type PlotLineStyle = \"line\" | \"step\" | \"dashed\" | \"circles\" | \"cross\";\n export type WmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type VwmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type HmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type SmmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type DemaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type TemaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type KamaOpts = Readonly<{\n length?: number;\n fastLength?: number;\n slowLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type AlmaOpts = Readonly<{\n offset?: number;\n sigma?: number;\n barShift?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type LsmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type McginleyOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type MaTypeNoVolume = \"sma\" | \"ema\" | \"wma\" | \"smma\";\n export type MaRibbonOpts = Readonly<{\n lengths?: ReadonlyArray<number>;\n maType?: MaTypeNoVolume;\n offset?: number;\n outputs?: Readonly<Record<string, { lineStyle?: PlotLineStyle }>>;\n }>;\n export type MaRibbonResult = Readonly<Record<string, Series<number>>>;\n export type AoOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type CmoOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type MomentumOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type RocOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type CciOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type StochOpts = Readonly<{\n kLength?: number;\n kSmoothing?: number;\n dLength?: number;\n offset?: number;\n }>;\n export type WilliamsROpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type StochResult = Readonly<{\n k: Series<number>;\n d: Series<number>;\n }>;\n export type StochRsiOpts = Readonly<{\n rsiLength?: number;\n stochLength?: number;\n kSmoothing?: number;\n dSmoothing?: number;\n offset?: number;\n }>;\n export type StochRsiResult = Readonly<{\n k: Series<number>;\n d: Series<number>;\n }>;\n export type UltimateOscOpts = Readonly<{\n shortLength?: number;\n mediumLength?: number;\n longLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type CoppockOpts = Readonly<{\n roc1Length?: number;\n roc2Length?: number;\n wmaLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type PpoOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type PpoResult = Readonly<{\n ppo: Series<number>;\n signal: Series<number>;\n hist: Series<number>;\n }>;\n export type DpoOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type ConnorsRsiOpts = Readonly<{\n rsiLength?: number;\n streakLength?: number;\n rocLength?: number;\n offset?: number;\n }>;\n export type KstOpts = Readonly<{\n roc1Length?: number;\n roc2Length?: number;\n roc3Length?: number;\n roc4Length?: number;\n roc1Smooth?: number;\n roc2Smooth?: number;\n roc3Smooth?: number;\n roc4Smooth?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type KstResult = Readonly<{\n kst: Series<number>;\n signal: Series<number>;\n }>;\n export type FisherOpts = Readonly<{ offset?: number }>;\n export type FisherResult = Readonly<{\n fisher: Series<number>;\n trigger: Series<number>;\n }>;\n export type KlingerOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type KlingerResult = Readonly<{\n klinger: Series<number>;\n signal: Series<number>;\n }>;\n export type RvgiOpts = Readonly<{\n length?: number;\n offset?: number;\n }>;\n export type RvgiResult = Readonly<{\n rvgi: Series<number>;\n signal: Series<number>;\n }>;\n export type AroonOpts = Readonly<{\n offset?: number;\n outputs?: Readonly<Record<\"up\" | \"down\", { lineStyle?: PlotLineStyle }>>;\n }>;\n export type AroonOscOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type VolOpts = Readonly<{ offset?: number }>;\n export type VwapOpts = Readonly<{\n source?: \"hlc3\" | \"close\" | \"hl2\" | \"ohlc4\" | \"hlcc4\";\n offset?: number;\n }>;\n export type AnchoredVwapOpts = Readonly<{\n source?: \"hlc3\" | \"close\" | \"hl2\" | \"ohlc4\" | \"hlcc4\";\n offset?: number;\n }>;\n export type VisibleRangeVolumeProfileOpts = Readonly<{\n rowSize?: number;\n valueAreaPct?: number;\n offset?: number;\n bucketColor?: string;\n }>;\n export type VisibleRangeVolumeProfileResult = Readonly<{\n poc: Series<number>;\n valHigh: Series<number>;\n valLow: Series<number>;\n }>;\n export type AnchoredVolumeProfileOpts = Readonly<{\n anchor: Time;\n rowSize?: number;\n valueAreaPct?: number;\n offset?: number;\n bucketColor?: string;\n }>;\n export type SessionVolumeProfileOpts = Readonly<{\n rowSize?: number;\n valueAreaPct?: number;\n offset?: number;\n bucketColor?: string;\n sessionStart?: Time;\n }>;\n export type SessionVolumeProfileResult = Readonly<{\n poc: Series<number>;\n valHigh: Series<number>;\n valLow: Series<number>;\n buckets: ReadonlyArray<Readonly<{ price: number; volume: number; color?: string }>>;\n }>;\n export type FixedRangeVolumeProfileOpts = Readonly<{\n from: Time;\n to: Time;\n rowSize?: number;\n valueAreaPct?: number;\n offset?: number;\n bucketColor?: string;\n }>;\n export type FixedRangeVolumeProfileResult = Readonly<{\n poc: Series<number>;\n valHigh: Series<number>;\n valLow: Series<number>;\n buckets: ReadonlyArray<Readonly<{ price: number; volume: number; color?: string }>>;\n }>;\n export type AnchoredVolumeProfileResult = Readonly<{\n poc: Series<number>;\n valHigh: Series<number>;\n valLow: Series<number>;\n buckets: ReadonlyArray<Readonly<{ price: number; volume: number; color?: string }>>;\n }>;\n export type ObvOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type AdlOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type BopOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type CmfOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type ChaikinOscOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n offset?: number;\n }>;\n export type MfiOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type NetVolumeOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type PvoOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type PvoResult = Readonly<{\n pvo: Series<number>;\n signal: Series<number>;\n hist: Series<number>;\n }>;\n export type PvtOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type EomOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type NviOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type PviOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type PsarOpts = Readonly<{\n accelerationStart?: number;\n accelerationStep?: number;\n accelerationMax?: number;\n offset?: number;\n }>;\n export type PsarResult = Readonly<{\n sar: Series<number>;\n direction: Series<number>;\n }>;\n export type SupertrendOpts = Readonly<{\n length?: number;\n multiplier?: number;\n offset?: number;\n }>;\n export type SupertrendResult = Readonly<{\n line: Series<number>;\n direction: Series<number>;\n }>;\n export type ChandelierOpts = Readonly<{\n length?: number;\n multiplier?: number;\n offset?: number;\n }>;\n export type ChandelierResult = Readonly<{\n long: Series<number>;\n short: Series<number>;\n }>;\n export type ChandeKrollStopOpts = Readonly<{\n length?: number;\n multiplier?: number;\n smoothingLength?: number;\n offset?: number;\n }>;\n export type ChandeKrollStopResult = Readonly<{\n long: Series<number>;\n short: Series<number>;\n }>;\n export type WilliamsFractalOpts = Readonly<{\n length?: number;\n offset?: number;\n }>;\n export type WilliamsFractalResult = Readonly<{\n up: Series<number>;\n down: Series<number>;\n }>;\n export type ZigZagOpts = Readonly<{\n deviation?: number;\n depth?: number;\n offset?: number;\n }>;\n export type ZigZagResult = Readonly<{\n value: Series<number>;\n direction: Series<number>;\n }>;\n export type PivotsHighLowOpts = Readonly<{\n leftLength?: number;\n rightLength?: number;\n offset?: number;\n }>;\n export type PivotsHighLowResult = Readonly<{\n high: Series<number>;\n low: Series<number>;\n }>;\n export type PivotsStandardSystem = \"classic\" | \"fibonacci\" | \"camarilla\" | \"woodie\";\n export type PivotsStandardOpts = Readonly<{\n system?: PivotsStandardSystem;\n offset?: number;\n }>;\n export type PivotsStandardResult = Readonly<{\n pp: Series<number>;\n r1: Series<number>;\n s1: Series<number>;\n r2: Series<number>;\n s2: Series<number>;\n r3: Series<number>;\n s3: Series<number>;\n }>;\n export type VolatilityStopOpts = Readonly<{\n length?: number;\n multiplier?: number;\n offset?: number;\n }>;\n export type VolatilityStopResult = Readonly<{\n value: Series<number>;\n direction: Series<number>;\n }>;\n export type BbPercentBOpts = Readonly<{\n multiplier?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type BbwOpts = Readonly<{\n multiplier?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type DonchianOpts = Readonly<{\n offset?: number;\n outputs?: Readonly<\n Record<\"upper\" | \"middle\" | \"lower\", { lineStyle?: PlotLineStyle }>\n >;\n }>;\n export type DonchianResult = Readonly<{\n upper: Series<number>;\n middle: Series<number>;\n lower: Series<number>;\n }>;\n export type KeltnerOpts = Readonly<{\n length?: number;\n multiplier?: number;\n maType?: MaTypeNoVolume;\n offset?: number;\n outputs?: Readonly<\n Record<\"upper\" | \"middle\" | \"lower\", { lineStyle?: PlotLineStyle }>\n >;\n }>;\n export type KeltnerResult = Readonly<{\n upper: Series<number>;\n middle: Series<number>;\n lower: Series<number>;\n }>;\n export type EnvelopeOpts = Readonly<{\n length?: number;\n percent?: number;\n maType?: MaTypeNoVolume;\n offset?: number;\n }>;\n export type EnvelopeResult = Readonly<{\n upper: Series<number>;\n middle: Series<number>;\n lower: Series<number>;\n }>;\n export type ChopOpts = Readonly<{\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type HvOpts = Readonly<{\n annualisationFactor?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type RviOpts = Readonly<{\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type MassIndexOpts = Readonly<{\n emaLength?: number;\n sumLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type AroonResult = Readonly<{\n up: Series<number>;\n down: Series<number>;\n }>;\n export type BbResult = Readonly<{\n upper: Series<number>;\n middle: Series<number>;\n lower: Series<number>;\n }>;\n export type MacdResult = Readonly<{\n macd: Series<number>;\n signal: Series<number>;\n hist: Series<number>;\n }>;\n export type AdxOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type DmiOpts = Readonly<{\n offset?: number;\n outputs?: Readonly<\n Record<\"plusDi\" | \"minusDi\", { lineStyle?: PlotLineStyle }>\n >;\n }>;\n export type DmiResult = Readonly<{\n plusDi: Series<number>;\n minusDi: Series<number>;\n }>;\n export type TrixOpts = Readonly<{ offset?: number; signalLength?: number }>;\n export type TrixResult = Readonly<{\n trix: Series<number>;\n signal: Series<number>;\n }>;\n export type VortexOpts = Readonly<{ offset?: number }>;\n export type VortexResult = Readonly<{\n plus: Series<number>;\n minus: Series<number>;\n }>;\n export type TrendStrengthIndexOpts = Readonly<{\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type IchimokuOpts = Readonly<{\n conversionLength?: number;\n baseLength?: number;\n leadingSpanBLength?: number;\n displacement?: number;\n offset?: number;\n outputs?: Readonly<\n Record<\n \"tenkan\" | \"kijun\" | \"senkouA\" | \"senkouB\" | \"chikou\",\n { lineStyle?: PlotLineStyle }\n >\n >;\n }>;\n export type IchimokuResult = Readonly<{\n tenkan: Series<number>;\n kijun: Series<number>;\n senkouA: Series<number>;\n senkouB: Series<number>;\n chikou: Series<number>;\n }>;\n export type MedianOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type AdrOpts = Readonly<{\n length?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type UlcerIndexOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type PmoOpts = Readonly<{\n length?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type PmoResult = Readonly<{\n pmo: Series<number>;\n signal: Series<number>;\n }>;\n export type SmiOpts = Readonly<{\n kLength?: number;\n dLength?: number;\n smoothLength?: number;\n offset?: number;\n }>;\n export type SmiResult = Readonly<{\n smi: Series<number>;\n signal: Series<number>;\n }>;\n export type TsiOpts = Readonly<{\n shortLength?: number;\n longLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type TsiResult = Readonly<{\n tsi: Series<number>;\n signal: Series<number>;\n }>;\n export type ValuewhenOpts = Readonly<{ offset?: number }>;\n export type BarssinceOpts = Readonly<{ offset?: number }>;\n export type TaNamespace = {\n sma(source: ScalarOrSeries, length: number, opts?: SmaOpts): Series<number>;\n ema(source: ScalarOrSeries, length: number, opts?: EmaOpts): Series<number>;\n stdev(source: ScalarOrSeries, length: number, opts?: StdevOpts): Series<number>;\n bb(source: ScalarOrSeries, length: number, opts?: BbOpts): BbResult;\n rsi(source: ScalarOrSeries, length: number, opts?: RsiOpts): Series<number>;\n macd(source: ScalarOrSeries, opts?: MacdOpts): MacdResult;\n atr(length: number, opts?: AtrOpts): Series<number>;\n crossover(\n a: ScalarOrSeries,\n b: ScalarOrSeries,\n opts?: CrossoverOpts,\n ): Series<boolean>;\n crossunder(\n a: ScalarOrSeries,\n b: ScalarOrSeries,\n opts?: CrossunderOpts,\n ): Series<boolean>;\n nz(value: number, replacement?: number): number;\n highest(source: ScalarOrSeries, length: number, opts?: HighestOpts): Series<number>;\n lowest(source: ScalarOrSeries, length: number, opts?: LowestOpts): Series<number>;\n change(source: ScalarOrSeries, opts?: ChangeOpts): Series<number>;\n valuewhen(\n condition: Series<boolean>,\n source: ScalarOrSeries,\n occurrence?: number,\n opts?: ValuewhenOpts,\n ): Series<number>;\n barssince(condition: Series<boolean>, opts?: BarssinceOpts): Series<number>;\n wma(source: ScalarOrSeries, length: number, opts?: WmaOpts): Series<number>;\n vwma(source: ScalarOrSeries, length: number, opts?: VwmaOpts): Series<number>;\n hma(source: ScalarOrSeries, length: number, opts?: HmaOpts): Series<number>;\n smma(source: ScalarOrSeries, length: number, opts?: SmmaOpts): Series<number>;\n dema(source: ScalarOrSeries, length: number, opts?: DemaOpts): Series<number>;\n tema(source: ScalarOrSeries, length: number, opts?: TemaOpts): Series<number>;\n kama(source: ScalarOrSeries, opts?: KamaOpts): Series<number>;\n alma(source: ScalarOrSeries, length: number, opts?: AlmaOpts): Series<number>;\n lsma(source: ScalarOrSeries, length: number, opts?: LsmaOpts): Series<number>;\n mcginley(source: ScalarOrSeries, length: number, opts?: McginleyOpts): Series<number>;\n maRibbon(source: ScalarOrSeries, opts?: MaRibbonOpts): MaRibbonResult;\n ao(opts?: AoOpts): Series<number>;\n cmo(source: ScalarOrSeries, length: number, opts?: CmoOpts): Series<number>;\n momentum(source: ScalarOrSeries, length: number, opts?: MomentumOpts): Series<number>;\n roc(source: ScalarOrSeries, length: number, opts?: RocOpts): Series<number>;\n cci(source: ScalarOrSeries, length: number, opts?: CciOpts): Series<number>;\n stoch(opts?: StochOpts): StochResult;\n stochRsi(source: ScalarOrSeries, opts?: StochRsiOpts): StochRsiResult;\n ultimateOsc(opts?: UltimateOscOpts): Series<number>;\n coppock(source: ScalarOrSeries, opts?: CoppockOpts): Series<number>;\n williamsR(length: number, opts?: WilliamsROpts): Series<number>;\n aroon(length: number, opts?: AroonOpts): AroonResult;\n aroonOsc(length: number, opts?: AroonOscOpts): Series<number>;\n median(source: ScalarOrSeries, length: number, opts?: MedianOpts): Series<number>;\n adr(opts?: AdrOpts): Series<number>;\n ulcerIndex(\n source: ScalarOrSeries,\n length: number,\n opts?: UlcerIndexOpts,\n ): Series<number>;\n pmo(source: ScalarOrSeries, opts?: PmoOpts): PmoResult;\n smi(opts?: SmiOpts): SmiResult;\n tsi(source: ScalarOrSeries, opts?: TsiOpts): TsiResult;\n vol(opts?: VolOpts): Series<number>;\n vwap(opts?: VwapOpts): Series<number>;\n anchoredVwap(anchorTime: number, opts?: AnchoredVwapOpts): Series<number>;\n anchoredVolumeProfile(opts: AnchoredVolumeProfileOpts): AnchoredVolumeProfileResult;\n fixedRangeVolumeProfile(opts: FixedRangeVolumeProfileOpts): FixedRangeVolumeProfileResult;\n sessionVolumeProfile(opts?: SessionVolumeProfileOpts): SessionVolumeProfileResult;\n visibleRangeVolumeProfile(\n opts?: VisibleRangeVolumeProfileOpts,\n ): VisibleRangeVolumeProfileResult;\n obv(opts?: ObvOpts): Series<number>;\n adl(opts?: AdlOpts): Series<number>;\n bop(opts?: BopOpts): Series<number>;\n cmf(length: number, opts?: CmfOpts): Series<number>;\n chaikinOsc(opts?: ChaikinOscOpts): Series<number>;\n mfi(length: number, opts?: MfiOpts): Series<number>;\n netVolume(opts?: NetVolumeOpts): Series<number>;\n pvo(opts?: PvoOpts): PvoResult;\n pvt(opts?: PvtOpts): Series<number>;\n eom(length: number, opts?: EomOpts): Series<number>;\n nvi(opts?: NviOpts): Series<number>;\n pvi(opts?: PviOpts): Series<number>;\n psar(opts?: PsarOpts): PsarResult;\n supertrend(opts?: SupertrendOpts): SupertrendResult;\n chandelier(opts?: ChandelierOpts): ChandelierResult;\n chandeKrollStop(opts?: ChandeKrollStopOpts): ChandeKrollStopResult;\n williamsFractal(opts?: WilliamsFractalOpts): WilliamsFractalResult;\n zigZag(opts?: ZigZagOpts): ZigZagResult;\n pivotsHighLow(opts?: PivotsHighLowOpts): PivotsHighLowResult;\n pivotsStandard(opts?: PivotsStandardOpts): PivotsStandardResult;\n volatilityStop(opts?: VolatilityStopOpts): VolatilityStopResult;\n bbPercentB(\n source: ScalarOrSeries,\n length: number,\n opts?: BbPercentBOpts,\n ): Series<number>;\n bbw(source: ScalarOrSeries, length: number, opts?: BbwOpts): Series<number>;\n donchian(length: number, opts?: DonchianOpts): DonchianResult;\n keltner(opts?: KeltnerOpts): KeltnerResult;\n envelope(source: ScalarOrSeries, opts?: EnvelopeOpts): EnvelopeResult;\n chop(length: number, opts?: ChopOpts): Series<number>;\n historicalVolatility(\n source: ScalarOrSeries,\n length: number,\n opts?: HvOpts,\n ): Series<number>;\n rvi(source: ScalarOrSeries, length: number, opts?: RviOpts): Series<number>;\n massIndex(opts?: MassIndexOpts): Series<number>;\n ppo(source: ScalarOrSeries, opts?: PpoOpts): PpoResult;\n dpo(source: ScalarOrSeries, length: number, opts?: DpoOpts): Series<number>;\n connorsRsi(source: ScalarOrSeries, opts?: ConnorsRsiOpts): Series<number>;\n kst(source: ScalarOrSeries, opts?: KstOpts): KstResult;\n fisher(length: number, opts?: FisherOpts): FisherResult;\n klinger(opts?: KlingerOpts): KlingerResult;\n rvgi(opts?: RvgiOpts): RvgiResult;\n adx(length: number, opts?: AdxOpts): Series<number>;\n dmi(length: number, opts?: DmiOpts): DmiResult;\n trix(source: ScalarOrSeries, length: number, opts?: TrixOpts): TrixResult;\n vortex(length: number, opts?: VortexOpts): VortexResult;\n trendStrengthIndex(\n source: ScalarOrSeries,\n length: number,\n opts?: TrendStrengthIndexOpts,\n ): Series<number>;\n ichimoku(opts?: IchimokuOpts): IchimokuResult;\n };\n export const ta: TaNamespace;\n export type PlotKind =\n | \"line\"\n | \"step-line\"\n | \"horizontal-line\"\n | \"histogram\"\n | \"area\"\n | \"filled-band\"\n | \"label\"\n | \"marker\"\n | \"shape\"\n | \"character\"\n | \"arrow\"\n | \"candle-override\"\n | \"bar-override\"\n | \"bg-color\"\n | \"bar-color\"\n | \"horizontal-histogram\";\n export type PlotGlyphShape =\n | \"circle\"\n | \"triangle-up\"\n | \"triangle-down\"\n | \"square\"\n | \"diamond\";\n export type PlotShapeGlyph = PlotGlyphShape | \"cross\" | \"xcross\" | \"flag\";\n export type PlotLocation = \"above\" | \"below\" | \"absolute\";\n export type HorizontalHistogramBucket = Readonly<{\n readonly price: number;\n readonly volume: number;\n readonly color?: Color;\n }>;\n export type PlotOptsStyle =\n | { readonly kind: \"line\" }\n | { readonly kind: \"step-line\" }\n | { readonly kind: \"horizontal-line\" }\n | { readonly kind: \"histogram\"; readonly baseline?: number }\n | {\n readonly kind: \"marker\";\n readonly shape: PlotGlyphShape;\n readonly size: number;\n }\n | {\n readonly kind: \"shape\";\n readonly shape: PlotShapeGlyph;\n readonly size: number;\n readonly location?: PlotLocation;\n }\n | {\n readonly kind: \"character\";\n readonly char: string;\n readonly size: number;\n readonly location?: PlotLocation;\n }\n | { readonly kind: \"arrow\"; readonly direction: \"up\" | \"down\"; readonly size: number }\n | {\n readonly kind: \"candle-override\";\n readonly bull: Color;\n readonly bear: Color;\n readonly doji?: Color;\n }\n | { readonly kind: \"bar-override\"; readonly color: Color }\n | { readonly kind: \"bg-color\"; readonly color: Color; readonly transp?: number }\n | { readonly kind: \"bar-color\"; readonly color: Color }\n | {\n readonly kind: \"horizontal-histogram\";\n readonly buckets: ReadonlyArray<HorizontalHistogramBucket>;\n };\n export type PlotOpts = Readonly<{\n color?: Color;\n title?: string;\n lineWidth?: number;\n lineStyle?: LineStyle;\n pane?: \"overlay\" | \"new\" | string;\n style?: PlotOptsStyle;\n }>;\n export type HLineOpts = Readonly<{\n color?: Color;\n title?: string;\n lineWidth?: number;\n lineStyle?: LineStyle;\n pane?: \"overlay\" | \"new\" | string;\n }>;\n export function plot(value: number | Series<number>, opts?: PlotOpts): void;\n export function hline(price: number, opts?: HLineOpts): void;\n export type JsonValue =\n | null\n | boolean\n | number\n | string\n | ReadonlyArray<JsonValue>\n | { readonly [k: string]: JsonValue };\n export type StreamSnapshot = Readonly<{\n interval: string;\n headIndex: number;\n filled: number;\n buffers: Readonly<{\n time: ReadonlyArray<number | null>;\n open: ReadonlyArray<number | null>;\n high: ReadonlyArray<number | null>;\n low: ReadonlyArray<number | null>;\n close: ReadonlyArray<number | null>;\n volume: ReadonlyArray<number | null>;\n }>;\n }>;\n export type RunnerSnapshot = Readonly<{\n slots: Readonly<Record<string, JsonValue>>;\n }>;\n export type StateSnapshot = Readonly<{\n lastBarTime: number;\n streams: Readonly<Record<string, StreamSnapshot>>;\n savedAt: number;\n snapshotVersion: 1;\n primary: RunnerSnapshot;\n siblings?: Readonly<Record<string, RunnerSnapshot>>;\n dependencies?: Readonly<Record<string, RunnerSnapshot>>;\n }>;\n export type StateStoreKey = Readonly<{\n scriptHash: string;\n compilerVersion: string;\n apiVersion: 1;\n capabilitiesHash: string;\n symbol: string;\n mainInterval: string;\n requestedIntervals: ReadonlyArray<string>;\n }>;\n export type AlertOpts = Readonly<{\n severity?: AlertSeverity;\n meta?: Readonly<Record<string, JsonValue>>;\n }>;\n export function alert(message: string, opts?: AlertOpts): void;\n export type LogLevel = \"info\" | \"warn\" | \"error\";\n export type RuntimeNamespace = Readonly<{\n log: Readonly<{\n info(message: string, meta?: Readonly<Record<string, JsonValue>>): void;\n warn(message: string, meta?: Readonly<Record<string, JsonValue>>): void;\n error(message: string, meta?: Readonly<Record<string, JsonValue>>): void;\n }>;\n error(message: string): never;\n }>;\n export const runtime: RuntimeNamespace;\n export function fromGradient(t: number, stops: ReadonlyArray<GradientStop>): Color;\n export function withAlpha(c: Color, alpha: number): Color;\n export function rgb(r: number, g: number, b: number, alpha?: number): Color;\n export function hsl(h: number, s: number, l: number, alpha?: number): Color;\n export const color: Readonly<{\n aqua: Color;\n black: Color;\n blue: Color;\n fuchsia: Color;\n gray: Color;\n green: Color;\n lime: Color;\n maroon: Color;\n navy: Color;\n olive: Color;\n orange: Color;\n purple: Color;\n red: Color;\n silver: Color;\n teal: Color;\n white: Color;\n yellow: Color;\n fromGradient: typeof fromGradient;\n withAlpha: typeof withAlpha;\n rgb: typeof rgb;\n hsl: typeof hsl;\n }>;\n export type InputKind =\n | \"int\"\n | \"float\"\n | \"bool\"\n | \"string\"\n | \"enum\"\n | \"color\"\n | \"source\"\n | \"time\"\n | \"price\"\n | \"symbol\"\n | \"interval\"\n | \"external-series\";\n export type SourceField =\n | \"open\"\n | \"high\"\n | \"low\"\n | \"close\"\n | \"hl2\"\n | \"hlc3\"\n | \"ohlc4\"\n | \"hlcc4\";\n export type Schema<T> = Readonly<{ kind: \"external-series-schema\"; __brand?: T }>;\n type NumericInputOpts = Readonly<{ min?: number; max?: number; step?: number }>;\n type CommonInputDescriptor<K extends InputKind, T> = Readonly<{\n kind: K;\n defaultValue: T;\n title?: string;\n }>;\n export type IntDescriptor = CommonInputDescriptor<\"int\", number> & NumericInputOpts;\n export type FloatDescriptor = CommonInputDescriptor<\"float\", number> & NumericInputOpts;\n export type BoolDescriptor = CommonInputDescriptor<\"bool\", boolean>;\n export type StringDescriptor = CommonInputDescriptor<\"string\", string> & Readonly<{ multiline?: boolean }>;\n export type EnumDescriptor<T extends string> = CommonInputDescriptor<\"enum\", T> & Readonly<{ options: ReadonlyArray<T> }>;\n export type ColorDescriptor = CommonInputDescriptor<\"color\", Color>;\n export type SourceDescriptor = CommonInputDescriptor<\"source\", SourceField>;\n export type TimeDescriptor = CommonInputDescriptor<\"time\", number> & Readonly<{ pickFromChart?: boolean }>;\n export type PriceDescriptor = CommonInputDescriptor<\"price\", number>;\n export type SymbolDescriptor = CommonInputDescriptor<\"symbol\", string>;\n export type IntervalDescriptorInput = CommonInputDescriptor<\"interval\", string>;\n export type ExternalSeriesDescriptor<T> = Readonly<{\n kind: \"external-series\";\n name: string;\n schema: Schema<T>;\n title?: string;\n }>;\n export type InputDescriptor<T> =\n | IntDescriptor\n | FloatDescriptor\n | BoolDescriptor\n | StringDescriptor\n | EnumDescriptor<string>\n | ColorDescriptor\n | SourceDescriptor\n | TimeDescriptor\n | PriceDescriptor\n | SymbolDescriptor\n | IntervalDescriptorInput\n | ExternalSeriesDescriptor<T>;\n export const input: Readonly<{\n int(defaultValue: number, opts?: NumericInputOpts & Readonly<{ title?: string }>): IntDescriptor;\n float(defaultValue: number, opts?: NumericInputOpts & Readonly<{ title?: string }>): FloatDescriptor;\n bool(defaultValue: boolean, opts?: Readonly<{ title?: string }>): BoolDescriptor;\n string(defaultValue: string, opts?: Readonly<{ title?: string; multiline?: boolean }>): StringDescriptor;\n enum<T extends string>(\n defaultValue: T,\n options: ReadonlyArray<T>,\n opts?: Readonly<{ title?: string }>,\n ): EnumDescriptor<T>;\n color(defaultValue: Color, opts?: Readonly<{ title?: string }>): ColorDescriptor;\n source(defaultValue: SourceField, opts?: Readonly<{ title?: string }>): SourceDescriptor;\n time(defaultValue: Time, opts?: Readonly<{ title?: string; pickFromChart?: boolean }>): TimeDescriptor;\n price(defaultValue: Price, opts?: Readonly<{ title?: string }>): PriceDescriptor;\n symbol(defaultValue: string, opts?: Readonly<{ title?: string }>): SymbolDescriptor;\n interval(defaultValue: string, opts?: Readonly<{ title?: string }>): IntervalDescriptorInput;\n externalSeries<T>(args: Readonly<{ name: string; schema: Schema<T>; title?: string }>): ExternalSeriesDescriptor<T>;\n }>;\n export type InputSchema = Readonly<Record<string, InputDescriptor<unknown>>>;\n export type MutableSlot<T> = {\n value: T;\n };\n export type StateNamespace = Readonly<{\n float(init: number): MutableSlot<number>;\n int(init: number): MutableSlot<number>;\n bool(init: boolean): MutableSlot<boolean>;\n string(init: string): MutableSlot<string>;\n tick: Readonly<{\n float(init: number): MutableSlot<number>;\n int(init: number): MutableSlot<number>;\n bool(init: boolean): MutableSlot<boolean>;\n string(init: string): MutableSlot<string>;\n }>;\n }>;\n export const state: StateNamespace;\n export type BarStateView = {\n readonly isfirst: boolean;\n readonly islast: boolean;\n readonly isnew: boolean;\n readonly ishistory: boolean;\n readonly isrealtime: boolean;\n readonly isconfirmed: boolean;\n };\n export const barstate: BarStateView;\n export type SymbolType =\n | \"equity\"\n | \"futures\"\n | \"forex\"\n | \"crypto\"\n | \"index\"\n | \"fund\"\n | \"bond\"\n | \"commodity\"\n | \"custom\";\n export type SymInfoView = {\n readonly ticker: string;\n readonly type: SymbolType;\n readonly mintick: number;\n readonly currency: string;\n readonly basecurrency: string;\n readonly exchange: string;\n readonly timezone: string;\n readonly session: string;\n readonly meta: Readonly<Record<string, JsonValue>>;\n };\n export const syminfo: SymInfoView;\n export type TimeframeView = {\n readonly period: string;\n readonly isintraday: boolean;\n readonly isdaily: boolean;\n readonly isweekly: boolean;\n readonly ismonthly: boolean;\n readonly inSeconds: number;\n };\n export const timeframe: TimeframeView;\n export type RequestSecurityOpts = Readonly<{ interval: string }>;\n export type RequestLowerTfOpts = Readonly<{ interval: string }>;\n export type SecurityBar = Readonly<{\n readonly time: Series<Time>;\n readonly open: Series<Price>;\n readonly high: Series<Price>;\n readonly low: Series<Price>;\n readonly close: Series<Price>;\n readonly volume: Series<Volume>;\n readonly hl2: Series<Price>;\n readonly hlc3: Series<Price>;\n readonly ohlc4: Series<Price>;\n readonly hlcc4: Series<Price>;\n readonly symbol: Series<string>;\n readonly interval: Series<string>;\n }>;\n export type RequestNamespace = Readonly<{\n security(opts: RequestSecurityOpts): SecurityBar;\n lowerTf(opts: RequestLowerTfOpts): Series<ReadonlyArray<Bar>>;\n }>;\n export const request: RequestNamespace;\n export function intervalToSeconds(d: IntervalDescriptor): number;\n export type OutputDeclaration = Readonly<{\n readonly title: string;\n readonly kind: \"series-number\";\n }>;\n export type PlotSlotDescriptor = Readonly<{\n readonly slotId: string;\n readonly kind: PlotKind;\n readonly title?: string;\n }>;\n export type DependencyDeclaration = Readonly<{\n readonly localId: string;\n readonly producerName: string;\n readonly producerSourcePath: string;\n readonly producerExportName: string;\n readonly effectiveInputs: Readonly<Record<string, JsonValue>>;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly isDrawn: boolean;\n }>;\n export type ScriptManifest = {\n readonly apiVersion: 1;\n readonly kind: \"indicator\" | \"drawing\" | \"alert\" | \"alertCondition\";\n readonly name: string;\n readonly inputs: InputSchema;\n readonly capabilities: ReadonlyArray<CapabilityId>;\n readonly requestedIntervals: ReadonlyArray<string>;\n readonly userPickableInterval: boolean;\n readonly seriesCapacities: Readonly<Record<string, number>>;\n readonly maxLookback: number;\n readonly overlay?: boolean;\n readonly maxDrawings?: DrawingCounts;\n readonly maxBarsBack?: number;\n readonly format?: ValueFormat;\n readonly precision?: number;\n readonly scale?: ScaleAxis;\n readonly shortName?: string;\n readonly requiresIntervals?: ReadonlyArray<string>;\n readonly alertConditions?: ReadonlyArray<AlertConditionDefinition>;\n readonly dependencies?: ReadonlyArray<DependencyDeclaration>;\n readonly outputs?: ReadonlyArray<OutputDeclaration>;\n readonly plots?: ReadonlyArray<PlotSlotDescriptor>;\n readonly exportName?: string;\n readonly siblings?: ReadonlyArray<ScriptManifest>;\n readonly isDrawn?: boolean;\n };\n export type AlertConditionDescriptor = Readonly<{\n title: string;\n description: string;\n defaultMessage: string;\n }>;\n export type AlertConditionDefinition = AlertConditionDescriptor & Readonly<{ id: string }>;\n export type Time = number;\n export type Price = number;\n export type WorldPoint = { readonly time: Time; readonly price: Price };\n export type AnchorPair = readonly [WorldPoint, WorldPoint];\n export type AnchorTriple = readonly [WorldPoint, WorldPoint, WorldPoint];\n export type AnchorQuad = readonly [WorldPoint, WorldPoint, WorldPoint, WorldPoint];\n export type AnchorQuint = readonly [\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n ];\n export type AnchorHept = readonly [\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n ];\n export type LineDrawStyle = Readonly<{\n color?: Color;\n lineWidth?: number;\n lineStyle?: LineStyle;\n extendLeft?: boolean;\n extendRight?: boolean;\n }>;\n export type ShapeStyle = Readonly<{\n stroke?: Color;\n fill?: Color;\n lineWidth?: number;\n lineStyle?: LineStyle;\n fillAlpha?: number;\n }>;\n export type HighlighterStyle = Readonly<{\n color: Color;\n alpha: number;\n }>;\n export type BrushStyle = Readonly<{\n stroke: Color;\n fill: Color;\n }>;\n export type TextOpts = Readonly<{\n color?: Color;\n size?: \"tiny\" | \"small\" | \"normal\" | \"large\" | \"huge\";\n halign?: \"left\" | \"center\" | \"right\";\n valign?: \"top\" | \"middle\" | \"bottom\";\n bgColor?: Color;\n }>;\n export type ArrowOpts = LineDrawStyle & Readonly<{ label?: string }>;\n export type ArrowMarkerOpts = Readonly<{\n color?: Color;\n text?: string;\n }>;\n export type PathOpts = LineDrawStyle & Readonly<{ closed?: boolean }>;\n export type FibOpts = Readonly<{\n levels?: ReadonlyArray<number>;\n showLabels?: boolean;\n color?: Color;\n extendLeft?: boolean;\n extendRight?: boolean;\n }>;\n export type RegressionTrendOpts = Readonly<{\n source?: \"close\" | \"open\" | \"high\" | \"low\" | \"hl2\" | \"hlc3\" | \"ohlc4\" | \"hlcc4\";\n stdevMultiplier?: number;\n showUpperBand?: boolean;\n showLowerBand?: boolean;\n color?: Color;\n }>;\n export type FrameOpts = Readonly<{\n label?: string;\n bgColor?: Color;\n }>;\n export type TablePosition =\n | \"top-left\" | \"top-center\" | \"top-right\"\n | \"middle-left\" | \"middle-center\" | \"middle-right\"\n | \"bottom-left\" | \"bottom-center\" | \"bottom-right\";\n export type TableCell = Readonly<{\n text: string;\n bgColor?: Color;\n textColor?: Color;\n textHalign?: \"left\" | \"center\" | \"right\";\n textValign?: \"top\" | \"middle\" | \"bottom\";\n textSize?: \"tiny\" | \"small\" | \"normal\" | \"large\" | \"huge\";\n }>;\n export type TableOpts = Readonly<{\n position: TablePosition;\n cells: ReadonlyArray<ReadonlyArray<TableCell>>;\n borderColor?: Color;\n borderWidth?: number;\n frame?: Readonly<{ color: Color; width: number }>;\n }>;\n export type DrawingHandle = Readonly<{\n readonly id: string;\n update(patch: Readonly<Record<string, unknown>>): void;\n remove(): void;\n }>;\n // Phase-3 draw surface — every kind listed in\n // \\`packages/core/src/draw/draw.ts:DrawNamespace\\`. The shim must\n // stay in lockstep; missing methods make valid scripts fail the\n // semantic-typecheck gate added in PLAN §5.2 step 1.\n export type DrawNamespace = {\n // Lines / Rays\n line(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n horizontalLine(price: Price, opts?: LineDrawStyle): DrawingHandle;\n horizontalRay(anchor: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n verticalLine(time: Time, opts?: LineDrawStyle): DrawingHandle;\n crossLine(anchor: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n trendAngle(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n // Boxes A\n rectangle(a: WorldPoint, b: WorldPoint, opts?: ShapeStyle): DrawingHandle;\n rotatedRectangle(anchors: AnchorQuad, opts?: ShapeStyle): DrawingHandle;\n triangle(anchors: AnchorTriple, opts?: ShapeStyle): DrawingHandle;\n polyline(anchors: ReadonlyArray<WorldPoint>, opts?: LineDrawStyle): DrawingHandle;\n // Boxes B\n circle(centre: WorldPoint, radiusAnchor: WorldPoint, opts?: ShapeStyle): DrawingHandle;\n ellipse(a: WorldPoint, b: WorldPoint, opts?: ShapeStyle): DrawingHandle;\n path(anchors: ReadonlyArray<WorldPoint>, opts?: PathOpts): DrawingHandle;\n marker(\n anchor: WorldPoint,\n opts?: TextOpts & Readonly<{ text?: string; value?: number }>,\n ): DrawingHandle;\n // Curves\n arc(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n curve(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n doubleCurve(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n // Freehand\n pen(anchors: ReadonlyArray<WorldPoint>, opts?: LineDrawStyle): DrawingHandle;\n highlighter(anchors: ReadonlyArray<WorldPoint>, opts: HighlighterStyle): DrawingHandle;\n brush(anchors: ReadonlyArray<WorldPoint>, opts: BrushStyle): DrawingHandle;\n // Annotations\n text(anchor: WorldPoint, body: string, opts?: TextOpts): DrawingHandle;\n arrow(a: WorldPoint, b: WorldPoint, opts?: ArrowOpts): DrawingHandle;\n arrowMarker(anchor: WorldPoint, opts?: ArrowMarkerOpts): DrawingHandle;\n arrowMarkUp(anchor: WorldPoint, opts?: ArrowMarkerOpts): DrawingHandle;\n arrowMarkDown(anchor: WorldPoint, opts?: ArrowMarkerOpts): DrawingHandle;\n // Channels\n trendChannel(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n flatTopBottom(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n disjointChannel(anchors: AnchorQuad, opts?: LineDrawStyle): DrawingHandle;\n regressionTrend(a: WorldPoint, b: WorldPoint, opts?: RegressionTrendOpts): DrawingHandle;\n // Fibonacci A\n fibRetracement(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibTrendExtension(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;\n fibChannel(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;\n fibTimeZone(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibWedge(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;\n // Fibonacci B\n fibSpeedFan(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibSpeedArcs(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibSpiral(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibCircles(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibTrendTime(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;\n // Gann\n gannBox(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n gannSquareFixed(anchor: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n gannSquare(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n gannFan(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n // Pitchforks\n pitchfork(\n anchors: AnchorTriple,\n opts?: LineDrawStyle & Readonly<{\n variant?: \"standard\" | \"schiff\" | \"modifiedSchiff\" | \"inside\";\n }>,\n ): DrawingHandle;\n pitchfan(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n // Harmonic Patterns\n xabcdPattern(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n cypherPattern(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n headAndShoulders(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n abcdPattern(anchors: AnchorQuad, opts?: LineDrawStyle): DrawingHandle;\n trianglePattern(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n threeDrivesPattern(anchors: AnchorHept, opts?: LineDrawStyle): DrawingHandle;\n // Elliott Waves\n elliottImpulseWave(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n elliottCorrectionWave(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n elliottTriangleWave(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n elliottDoubleCombo(anchors: AnchorHept, opts?: LineDrawStyle): DrawingHandle;\n elliottTripleCombo(anchors: AnchorHept, opts?: LineDrawStyle): DrawingHandle;\n // Cycles\n cyclicLines(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n timeCycles(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n sineLine(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n // Containers\n group(childHandleIds: ReadonlyArray<string>): DrawingHandle;\n frame(a: WorldPoint, b: WorldPoint, opts?: FrameOpts): DrawingHandle;\n // Viewport overlays\n table(opts: TableOpts): DrawingHandle;\n };\n export const draw: DrawNamespace;\n export type ComputeContext = {\n readonly bar: Bar;\n readonly inputs: Readonly<Record<string, unknown>>;\n readonly ta: TaNamespace;\n readonly plot: typeof plot;\n readonly hline: typeof hline;\n readonly alert: typeof alert;\n readonly draw: DrawNamespace;\n readonly state: StateNamespace;\n readonly barstate: BarStateView;\n readonly syminfo: SymInfoView;\n readonly timeframe: TimeframeView;\n readonly request: RequestNamespace;\n readonly runtime: RuntimeNamespace;\n readonly signal?: (conditionId: string, fired: boolean) => void;\n };\n export type ComputeFn = (ctx: ComputeContext) => void;\n export type CompiledScriptObject = {\n readonly manifest: ScriptManifest;\n readonly compute: ComputeFn;\n readonly output: (name: string) => Series<number>;\n readonly withInputs: (\n overrides: Readonly<Record<string, unknown>>,\n ) => CompiledScriptObject;\n };\n export type CompiledScriptBundle = Readonly<{\n readonly primary: CompiledScriptObject;\n readonly siblings: ReadonlyArray<{\n readonly exportName: string;\n readonly compiled: CompiledScriptObject;\n }>;\n readonly dependencies: ReadonlyArray<{\n readonly localId: string;\n readonly compiled: CompiledScriptObject;\n readonly inputOverrides?: Readonly<Record<string, unknown>>;\n }>;\n }>;\n export function isCompiledScriptBundle(\n v: CompiledScriptObject | CompiledScriptBundle,\n ): v is CompiledScriptBundle;\n export type DefineIndicatorOpts = Readonly<{\n name: string;\n apiVersion: 1;\n overlay?: boolean;\n inputs?: InputSchema;\n compute: ComputeFn;\n maxDrawings?: DrawingCounts;\n outputs?: ReadonlyArray<OutputDeclaration>;\n }> & ScriptOverrides;\n export type DefineAlertOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n compute: ComputeFn;\n }> & Omit<ScriptOverrides, \"scale\" | \"format\" | \"precision\">;\n export type DefineAlertConditionOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n conditions: Readonly<Record<string, AlertConditionDescriptor>>;\n compute: ComputeFn;\n }>;\n export type DefineDrawingOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n compute: ComputeFn;\n maxDrawings?: DrawingCounts;\n }> & Omit<ScriptOverrides, \"maxBarsBack\" | \"scale\">;\n export function defineIndicator(opts: DefineIndicatorOpts): CompiledScriptObject;\n export function defineAlert(opts: DefineAlertOpts): CompiledScriptObject;\n export function defineAlertCondition(opts: DefineAlertConditionOpts): CompiledScriptObject;\n export function defineDrawing(opts: DefineDrawingOpts): CompiledScriptObject;\n export type StatefulPrimitiveEntry = Readonly<{ name: string; slot: boolean }>;\n export const STATEFUL_PRIMITIVES: ReadonlySet<StatefulPrimitiveEntry>;\n export const STATEFUL_PRIMITIVES_BY_NAME: ReadonlyMap<string, StatefulPrimitiveEntry>;\n}\n\ndeclare module \"@invinite-org/chartlang-core/time\" {\n import type { Time } from \"@invinite-org/chartlang-core\";\n export type SessionType = \"regular\" | \"extended\";\n export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n export type SessionBounds = Readonly<{ startMs: number; endMs: number }>;\n export const session: Readonly<{\n regular(tz: string, t: Time): SessionBounds | null;\n extended(tz: string, t: Time): SessionBounds | null;\n isOpen(tz: string, t: Time, type: SessionType): boolean;\n }>;\n export function weekday(tz: string, t: Time): Weekday;\n export function nyDayKey(t: Time): string;\n export function nySessionBounds(t: Time): SessionBounds;\n export function weekKey(tz: string, t: Time): string;\n}\n`;\n\n/**\n * The compiler options the compiler pins for every script. ES2022 target,\n * Bundler module resolution, strict mode, no DOM. Scripts that depend on\n * browser globals fail the `forbiddenConstructs` pass on the global access\n * itself; the `lib` setting keeps the typechecker from accepting them in the\n * first place.\n *\n * @since 0.1\n * @example\n * import { COMPILER_OPTIONS } from \"@invinite-org/chartlang-compiler/program\";\n * void COMPILER_OPTIONS;\n */\nexport const COMPILER_OPTIONS: ts.CompilerOptions = {\n target: ts.ScriptTarget.ES2022,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n strict: true,\n noEmit: true,\n lib: [\"lib.es2022.d.ts\"],\n skipLibCheck: true,\n esModuleInterop: true,\n isolatedModules: true,\n verbatimModuleSyntax: false,\n allowJs: false,\n};\n\n/**\n * The return shape of `createProgramForSource`. Callers use `sourceFile` for\n * AST walks, `checker` for symbol resolution, and `program` as the root\n * handle when they need diagnostics from `tsc` itself (not used in Phase 1,\n * but kept on the type so Task 3 can plug in `program.getSemanticDiagnostics`\n * without an API change).\n *\n * @since 0.1\n * @example\n * // const { sourceFile, checker } = createProgramForSource(src, opts);\n * const shape: { sourceFile: unknown; checker: unknown; program: unknown } = {\n * sourceFile: null,\n * checker: null,\n * program: null,\n * };\n * void shape;\n */\nexport type ProgramForSource = Readonly<{\n program: ts.Program;\n sourceFile: ts.SourceFile;\n checker: ts.TypeChecker;\n}>;\n\n/**\n * Build a single-file TypeScript program for an in-memory `.chart.ts`\n * source. The synthetic file lives at `sourcePath` (POSIX, as the user\n * would write it); imports of `@invinite-org/chartlang-core` resolve\n * against the in-memory ambient shim. Returns the source file and a\n * configured type checker — the caller never sees the underlying compiler\n * host plumbing.\n *\n * @since 0.1\n * @example\n * // const { sourceFile, checker } = createProgramForSource(\n * // 'export default defineIndicator({ name: \"x\", apiVersion: 1, compute: () => {} });',\n * // { sourcePath: \"demo.chart.ts\" },\n * // );\n * const fn: typeof createProgramForSource = createProgramForSource;\n * void fn;\n */\nexport function createProgramForSource(\n source: string,\n opts: {\n readonly sourcePath: string;\n readonly chartImports?: ReadonlyArray<string>;\n },\n): ProgramForSource {\n const sourcePath = normalisePath(opts.sourcePath);\n const sourceFile = ts.createSourceFile(\n sourcePath,\n source,\n ts.ScriptTarget.ES2022,\n true,\n ts.ScriptKind.TS,\n );\n const shimFile = ts.createSourceFile(\n CORE_MODULE_PATH,\n CORE_AMBIENT_SHIM,\n ts.ScriptTarget.ES2022,\n true,\n ts.ScriptKind.TS,\n );\n\n // Synthesise an ambient declaration for every `.chart` / `.chart.ts`\n // import the caller pre-scanned. Each module exports a default\n // `CompiledScriptObject` so consumer-side typecheck passes; the\n // analysis pass walks the real `ProducerSnapshot` for output-title\n // validation (see `extractDependencyGraph.ts`).\n const chartImports = opts.chartImports ?? [];\n const chartShimPath = \"/__chartlang__/chart-imports.d.ts\";\n const VIRTUAL_FILE_SET = new Set<string>([sourcePath, CORE_MODULE_PATH]);\n let chartShimFile: ts.SourceFile | undefined;\n if (chartImports.length > 0) {\n VIRTUAL_FILE_SET.add(chartShimPath);\n const body = chartImports\n .map(\n (specifier) => `\ndeclare module ${JSON.stringify(specifier)} {\n import type { CompiledScriptObject } from \"@invinite-org/chartlang-core\";\n const value: CompiledScriptObject;\n export default value;\n}`,\n )\n .join(\"\\n\");\n chartShimFile = ts.createSourceFile(\n chartShimPath,\n body,\n ts.ScriptTarget.ES2022,\n true,\n ts.ScriptKind.TS,\n );\n }\n\n const fallbackHost = ts.createCompilerHost(COMPILER_OPTIONS, true);\n\n const host: ts.CompilerHost = {\n ...fallbackHost,\n getSourceFile(\n fileName,\n languageVersionOrOptions,\n onError,\n shouldCreateNewSourceFile,\n ): ts.SourceFile | undefined {\n if (fileName === sourcePath) return sourceFile;\n if (fileName === CORE_MODULE_PATH) return shimFile;\n if (fileName === chartShimPath && chartShimFile !== undefined) {\n return chartShimFile;\n }\n return fallbackHost.getSourceFile(\n fileName,\n languageVersionOrOptions,\n onError,\n shouldCreateNewSourceFile,\n );\n },\n fileExists(fileName) {\n return VIRTUAL_FILE_SET.has(fileName) || fallbackHost.fileExists(fileName);\n },\n };\n\n const rootNames: string[] = [sourcePath, CORE_MODULE_PATH];\n if (chartShimFile !== undefined) rootNames.push(chartShimPath);\n const program = ts.createProgram({\n rootNames,\n options: COMPILER_OPTIONS,\n host,\n });\n return Object.freeze({\n program,\n sourceFile,\n checker: program.getTypeChecker(),\n });\n}\n\nfunction normalisePath(p: string): string {\n return p.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n}\n"]}
|
|
@@ -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
|
*
|
|
@@ -6,7 +6,7 @@ import { plotKindFromCallsite, readLiteralTitle } from "./plotKindFromCallsite.j
|
|
|
6
6
|
import { resolveCalleeName, resolveCoreSymbolForElementAccess } from "./resolveCallee.js";
|
|
7
7
|
/**
|
|
8
8
|
* Inject a `__slot` string-literal first argument into every stateful
|
|
9
|
-
* primitive call. Slot id format
|
|
9
|
+
* primitive call. Slot id format:
|
|
10
10
|
* `<sourcePath>:<line>:<col>#<callIndex>`. `callIndex` is hardcoded to `0`
|
|
11
11
|
* for hand-written code (Phase 1 reserves non-zero for future macros).
|
|
12
12
|
*
|
|
@@ -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,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AAsB1F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,iBAAiB,CAC7B,UAAyB,EACzB,OAAuB,EACvB,IAKC;IAED,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,GAAG,EAA6B,CAAC;IACzE,MAAM,WAAW,GAAwB,EAAE,CAAC;IAE5C,MAAM,OAAO,GAAyC,CAAC,OAAO,EAAE,EAAE;QAC9D,MAAM,KAAK,GAAe,CAAC,IAAI,EAAE,EAAE;YAC/B,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5B,gEAAgE;gBAChE,4DAA4D;gBAC5D,yDAAyD;gBACzD,6DAA6D;gBAC7D,IAAI,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;oBAChD,MAAM,QAAQ,GAAG,iCAAiC,CAAC,IAAI,CAAC,UAAU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,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACrD,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,CACjB,CAAC;oBAClC,MAAM,gBAAgB,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAAgB;wBAC/D,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC;wBACtC,GAAG,gBAAgB;qBACtB,CAAC,CAAC;oBACH,MAAM,aAAa,GAAG,EAAE,CAAC,SAAS,CAC9B,IAAI,CAAC,UAAU,EACf,KAAK,EACL,EAAE,CAAC,YAAY,CACD,CAAC;oBACnB,OAAO,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAClC,IAAI,EACJ,aAAa,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","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { PlotSlotDescriptor, StatefulPrimitiveEntry } from \"@invinite-org/chartlang-core\";\nimport ts from \"typescript\";\n\nimport { type CompileDiagnostic, createDiagnostic } from \"../diagnostics.js\";\nimport { plotKindFromCallsite, readLiteralTitle } from \"./plotKindFromCallsite.js\";\nimport { resolveCalleeName, resolveCoreSymbolForElementAccess } from \"./resolveCallee.js\";\n\n/**\n * Output of `injectCallsiteIds` — the rewritten source file plus any\n * diagnostics produced during the rewrite. Only `callsite-id-conflict`\n * surfaces here; every other transformer-related check lives in the\n * `analysis/` modules.\n *\n * @since 0.1\n * @example\n * // const { transformed, diagnostics } = injectCallsiteIds(src, checker, opts);\n * const shape: { transformed: unknown; diagnostics: ReadonlyArray<unknown> } = {\n * transformed: null,\n * diagnostics: [],\n * };\n * void shape;\n */\nexport type InjectCallsiteIdsResult = Readonly<{\n transformed: ts.SourceFile;\n diagnostics: ReadonlyArray<CompileDiagnostic>;\n}>;\n\n/**\n * Inject a `__slot` string-literal first argument into every stateful\n * primitive call. Slot id format:\n * `<sourcePath>:<line>:<col>#<callIndex>`. `callIndex` is hardcoded to `0`\n * for hand-written code (Phase 1 reserves non-zero for future macros).\n *\n * The transformer is a pure rewrite — input nodes are never mutated. Lines\n * and columns are 1-based and read from the **input** source file before\n * any rewrite happens. Duplicate ids at the same `(line, col)` (impossible\n * in hand-written TS but reachable by future macros) trigger a\n * `callsite-id-conflict` diagnostic; only the first call at the duplicated\n * position gets the slot.\n *\n * @since 0.1\n * @example\n * // Input: ta.ema(close, 20)\n * // Output: ta.ema(\"demo.chart.ts:5:13#0\", close, 20)\n * const fn: typeof injectCallsiteIds = injectCallsiteIds;\n * void fn;\n */\nexport function injectCallsiteIds(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n opts: {\n readonly sourcePath: string;\n readonly statefulByName: ReadonlyMap<string, StatefulPrimitiveEntry>;\n readonly slotsSeen?: Map<string, ts.CallExpression>;\n readonly plotSlots?: PlotSlotDescriptor[];\n },\n): InjectCallsiteIdsResult {\n const { sourcePath, statefulByName } = opts;\n const plotSlots = opts.plotSlots;\n const slotsSeen = opts.slotsSeen ?? new Map<string, ts.CallExpression>();\n const diagnostics: CompileDiagnostic[] = [];\n\n const factory: ts.TransformerFactory<ts.SourceFile> = (context) => {\n const visit: ts.Visitor = (node) => {\n if (ts.isCallExpression(node)) {\n // Element-access calls (`ta[\"ema\"](...)`, `alert?.[chan](...)`)\n // bypass slot-id injection because the property name is not\n // statically known. Detecting these explicitly turns the\n // silent-state-corruption footgun into a compile-time error.\n if (ts.isElementAccessExpression(node.expression)) {\n const coreName = resolveCoreSymbolForElementAccess(node.expression, checker);\n if (coreName !== null) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"stateful-call-element-access\",\n message: `Element-access calls on the \\`${coreName}\\` namespace bypass callsite-id injection. Use the property-access form (\\`${coreName}.<name>(...)\\`).`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n return ts.visitEachChild(node, visit, context);\n }\n }\n const calleeName = resolveCalleeName(node, checker);\n const entry = calleeName === null ? undefined : statefulByName.get(calleeName);\n if (entry?.slot) {\n const start = node.getStart(sourceFile);\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);\n const slotId = `${sourcePath}:${line + 1}:${character + 1}#0`;\n const existing = slotsSeen.get(slotId);\n if (existing !== undefined) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"callsite-id-conflict\",\n message: `Two stateful calls share the same slot id \"${slotId}\".`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n return ts.visitEachChild(node, visit, context);\n }\n slotsSeen.set(slotId, node);\n if (\n plotSlots !== undefined &&\n (calleeName === \"plot\" || calleeName === \"hline\")\n ) {\n const optsArg = node.arguments[1];\n // best-effort dynamic-kind fallback: a callsite whose\n // `style` is non-literal is still listed as \"line\".\n const kind = plotKindFromCallsite(calleeName, optsArg) ?? \"line\";\n const title = readLiteralTitle(optsArg);\n plotSlots.push(\n Object.freeze({\n slotId,\n kind,\n ...(title === undefined ? {} : { title }),\n }),\n );\n }\n const visitedArguments = node.arguments.map((argument) =>\n ts.visitNode(argument, visit, ts.isExpression),\n ) as ReadonlyArray<ts.Expression>;\n const updatedArguments = ts.factory.createNodeArray<ts.Expression>([\n ts.factory.createStringLiteral(slotId),\n ...visitedArguments,\n ]);\n const visitedCallee = ts.visitNode(\n node.expression,\n visit,\n ts.isExpression,\n ) as ts.Expression;\n return ts.factory.updateCallExpression(\n node,\n visitedCallee,\n node.typeArguments,\n updatedArguments,\n );\n }\n }\n return ts.visitEachChild(node, visit, context);\n };\n return (file) => ts.visitNode(file, visit, ts.isSourceFile) as ts.SourceFile;\n };\n\n const result = ts.transform(sourceFile, [factory]);\n const transformed = result.transformed[0];\n result.dispose();\n return Object.freeze({\n transformed,\n diagnostics: Object.freeze(diagnostics.slice()),\n });\n}\n"]}
|
|
@@ -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;AAE7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,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","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nexport { resolveCalleeName } from \"./resolveCallee.js\";\nexport { injectCallsiteIds } from \"./callsiteIdInjection.js\";\nexport type { InjectCallsiteIdsResult } from \"./callsiteIdInjection.js\";\nexport { rewriteDependencyAccessors } from \"./rewriteDependencyAccessors.js\";\nexport type { RewriteDependencyAccessorsResult } from \"./rewriteDependencyAccessors.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plotKindFromCallsite.js","sourceRoot":"","sources":["../../src/transformers/plotKindFromCallsite.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,UAAU,GAA0B,IAAI,GAAG,CAAW;IACxD,MAAM;IACN,WAAW;IACX,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,aAAa;IACb,OAAO;IACP,QAAQ;IACR,OAAO;IACP,WAAW;IACX,OAAO;IACP,iBAAiB;IACjB,cAAc;IACd,UAAU;IACV,WAAW;IACX,sBAAsB;CACzB,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAQ,UAAkC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,YAAY,CACjB,GAA+B,EAC/B,IAAY;IAEZ,KAAK,MAAM,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;QACpC,IACI,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YACjC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAC7B,CAAC;YACC,OAAO,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,oBAAoB,CAChC,UAAkB,EAClB,OAAkC;IAElC,IAAI,UAAU,KAAK,OAAO;QAAE,OAAO,iBAAiB,CAAC;IACrD,IAAI,UAAU,KAAK,MAAM;QAAE,OAAO,SAAS,CAAC;IAC5C,IAAI,OAAO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E,OAAO,MAAM,CAAC;IAC3C,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC;IACpC,IAAI,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","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { PlotKind } from \"@invinite-org/chartlang-core\";\nimport ts from \"typescript\";\n\nconst PLOT_KINDS: ReadonlySet<PlotKind> = new Set<PlotKind>([\n \"line\",\n \"step-line\",\n \"horizontal-line\",\n \"histogram\",\n \"area\",\n \"filled-band\",\n \"label\",\n \"marker\",\n \"shape\",\n \"character\",\n \"arrow\",\n \"candle-override\",\n \"bar-override\",\n \"bg-color\",\n \"bar-color\",\n \"horizontal-histogram\",\n]);\n\nfunction isPlotKind(value: string): value is PlotKind {\n return (PLOT_KINDS as ReadonlySet<string>).has(value);\n}\n\nfunction findProperty(\n obj: ts.ObjectLiteralExpression,\n name: string,\n): ts.PropertyAssignment | undefined {\n for (const property of obj.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n ts.isIdentifier(property.name) &&\n property.name.text === name\n ) {\n return property;\n }\n }\n return undefined;\n}\n\n/**\n * Derive the statically-known {@link PlotKind} for a plotting callsite from\n * its callee name and opts argument. The chartlang plot surface has no\n * `plot.*` member API — the kind is selected at the callsite via the opts\n * object literal's `style.kind` property (mirrored by the runtime's\n * `buildStyle`). Returns:\n *\n * - `\"horizontal-line\"` for `hline`.\n * - `\"line\"` for a bare `plot` with no `style` (no opts, opts without\n * `style`, or a non-object opts).\n * - the literal `style.kind` value for `plot(x, { style: { kind: \"<lit>\" } })`\n * when it is a string literal naming a `PlotKind` member.\n * - `undefined` when the kind is not statically determinable: a dynamic\n * `style` (`{ style: someVar }`), a dynamic `kind` (`{ style: { kind:\n * someVar } }`), or a string literal that is not a `PlotKind` member.\n * The caller falls back to `\"line\"` (best-effort) so the slot is still\n * listed.\n *\n * @since 0.8\n * @example\n * // const kind = plotKindFromCallsite(\"plot\", optsObjectLiteralNode);\n * // kind === \"histogram\" | \"line\" | undefined | ...\n * const fn: typeof plotKindFromCallsite = plotKindFromCallsite;\n * void fn;\n */\nexport function plotKindFromCallsite(\n calleeName: string,\n optsArg: ts.Expression | undefined,\n): PlotKind | undefined {\n if (calleeName === \"hline\") return \"horizontal-line\";\n if (calleeName !== \"plot\") return undefined;\n if (optsArg === undefined || !ts.isObjectLiteralExpression(optsArg)) return \"line\";\n const styleProp = findProperty(optsArg, \"style\");\n if (styleProp === undefined) return \"line\";\n const style = styleProp.initializer;\n if (!ts.isObjectLiteralExpression(style)) return undefined;\n const kindProp = findProperty(style, \"kind\");\n if (kindProp === undefined) return undefined;\n const kind = kindProp.initializer;\n if (!ts.isStringLiteral(kind)) return undefined;\n return isPlotKind(kind.text) ? kind.text : undefined;\n}\n\n/**\n * Read a string-literal `title` from a plotting callsite's opts object\n * literal. Returns `undefined` for a missing, dynamic, or non-string\n * `title` so the manifest omits the field rather than recording a\n * placeholder.\n *\n * @since 0.8\n * @example\n * // const title = readLiteralTitle(optsObjectLiteralNode);\n * // title === \"Vol\" | undefined\n * const fn: typeof readLiteralTitle = readLiteralTitle;\n * void fn;\n */\nexport function readLiteralTitle(optsArg: ts.Expression | undefined): string | undefined {\n if (optsArg === undefined || !ts.isObjectLiteralExpression(optsArg)) return undefined;\n const titleProp = findProperty(optsArg, \"title\");\n if (titleProp === undefined) return undefined;\n const title = titleProp.initializer;\n return ts.isStringLiteral(title) ? title.text : undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveCallee.js","sourceRoot":"","sources":["../../src/transformers/resolveCallee.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAuB,EAAE,OAAuB;IAC9E,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACnC,IAAI,EAAE,CAAC,0BAA0B,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5C,OAAO,yBAAyB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,qBAAqB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC7D,IAAI,SAAS,KAAK,IAAI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,EAAE,CAAC;IACnD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,QAAQ,KAAK,gBAAgB,CAAC,CAAC;AACtF,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport ts from \"typescript\";\n\nimport { CORE_MODULE_PATH } from \"../program.js\";\n\n/**\n * Resolve a `CallExpression`'s callee to its fully-qualified name. Returns\n * one of `\"ta.<method>\"`, `\"plot\"`, `\"hline\"`, `\"alert\"`,\n * `\"defineIndicator\"`, `\"defineAlert\"` for calls whose target comes from\n * `@invinite-org/chartlang-core`; returns `null` for everything else\n * (user-shadowed identifiers, computed access, optional chains, calls on\n * call results).\n *\n * Identifier callees are gated on the symbol's declaration source file\n * matching the core ambient module path so a user's `const plot = (x) => x;\n * plot(42);` is not mistaken for the core `plot` primitive.\n *\n * @since 0.1\n * @example\n * // const fqn = resolveCalleeName(callNode, checker);\n * // fqn === \"ta.ema\" | \"plot\" | \"alert\" | ... | null\n * const fn: typeof resolveCalleeName = resolveCalleeName;\n * void fn;\n */\nexport function resolveCalleeName(node: ts.CallExpression, checker: ts.TypeChecker): string | null {\n const expression = node.expression;\n if (ts.isPropertyAccessExpression(expression)) {\n return resolvePropertyAccessName(expression, checker);\n }\n if (ts.isIdentifier(expression)) {\n const canonical = resolveCoreSymbolName(checker, expression);\n if (canonical === null) return null;\n return canonical;\n }\n return null;\n}\n\nfunction resolvePropertyAccessName(\n expression: ts.PropertyAccessExpression,\n checker: ts.TypeChecker,\n): string | null {\n const segments: string[] = [expression.name.text];\n let current: ts.Expression = expression.expression;\n while (ts.isPropertyAccessExpression(current)) {\n segments.unshift(current.name.text);\n current = current.expression;\n }\n if (!ts.isIdentifier(current)) return null;\n const canonical = resolveCoreSymbolName(checker, current);\n if (canonical === null) return null;\n return [canonical, ...segments].join(\".\");\n}\n\n/**\n * Resolve the canonical core-export name for the *object* of an\n * `ElementAccessExpression` (`obj[...]`). Used by the callsite-id\n * transformer to detect element-access calls on core namespaces\n * (`ta[\"ema\"](...)`, `state[\"foo\"]?.()`) that would otherwise silently\n * skip slot-id injection. Returns the canonical name (e.g. `\"ta\"`) when\n * the object identifier resolves to a core symbol, or `null` when it\n * does not (user-shadowed identifier, non-core object, computed receiver).\n *\n * @since 0.1\n * @example\n * // const name = resolveCoreSymbolForElementAccess(node, checker);\n * // name === \"ta\" | null\n * const fn: typeof resolveCoreSymbolForElementAccess = resolveCoreSymbolForElementAccess;\n * void fn;\n */\nexport function resolveCoreSymbolForElementAccess(\n node: ts.ElementAccessExpression,\n checker: ts.TypeChecker,\n): string | null {\n const obj = node.expression;\n if (!ts.isIdentifier(obj)) return null;\n return resolveCoreSymbolName(checker, obj);\n}\n\n/**\n * Return the canonical core-export name for `identifier`, or `null` if\n * the identifier does not resolve to a `@invinite-org/chartlang-core`\n * symbol. Renamed imports (`import { ta as TA } from \"core\"; TA.ema(...)`)\n * map back to their export name (`\"ta\"`) so the resulting slot-id\n * matches what `STATEFUL_PRIMITIVES` expects.\n */\nfunction resolveCoreSymbolName(checker: ts.TypeChecker, identifier: ts.Identifier): string | null {\n const localSymbol = checker.getSymbolAtLocation(identifier);\n if (!localSymbol) return null;\n const target =\n localSymbol.flags & ts.SymbolFlags.Alias\n ? checker.getAliasedSymbol(localSymbol)\n : localSymbol;\n const declarations = target.declarations ?? [];\n if (declarations.some((d) => d.getSourceFile().fileName === CORE_MODULE_PATH)) {\n return target.getName();\n }\n // Destructured `compute({ ta, plot, ... })` binding: the symbol's\n // declaration is the binding element, not the core module. The\n // identifier's *type*, however, comes from `ComputeContext` (core)\n // — so a binding element whose type declaration originates in core\n // counts as a core symbol for the callsite-id transformer. The\n // canonical name is the binding's property name (or, when the\n // binding is renamed `{ ta: TA }`, the original property name).\n for (const declaration of declarations) {\n if (!ts.isBindingElement(declaration)) continue;\n // `{ ta }` → propertyName is undefined, fall back to identifier.\n // `{ ta: TA }` → propertyName is `ta`, identifier is `TA`.\n const propertyName = declaration.propertyName;\n const canonicalName =\n propertyName !== undefined && ts.isIdentifier(propertyName)\n ? propertyName.text\n : identifier.text;\n if (bindingElementComesFromCoreContext(checker, declaration, canonicalName)) {\n return canonicalName;\n }\n const type = checker.getTypeAtLocation(identifier);\n const typeSymbol = type.getSymbol();\n /* v8 ignore next */\n if (typeSymbol === undefined) continue;\n /* v8 ignore next */\n const typeDecls = typeSymbol.declarations ?? [];\n if (!typeDecls.some((d) => d.getSourceFile().fileName === CORE_MODULE_PATH)) continue;\n if (propertyName !== undefined && ts.isIdentifier(propertyName)) {\n return propertyName.text;\n }\n return identifier.text;\n }\n return null;\n}\n\nfunction bindingElementComesFromCoreContext(\n checker: ts.TypeChecker,\n declaration: ts.BindingElement,\n canonicalName: string,\n): boolean {\n const bindingPattern = declaration.parent;\n const bindingOwner = bindingPattern.parent;\n if (!ts.isObjectBindingPattern(bindingPattern) || !ts.isParameter(bindingOwner)) return false;\n const parameterType = checker.getTypeAtLocation(bindingOwner);\n const property = parameterType.getProperty(canonicalName);\n const propertyDecls = property?.declarations ?? [];\n return propertyDecls.some((d) => d.getSourceFile().fileName === CORE_MODULE_PATH);\n}\n"]}
|
|
@@ -1 +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,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AAO,CAAC,wBAAwB,CAC/B,OAAO,EACP,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAC/C;QACD,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAC/B,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"}
|
|
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,EAC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,4BAA4B,CAC1D,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACnB,EAAE,CAAC,OAAO,CAAC,6BAA6B,CACpC;QACI,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAC/B,OAAO,EACP,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAC/C;QACD,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAC/B,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","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { OutputDeclaration } from \"@invinite-org/chartlang-core\";\nimport ts from \"typescript\";\n\nimport type { DepGraph } from \"../analysis/extractDependencyGraph.js\";\nimport type { CompileDiagnostic } from \"../diagnostics.js\";\n\n/**\n * Result of `rewriteDependencyAccessors`. `transformed` is the new\n * source file where every consumer-side `<binding>.output(\"title\")`\n * call has been replaced with the synthesised\n * `__chartlang_depOutput(\"slotId\", \"localId\", \"title\")` call the\n * runtime's dep executor (Phase 7 / Task 4) consumes.\n *\n * @since 0.7\n * @stable\n * @example\n * const r: RewriteDependencyAccessorsResult = {\n * transformed: undefined as unknown as ts.SourceFile,\n * diagnostics: [],\n * };\n * void r;\n */\nexport type RewriteDependencyAccessorsResult = Readonly<{\n readonly transformed: ts.SourceFile;\n readonly diagnostics: ReadonlyArray<CompileDiagnostic>;\n}>;\n\nconst DEP_OUTPUT_HELPER = \"__chartlang_depOutput\";\n\n/**\n * Rewrite every consumer-side `<binding>.output(\"title\")` call into\n * `__chartlang_depOutput(\"slotId\", \"localId\", \"title\")`. The receiver\n * traces back to a binding declared in the file's\n * {@link DepGraph}; the slot id follows the existing\n * `<sourcePath>:<line>:<col>#0` format (Phase 1 §5.5) read from the\n * **input** source file before any rewrite. Bindings that are not\n * part of the dep graph (zero consumes, unknown receivers) are\n * left untouched — they would already have raised diagnostics during\n * `extractDependencyGraph`.\n *\n * The same pass injects each producer binding's statically-resolved\n * titled `outputs` into its `defineIndicator({...})` opts literal so\n * the runtime object built by `defineIndicator` carries\n * `manifest.outputs` directly. Without this, a sibling- or dep-mounted\n * producer's `manifest.outputs` is `undefined` at runtime — the host\n * never allocates a {@link DepOutputStore} ring buffer for it and the\n * consumer's `.output(\"title\")` reads NaN every bar (Phase-7\n * composition bug). The compiler already computes these outputs in\n * `extractDependencyGraph`; here they are baked onto the producer\n * object so every host path (worker, quickjs, conformance) wires the\n * store with zero assembler changes. The injection is scoped to\n * bindings that are producers within a composition graph — private\n * deps and named-export siblings always, the default export only when\n * the file participates in composition (multi-export or has private\n * deps) or is itself consumed cross-file — so a standalone\n * single-export script with no deps stays byte-identical.\n *\n * Runs **before** `injectCallsiteIds` so the synthesised\n * `__chartlang_depOutput` carries a slot id read from the original\n * source positions.\n *\n * @since 0.7\n * @stable\n * @example\n * // Input: fastTrend.output(\"line\")\n * // Output: __chartlang_depOutput(\"demo.chart.ts:6:14#0\", \"fastTrend\", \"line\")\n * const fn: typeof rewriteDependencyAccessors = rewriteDependencyAccessors;\n * void fn;\n */\nexport function rewriteDependencyAccessors(\n sourceFile: ts.SourceFile,\n depGraph: DepGraph,\n sourcePath: string,\n): RewriteDependencyAccessorsResult {\n const knownLocalIds = new Set<string>();\n for (const drawn of depGraph.drawn) knownLocalIds.add(drawn.bindingName);\n for (const dep of depGraph.privateDeps) knownLocalIds.add(dep.localId);\n const outputsByDefineCall = collectProducerOutputs(depGraph);\n // `withInputs`-derived aliases (synthetic private deps with no\n // `defineCall` of their own). Every such alias's declaration is\n // rewritten from `const <alias> = <root>.withInputs({...})...;` to\n // `const <alias> = <root>;` so the runtime sentinel never fires\n // when the bundle is loaded. The merged effective inputs flow into\n // the dep runner through the manifest's `dependencies` entry; the\n // alias binding itself just needs to be a `CompiledScriptObject`\n // reference.\n const aliasLocalIds = new Set<string>();\n for (const dep of depGraph.privateDeps) {\n if (dep.defineCall === null) aliasLocalIds.add(dep.localId);\n }\n\n const factory: ts.TransformerFactory<ts.SourceFile> = (context) => {\n const visit: ts.Visitor = (node) => {\n if (ts.isCallExpression(node)) {\n const outputs = outputsByDefineCall.get(node);\n if (outputs !== undefined) {\n const injected = injectOutputsIntoDefineCall(node, outputs);\n return ts.visitEachChild(injected, visit, context);\n }\n }\n if (\n ts.isVariableDeclaration(node) &&\n ts.isIdentifier(node.name) &&\n aliasLocalIds.has(node.name.text) &&\n node.initializer !== undefined\n ) {\n const root = resolveChainRoot(node.initializer);\n if (root !== null) {\n return ts.factory.updateVariableDeclaration(\n node,\n node.name,\n node.exclamationToken,\n node.type,\n ts.factory.createIdentifier(root.text),\n );\n }\n }\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === \"output\"\n ) {\n const arg = node.arguments[0];\n if (arg !== undefined && ts.isStringLiteral(arg)) {\n const receiverRoot = resolveReceiverRoot(node.expression.expression);\n if (receiverRoot !== null && knownLocalIds.has(receiverRoot.text)) {\n const start = node.getStart(sourceFile);\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);\n const slotId = `${sourcePath}:${line + 1}:${character + 1}#0`;\n return ts.factory.createCallExpression(\n ts.factory.createIdentifier(DEP_OUTPUT_HELPER),\n undefined,\n [\n ts.factory.createStringLiteral(slotId),\n ts.factory.createStringLiteral(receiverRoot.text),\n ts.factory.createStringLiteral(arg.text),\n ],\n );\n }\n }\n }\n return ts.visitEachChild(node, visit, context);\n };\n return (file) => ts.visitNode(file, visit, ts.isSourceFile) as ts.SourceFile;\n };\n\n const result = ts.transform(sourceFile, [factory]);\n const transformed = result.transformed[0];\n result.dispose();\n return Object.freeze({\n transformed,\n diagnostics: Object.freeze([] as ReadonlyArray<CompileDiagnostic>),\n });\n}\n\n/**\n * Walk back from a `<root>.withInputs({...}).withInputs({...})` chain\n * to its rooted identifier. The analysis pass already validates every\n * alias's chain shape (`dep-dynamic` errors abort the rewrite long\n * before we reach this function), so only the happy path is exercised\n * in production; the defensive `null` branches keep the rewriter\n * conservative if a future caller misuses it.\n */\nfunction resolveChainRoot(expression: ts.Expression): ts.Identifier | null {\n let current: ts.Expression = expression;\n while (ts.isCallExpression(current)) {\n const callee = current.expression;\n /* v8 ignore next 2 */\n if (!ts.isPropertyAccessExpression(callee)) return null;\n if (callee.name.text !== \"withInputs\") return null;\n current = callee.expression;\n }\n /* v8 ignore next 2 */\n if (!ts.isIdentifier(current)) return null;\n return current;\n}\n\n/**\n * Map each producer binding's original `defineIndicator(...)` call node\n * to the titled outputs that must be baked onto its runtime manifest.\n *\n * A binding is in scope when it has a real `defineCall` (withInputs\n * aliases have `null`) and declares at least one titled `plot(...)`\n * output. Every drawn binding — named-export sibling AND default — is a\n * potential producer: a same-file sibling can be consumed by the\n * default, and a single-export default can be consumed cross-file\n * (`import baseTrend from \"./base-trend.chart\"`). The compiler cannot\n * know during a producer file's own compile whether its default will be\n * imported elsewhere, so the default is always baked when it declares\n * titled outputs. This keeps cross-file producers self-describing\n * without an assembler change.\n *\n * Output-free bindings (no titled `plot`) are never touched, so a\n * standalone script that only emits untitled plots stays byte-identical.\n */\nfunction collectProducerOutputs(\n depGraph: DepGraph,\n): ReadonlyMap<ts.CallExpression, ReadonlyArray<OutputDeclaration>> {\n const map = new Map<ts.CallExpression, ReadonlyArray<OutputDeclaration>>();\n for (const dep of depGraph.privateDeps) {\n if (dep.defineCall !== null && dep.outputs.length > 0) {\n map.set(dep.defineCall, dep.outputs);\n }\n }\n for (const drawn of depGraph.drawn) {\n if (drawn.outputs.length > 0) map.set(drawn.defineCall, drawn.outputs);\n }\n return map;\n}\n\n/**\n * Append an `outputs: [{ title, kind }, ...]` property assignment to the\n * `defineIndicator({...})` opts object literal. The analysis pass\n * guarantees a producer binding's `defineCall` carries an object-literal\n * first argument, so the non-object-literal branch is defensive only.\n */\nfunction injectOutputsIntoDefineCall(\n call: ts.CallExpression,\n outputs: ReadonlyArray<OutputDeclaration>,\n): ts.CallExpression {\n const arg = call.arguments[0];\n /* v8 ignore next 3 */\n if (arg === undefined || !ts.isObjectLiteralExpression(arg)) {\n return call;\n }\n const outputsLiteral = ts.factory.createArrayLiteralExpression(\n outputs.map((output) =>\n ts.factory.createObjectLiteralExpression(\n [\n ts.factory.createPropertyAssignment(\n \"title\",\n ts.factory.createStringLiteral(output.title),\n ),\n ts.factory.createPropertyAssignment(\n \"kind\",\n ts.factory.createStringLiteral(output.kind),\n ),\n ],\n false,\n ),\n ),\n false,\n );\n const updatedArg = ts.factory.updateObjectLiteralExpression(arg, [\n ...arg.properties,\n ts.factory.createPropertyAssignment(\"outputs\", outputsLiteral),\n ]);\n return ts.factory.updateCallExpression(call, call.expression, call.typeArguments, [\n updatedArg,\n ...call.arguments.slice(1),\n ]);\n}\n\nfunction resolveReceiverRoot(receiver: ts.Expression): ts.Identifier | null {\n // extractDependencyGraph validates that every `.output(...)` call\n // reaching the rewriter has a bare identifier receiver (or a\n // withInputs-aliased binding name we already collapsed in the\n // graph). The defensive null return is exercised by the\n // \"leaves unknown .output() receivers untouched\" test case where\n // the receiver type isn't an Identifier (it's a PropertyAccess).\n if (ts.isIdentifier(receiver)) return receiver;\n return null;\n}\n"]}
|
package/dist/typesEmit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesEmit.js","sourceRoot":"","sources":["../src/typesEmit.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAwB/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,SAAS,CAAC,IAAsB;IAC5C,MAAM,SAAS,GAAkC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzE,CAAC,CAAC,IAAI,CAAC,QAAQ;QACf,CAAC,CAAC,CAAC,IAAI,CAAC,QAA0B,CAAC,CAAC;IAExC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAmB,CAAC,EAAE,CAAC;QAC/E,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,OAAO,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,eAAe,GAAG;;;;;;;CAOvB,CAAC;AAEF,SAAS,iBAAiB,CAAC,QAAwB;IAC/C,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,KAAK,SAAS,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACjF,MAAM,eAAe,GAAG,QAAQ,CAAC,YAAY,KAAK,SAAS,IAAI,QAAQ,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAChG,OAAO,UAAU,IAAI,eAAe,CAAC;AACzC,CAAC;AAED,SAAS,qBAAqB,CAAC,SAAwC;IACnE,MAAM,KAAK,GAAa;QACpB,uDA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AAQ,CAAC;IACnB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,UAAU,EAAE,QAAQ,CAAC;IACtB,CAAC,MAAM,EAAE,SAAS,CAAC;IACnB,CAAC,iBAAiB,EAAE,SAAS,CAAC;CACjC,CAAC,CAAC;AAEH,SAAS,kBAAkB,CAAC,UAA6C;IACrE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAC7B,sBAAsB;IACtB,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC/C,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC;AAClD,CAAC;AAED,MAAM,eAAe,GAAG,4BAA4B,CAAC;AACrD,SAAS,aAAa,CAAC,GAAW;IAC9B,oBAAoB;IACpB,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AACjE,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { ScriptManifest } from \"@invinite-org/chartlang-core\";\n\n/**\n * Options accepted by `emitTypes`. `manifest` accepts either a single\n * `ScriptManifest` (single-script files) or an array of manifests for\n * multi-export indicator-composition files. `sourcePath` is reserved so a\n * future generator can embed it into the declarations as a comment when\n * source navigation surfaces land.\n *\n * @since 0.1\n * @example\n * const opts: EmitTypesOptions = {\n * manifest: { } as never,\n * sourcePath: \"demo.chart.ts\",\n * };\n * void opts;\n */\nexport type EmitTypesOptions = Readonly<{\n manifest: ScriptManifest | ReadonlyArray<ScriptManifest>;\n sourcePath: string;\n}>;\n\n/**\n * Generate the `.d.ts` sibling for a compiled script. Single-script files\n * with no `outputs` / `dependencies` emit the Phase-1 minimal declarations\n * byte-identically so existing snapshot tests stay green. Multi-export\n * files (array input) or single-export files carrying `outputs` /\n * `dependencies` emit per-binding typed declarations — `output<K extends\n * \"title1\" | \"title2\">(name: K): Series<number>` overloads + `withInputs`\n * typed against the binding's `inputs` schema.\n *\n * @since 0.1\n * @example\n * // const dts = emitTypes({ manifest, sourcePath: \"demo.chart.ts\" });\n * // dts.includes(\"export default script\");\n * const fn: typeof emitTypes = emitTypes;\n * void fn;\n */\nexport function emitTypes(opts: EmitTypesOptions): string {\n const manifests: ReadonlyArray<ScriptManifest> = Array.isArray(opts.manifest)\n ? opts.manifest\n : [opts.manifest as ScriptManifest];\n\n if (manifests.length === 1 && !needsTypedExports(manifests[0] as ScriptManifest)) {\n return BACK_COMPAT_DTS;\n }\n\n return emitTypedDeclarations(manifests);\n}\n\nconst BACK_COMPAT_DTS = `// auto-generated by @invinite-org/chartlang-compiler\nimport type { CompiledScriptObject, ScriptManifest } from \"@invinite-org/chartlang-core\";\n\ndeclare const script: CompiledScriptObject;\nexport default script;\n\nexport declare const __manifest: ScriptManifest;\n`;\n\nfunction needsTypedExports(manifest: ScriptManifest): boolean {\n const hasOutputs = manifest.outputs !== undefined && manifest.outputs.length > 0;\n const hasDependencies = manifest.dependencies !== undefined && manifest.dependencies.length > 0;\n return hasOutputs || hasDependencies;\n}\n\nfunction emitTypedDeclarations(manifests: ReadonlyArray<ScriptManifest>): string {\n const lines: string[] = [\n \"// auto-generated by @invinite-org/chartlang-compiler\",\n 'import type { CompiledScriptObject, ScriptManifest, Series } from \"@invinite-org/chartlang-core\";',\n \"\",\n ];\n\n for (const m of manifests) {\n const exportName = m.exportName ?? \"default\";\n const localName = exportName === \"default\" ? \"script\" : exportName;\n lines.push(\n `declare const ${localName}: CompiledScriptObject & {`,\n ` output${outputOverloadSignature(m)}: Series<number>;`,\n ` withInputs(overrides: ${inputsOverrideType(m)}): typeof ${localName};`,\n \"};\",\n );\n if (exportName === \"default\") {\n lines.push(`export default ${localName};`, \"\");\n } else {\n lines.push(`export { ${localName} };`, \"\");\n }\n }\n\n const manifestType = manifests.length > 1 ? \"ReadonlyArray<ScriptManifest>\" : \"ScriptManifest\";\n lines.push(`export declare const __manifest: ${manifestType};`, \"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction outputOverloadSignature(manifest: ScriptManifest): string {\n const outputs = manifest.outputs ?? [];\n if (outputs.length === 0) {\n return \"<K extends never>(name: K)\";\n }\n const titleUnion = outputs.map((o) => JSON.stringify(o.title)).join(\" | \");\n return `<K extends ${titleUnion}>(name: K)`;\n}\n\nfunction inputsOverrideType(manifest: ScriptManifest): string {\n const inputs = manifest.inputs;\n const keys = Object.keys(inputs);\n if (keys.length === 0) {\n return \"Readonly<Record<string, never>>\";\n }\n const fields: string[] = [];\n for (const key of keys) {\n const descriptor = inputs[key] as Readonly<Record<string, unknown>>;\n const tsType = descriptorToTsType(descriptor);\n fields.push(`${quoteFieldKey(key)}?: ${tsType}`);\n }\n /* v8 ignore next */\n return `Readonly<{ ${fields.join(\"; \")} }>`;\n}\n\nconst KIND_TO_TS_TYPE: ReadonlyMap<string, string> = new Map([\n [\"int\", \"number\"],\n [\"float\", \"number\"],\n [\"price\", \"number\"],\n [\"time\", \"number\"],\n [\"string\", \"string\"],\n [\"enum\", \"string\"],\n [\"color\", \"string\"],\n [\"source\", \"string\"],\n [\"symbol\", \"string\"],\n [\"interval\", \"string\"],\n [\"bool\", \"boolean\"],\n [\"external-series\", \"unknown\"],\n]);\n\nfunction descriptorToTsType(descriptor: Readonly<Record<string, unknown>>): string {\n const kind = descriptor.kind;\n /* v8 ignore next 2 */\n if (typeof kind !== \"string\") return \"unknown\";\n return KIND_TO_TS_TYPE.get(kind) ?? \"unknown\";\n}\n\nconst SAFE_FIELD_NAME = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\nfunction quoteFieldKey(key: string): string {\n /* v8 ignore next */\n return SAFE_FIELD_NAME.test(key) ? key : JSON.stringify(key);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@invinite-org/chartlang-compiler",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "TypeScript transformer + bundler for .chart.ts files",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"esbuild": "^0.24.0",
|
|
23
23
|
"typescript": "^5.6.0",
|
|
24
|
-
"@invinite-org/chartlang-core": "1.1.
|
|
24
|
+
"@invinite-org/chartlang-core": "1.1.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^20.0.0",
|