@invinite-org/chartlang-core 1.0.1 → 1.1.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 +98 -0
- package/README.md +6 -1
- package/dist/alert/alert.d.ts +1 -1
- package/dist/alert/alert.js +1 -1
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert/index.js.map +1 -1
- package/dist/color/colorHelpers.js.map +1 -1
- package/dist/color/index.js.map +1 -1
- package/dist/color/parseColor.js.map +1 -1
- package/dist/define/defineAlert.d.ts.map +1 -1
- package/dist/define/defineAlert.js +3 -2
- package/dist/define/defineAlert.js.map +1 -1
- package/dist/define/defineAlertCondition.d.ts.map +1 -1
- package/dist/define/defineAlertCondition.js +2 -1
- package/dist/define/defineAlertCondition.js.map +1 -1
- package/dist/define/defineDrawing.d.ts +2 -2
- package/dist/define/defineDrawing.d.ts.map +1 -1
- package/dist/define/defineDrawing.js +5 -4
- package/dist/define/defineDrawing.js.map +1 -1
- package/dist/define/defineIndicator.d.ts +11 -0
- package/dist/define/defineIndicator.d.ts.map +1 -1
- package/dist/define/defineIndicator.js +5 -2
- package/dist/define/defineIndicator.js.map +1 -1
- package/dist/define/depAccessorSentinel.d.ts +46 -0
- package/dist/define/depAccessorSentinel.d.ts.map +1 -0
- package/dist/define/depAccessorSentinel.js +51 -0
- package/dist/define/depAccessorSentinel.js.map +1 -0
- package/dist/define/dependency.d.ts +63 -0
- package/dist/define/dependency.d.ts.map +1 -0
- package/dist/define/dependency.js +4 -0
- package/dist/define/dependency.js.map +1 -0
- package/dist/define/index.d.ts +1 -0
- package/dist/define/index.d.ts.map +1 -1
- package/dist/define/index.js.map +1 -1
- package/dist/define/overrides.js.map +1 -1
- package/dist/draw/buckets.js.map +1 -1
- package/dist/draw/draw.d.ts +2 -3
- package/dist/draw/draw.d.ts.map +1 -1
- package/dist/draw/draw.js +1 -2
- package/dist/draw/draw.js.map +1 -1
- package/dist/draw/drawingKind.d.ts +1 -1
- package/dist/draw/drawingKind.js.map +1 -1
- package/dist/draw/drawingState.d.ts +5 -5
- package/dist/draw/drawingState.js.map +1 -1
- package/dist/draw/drawingStyle.d.ts +1 -1
- package/dist/draw/drawingStyle.js.map +1 -1
- package/dist/draw/handle.js.map +1 -1
- package/dist/draw/index.js.map +1 -1
- package/dist/draw/table.d.ts +1 -1
- package/dist/draw/table.js.map +1 -1
- package/dist/draw/worldPoint.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/input/index.js.map +1 -1
- package/dist/input/input.js.map +1 -1
- package/dist/input/inputDescriptor.js.map +1 -1
- package/dist/interval/intervalToSeconds.js.map +1 -1
- package/dist/plot/index.js.map +1 -1
- package/dist/plot/plot.d.ts +25 -7
- package/dist/plot/plot.d.ts.map +1 -1
- package/dist/plot/plot.js +1 -1
- package/dist/plot/plot.js.map +1 -1
- package/dist/request/index.js.map +1 -1
- package/dist/request/request.js.map +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/state/index.d.ts +1 -1
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js.map +1 -1
- package/dist/state/mutableSlot.js.map +1 -1
- package/dist/state/snapshot.d.ts +39 -12
- package/dist/state/snapshot.d.ts.map +1 -1
- package/dist/state/snapshot.js.map +1 -1
- package/dist/state/state.js.map +1 -1
- package/dist/statefulPrimitives.d.ts +1 -1
- package/dist/statefulPrimitives.js +1 -1
- package/dist/statefulPrimitives.js.map +1 -1
- package/dist/ta/index.js.map +1 -1
- package/dist/ta/ta.d.ts +41 -41
- package/dist/ta/ta.js.map +1 -1
- package/dist/time/_lib/dateTimeFormatCache.js.map +1 -1
- package/dist/time/index.js.map +1 -1
- package/dist/time/nyDayKey.js +2 -2
- package/dist/time/nyDayKey.js.map +1 -1
- package/dist/time/session.js.map +1 -1
- package/dist/time/sessionBoundaries.js +2 -2
- package/dist/time/sessionBoundaries.js.map +1 -1
- package/dist/time/types.js.map +1 -1
- package/dist/time/weekKey.js.map +1 -1
- package/dist/time/weekday.js.map +1 -1
- package/dist/types.d.ts +246 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +17 -1
- package/dist/types.js.map +1 -1
- package/dist/views/barstate.js.map +1 -1
- package/dist/views/index.js.map +1 -1
- package/dist/views/syminfo.js.map +1 -1
- package/dist/views/timeframe.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,103 @@
|
|
|
1
1
|
# @invinite-org/chartlang-core
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 71ea0a5: Inline original TypeScript sources into emitted `.js.map` files (`inlineSources: true`). Published sourcemaps no longer reference missing `../src/*.ts` files, fixing "points to missing source files" warnings in downstream bundlers (e.g. Vite).
|
|
8
|
+
|
|
9
|
+
## 1.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- f0c8eb8: Add `CompiledScriptObject.output` / `.withInputs` sentinels, `DependencyDeclaration` + `OutputDeclaration` types, optional `dependencies` / `outputs` / `exportName` / `siblings` / `isDrawn` fields on `ScriptManifest`, `CompiledScriptBundle` + `isCompiledScriptBundle` narrowing helper, and six new `dep-*` `DiagnosticCode` entries (`dep-error`, `dep-cycle`, `dep-unknown-output`, `dep-invalid-input-override`, `dep-dynamic`, `dep-output-not-titled`). The compiler ambient shim is widened in lockstep so script source resolves the new surface. Additive within `apiVersion: 1`.
|
|
14
|
+
- 2123181: Structured `StateSnapshot` carrying per-runner slot sections (primary +
|
|
15
|
+
siblings + dependencies) so a `CompiledScriptBundle`'s cold-replay
|
|
16
|
+
emissions match its warm-restart emissions byte-identically. Slot keys
|
|
17
|
+
now carry the active runner's `slotIdPrefix` everywhere they reach a
|
|
18
|
+
`StateStore` (`dep:<localId>/` for deps, `export:<exportName>/` for
|
|
19
|
+
siblings, empty for the primary). Flat-shape snapshots from before this
|
|
20
|
+
release continue to load back-compat as primary-only.
|
|
21
|
+
- 2123181: Indicator composition (Phase 7 closeout): one chartlang indicator can
|
|
22
|
+
read another indicator's titled plot output as a typed `Series<number>`.
|
|
23
|
+
|
|
24
|
+
- Compose via local `const` binding plus `<binding>.output("title")` —
|
|
25
|
+
no new public API beyond the chainable `.output` / `.withInputs`
|
|
26
|
+
accessors on `CompiledScriptObject`.
|
|
27
|
+
- A single `.chart.ts` MAY declare a default export plus any number of
|
|
28
|
+
named exports plus any number of private `const` deps. Export form
|
|
29
|
+
determines render policy: drawn exports render with the
|
|
30
|
+
`export:<exportName>/` slot-id prefix; private `const` deps are data
|
|
31
|
+
feeds only and their visuals are dropped.
|
|
32
|
+
- Cross-file `import baseTrend from "./base-trend.chart"` resolves
|
|
33
|
+
recursively; shared producers inline exactly once per consumer.
|
|
34
|
+
- Additive within `apiVersion: 1.x`. The 172-entry
|
|
35
|
+
`STATEFUL_PRIMITIVES` set is unchanged. `DiagnosticCode` widens to 32
|
|
36
|
+
with the new `dep-*` codes (`dep-error`, `dep-cycle`,
|
|
37
|
+
`dep-unknown-output`, `dep-invalid-input-override`, `dep-dynamic`,
|
|
38
|
+
`dep-output-not-titled`).
|
|
39
|
+
- Five conformance scenarios in `@invinite-org/chartlang-conformance`
|
|
40
|
+
pin the runtime contract end-to-end (`dep-private-single-file`,
|
|
41
|
+
`dep-multi-export`, `dep-cross-file`, `dep-diamond`,
|
|
42
|
+
`dep-error-halts-parent`). `Scenario.additionalSources` lets
|
|
43
|
+
cross-file scenarios ship producer + consumer side-by-side.
|
|
44
|
+
- Two new example scripts in `examples/scripts/`:
|
|
45
|
+
`base-trend.chart.ts` (producer) + `trend-confirmation.chart.ts`
|
|
46
|
+
(multi-export consumer). React-demo gains a fifth catalogue entry
|
|
47
|
+
exercising the feature end-to-end in the browser.
|
|
48
|
+
- Docs: `docs/language/indicator-composition.md` narrative guide,
|
|
49
|
+
`docs/spec/manifest.md` + `docs/spec/semantics.md` +
|
|
50
|
+
`docs/spec/versioning.md` updates, five new glossary entries.
|
|
51
|
+
|
|
52
|
+
- 2123181: Light up the end-to-end cross-file dep path for indicator composition. The
|
|
53
|
+
compiler's `rewriteDependencyAccessors` transformer now collapses
|
|
54
|
+
`const <alias> = <root>.withInputs({...})...` chains to the bare root
|
|
55
|
+
identifier so the runtime sentinel never fires at module load; the merged
|
|
56
|
+
effective inputs flow through the `__dependencies[i].inputOverrides` slot
|
|
57
|
+
into the runtime's `DepRunner`. Cross-file producers' `@invinite-org/chartlang-core`
|
|
58
|
+
imports are hoisted above the inlined IIFE so esbuild dedupes them against
|
|
59
|
+
the consumer's imports and pulls in every symbol the producer uses
|
|
60
|
+
(`input.int`, `ta.ema`, …). The `__dependencies` export is now prepended
|
|
61
|
+
pre-bundle so esbuild's tree-shaker keeps each alias binding alive. The
|
|
62
|
+
`dep-cross-file` conformance scenario joins `ALL_SCENARIOS` and the suite
|
|
63
|
+
runs 225 scenarios green.
|
|
64
|
+
- 4d77f4d: Add the additive plot-override contract: `PlotSlotDescriptor`,
|
|
65
|
+
`PlotOverride`, `ScriptManifest.plots?`, `PlotEmission.visible?`, and
|
|
66
|
+
`Adapter.resolvePlotOverrides?`. `validateEmission` now accepts an
|
|
67
|
+
optional `visible: boolean` arm on plot emissions and rejects any
|
|
68
|
+
other type via the existing `malformed-emission` path.
|
|
69
|
+
|
|
70
|
+
No behavior changes ship in this contract step — every new field is
|
|
71
|
+
optional and absence keeps emissions byte-identical to today. The
|
|
72
|
+
compiler's ambient core shim gains `PlotSlotDescriptor` and the
|
|
73
|
+
`ScriptManifest.plots?` field so script-side `__manifest` consumers
|
|
74
|
+
stay in lockstep; `PlotOverride` is intentionally not shimmed (it is
|
|
75
|
+
runtime-/host-side only).
|
|
76
|
+
|
|
77
|
+
- 0427459: Persist `defineIndicator({ overlay })` onto `ScriptManifest.overlay?:
|
|
78
|
+
boolean` so the runtime has a script-level default-pane signal. Add
|
|
79
|
+
`HLineOpts.pane?: "overlay" | "new" | string` mirroring `PlotOpts.pane`
|
|
80
|
+
so hlines opt into the same pane router. The compiler's `buildManifest`
|
|
81
|
+
extracts the literal-boolean `overlay` from the `defineIndicator`
|
|
82
|
+
object literal via `extractOverrides` and emits it on the bundled
|
|
83
|
+
`__manifest`; the ambient core shim now carries `ScriptManifest.overlay?`
|
|
84
|
+
and `HLineOpts.pane?` to keep downstream packages type-aligned.
|
|
85
|
+
|
|
86
|
+
Step 1 of the `subpane-rendering` feature. Pure additive contract
|
|
87
|
+
change — every new field is optional and absence keeps existing
|
|
88
|
+
manifests / emissions byte-identical. The runtime, adapter, and demos
|
|
89
|
+
land in tasks 2-5.
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- d6d1a1f: Fix Phase-7 indicator composition where a producer's titled `plot(...)` outputs were never wired to consumers. The compiler computed each binding's `outputs` statically but only wrote them into the manifest sidecar, never onto the producer object's own `manifest.outputs` — so the runtime allocated no dep-output ring buffer and every `<binding>.output("title")` read returned NaN past warmup.
|
|
94
|
+
|
|
95
|
+
`defineIndicator` now copies an optional `outputs` opts field into the manifest (omitted ⇒ manifest byte-identical to a script with no titled plots), and the compiler bakes each producer binding's titled `outputs` into its `defineIndicator({...})` opts literal so private deps, named-export siblings, and cross-file producer defaults are self-describing at runtime. Output-free scripts are untouched. Additive within `apiVersion: 1`.
|
|
96
|
+
|
|
97
|
+
- 3b4952d: Remove the redundant `bars` plot kind. It was never reachable from the script-author API (`PlotOptsStyle` had no `bars` arm and the runtime `buildStyle` had no `case`), no `ta.*` primitive or example emitted it, and the canvas2d reference adapter declared it as a capability but never rendered it. It carried the same `{ baseline: number }` shape as `histogram`, so it was a dead arm of the `PlotKind` / wire-level `PlotStyle` unions.
|
|
98
|
+
|
|
99
|
+
`PlotKind`, the adapter-kit `PlotStyle` union, `validateEmission`, the `capabilities.bars()` / `PHASE_5_PLOT_KINDS` surfaces, and the canvas2d adapter's dead `bars.ts` renderer are all dropped. chartlang has no users yet, so this is a hard reset with no deprecation path. Authors who want columns use `histogram`.
|
|
100
|
+
|
|
3
101
|
## 1.0.1
|
|
4
102
|
|
|
5
103
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -22,9 +22,14 @@ pnpm add @invinite-org/chartlang-core
|
|
|
22
22
|
- Secondary stream: `request.security({ interval })` typed surface.
|
|
23
23
|
- Emissions: `plot`, `hline`, `alert`, and the 61-kind `draw.*` namespace.
|
|
24
24
|
- Registry: `STATEFUL_PRIMITIVES` for compiler slot-id injection.
|
|
25
|
+
- Indicator composition (Phase 7): `CompiledScriptObject.output(title)` /
|
|
26
|
+
`.withInputs(overrides)` accessors for binding one indicator's output to
|
|
27
|
+
another. Both are compiler-rewritten sentinels — direct invocation throws.
|
|
28
|
+
`isCompiledScriptBundle(v)` narrows the multi-script bundle.
|
|
25
29
|
- Types: `Series<T>`, `Bar`, `InputDescriptor`, `MutableSlot<T>`,
|
|
26
30
|
`ScriptManifest`, `ComputeContext`, `DrawingState`, `DrawingHandle`,
|
|
27
|
-
`DrawingCounts`, `SecurityBar`, view types,
|
|
31
|
+
`DrawingCounts`, `SecurityBar`, view types, option/result types, plus
|
|
32
|
+
`DependencyDeclaration`, `OutputDeclaration`, `CompiledScriptBundle`.
|
|
28
33
|
|
|
29
34
|
## Minimum-viable API call
|
|
30
35
|
|
package/dist/alert/alert.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type AlertOpts = Readonly<{
|
|
|
17
17
|
}>;
|
|
18
18
|
/**
|
|
19
19
|
* Compile-time callable hole for `alert(message, opts?)`. The compiler
|
|
20
|
-
* rewrites every callsite
|
|
20
|
+
* rewrites every callsite to dispatch to the runtime; calling this
|
|
21
21
|
* outside the runtime throws the sentinel.
|
|
22
22
|
*
|
|
23
23
|
* @since 0.1
|
package/dist/alert/alert.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
3
|
/**
|
|
4
4
|
* Compile-time callable hole for `alert(message, opts?)`. The compiler
|
|
5
|
-
* rewrites every callsite
|
|
5
|
+
* rewrites every callsite to dispatch to the runtime; calling this
|
|
6
6
|
* outside the runtime throws the sentinel.
|
|
7
7
|
*
|
|
8
8
|
* @since 0.1
|
package/dist/alert/alert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/alert/alert.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAqB/D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,KAAiB;IACrD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AAC7D,CAAC"}
|
|
1
|
+
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/alert/alert.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAqB/D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,KAAiB;IACrD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AAC7D,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 { AlertSeverity, JsonValue } from \"../types.js\";\n\n/**\n * Styling and metadata options accepted by `alert(...)`. `severity` defaults\n * to `\"info\"`; `meta` is round-tripped to the host as a JSON-serialisable\n * payload.\n *\n * @since 0.1\n * @example\n * const opts: AlertOpts = {\n * severity: \"warning\",\n * meta: { reason: \"crossover\", strength: 0.42 },\n * };\n */\nexport type AlertOpts = Readonly<{\n severity?: AlertSeverity;\n meta?: Readonly<Record<string, JsonValue>>;\n}>;\n\n/**\n * Compile-time callable hole for `alert(message, opts?)`. The compiler\n * rewrites every callsite to dispatch to the runtime; calling this\n * outside the runtime throws the sentinel.\n *\n * @since 0.1\n * @stable\n * @example\n * // Inside a compiled `compute`:\n * // alert(\"EMA crossed\", { severity: \"info\" });\n * import { alert } from \"@invinite-org/chartlang-core\";\n * try { alert(\"noop\"); } catch {}\n */\nexport function alert(_message: string, _opts?: AlertOpts): void {\n throw new Error(\"alert called outside compiled runtime\");\n}\n"]}
|
package/dist/alert/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/alert/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/alert/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,cAAc,YAAY,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 * from \"./alert.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorHelpers.js","sourceRoot":"","sources":["../../src/color/colorHelpers.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAa7C,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAE7C,SAAS,SAAS,CAAC,KAAa;IAC5B,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC5B,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,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C;IAC3B,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,OAAO,GAAG,KAAK,KAAK,KAAK,IAAI,GAAG,CAAC;IACjE,OAAO,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,KAAc;IAC/D,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,OAAO,GAAG,KAAK,GAAG,MAAM,KAAK,IAAI,CAAC;IAClE,OAAO,QAAQ,GAAG,KAAK,GAAG,MAAM,KAAK,MAAM,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;AACjF,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 { Color } from \"../types.js\";\nimport { parseColor } from \"./parseColor.js\";\n\n/**\n * Gradient color stop for `color.fromGradient`.\n *\n * @since 0.5\n * @stable\n * @example\n * const stop: GradientStop = { at: 0, color: \"#0000ff\" };\n * void stop;\n */\nexport type GradientStop = Readonly<{ at: number; color: Color }>;\n\nconst TRANSPARENT_BLACK = \"rgba(0, 0, 0, 0)\";\n\nfunction clampUnit(value: number): number {\n if (Number.isNaN(value)) return 0;\n return Math.min(1, Math.max(0, value));\n}\n\nfunction clampByte(value: number): number {\n if (Number.isNaN(value)) return 0;\n return Math.min(255, Math.max(0, Math.floor(value)));\n}\n\nfunction clampHue(value: number): number {\n if (Number.isNaN(value)) return 0;\n return Math.min(359.999, Math.max(0, value));\n}\n\nfunction clampPercent(value: number): number {\n if (Number.isNaN(value)) return 0;\n return Math.min(100, Math.max(0, value));\n}\n\nfunction formatNumber(value: number): string {\n const rounded = Math.round(value * 1000) / 1000;\n return String(rounded);\n}\n\nfunction emitRgb(r: number, g: number, b: number, alpha: number): Color {\n if (alpha >= 1) return `rgb(${r}, ${g}, ${b})`;\n return `rgba(${r}, ${g}, ${b}, ${formatNumber(alpha)})`;\n}\n\nfunction emitRgba(r: number, g: number, b: number, alpha: number): Color {\n return `rgba(${r}, ${g}, ${b}, ${formatNumber(alpha)})`;\n}\n\n/**\n * Dynamic color from a normalised position. `t` is clamped to `[0, 1]`;\n * out-of-range maps to the boundary stop. Stops must be pre-sorted by `at`\n * ascending. Empty stops return transparent black.\n *\n * Pine's `color.from_gradient`.\n *\n * @since 0.5\n * @stable\n * @example\n * // const blue = \"#0000ff\";\n * // const red = \"#ff0000\";\n * // color.fromGradient(0.5, [{ at: 0, color: blue }, { at: 1, color: red }]);\n */\nexport function fromGradient(t: number, stops: ReadonlyArray<GradientStop>): Color {\n const first = stops[0];\n if (first === undefined) return TRANSPARENT_BLACK;\n if (stops.length === 1 || Number.isNaN(t)) return first.color;\n\n const position = clampUnit(t);\n if (position <= first.at) return first.color;\n const last = stops[stops.length - 1];\n if (position >= last.at) return last.color;\n\n let previous = first;\n let next = last;\n for (let i = 1; i < stops.length; i += 1) {\n const candidate = stops[i];\n if (position <= candidate.at) {\n next = candidate;\n break;\n }\n previous = candidate;\n }\n\n const left = parseColor(previous.color);\n const right = parseColor(next.color);\n if (left === null || right === null) return previous.color;\n const ratio = (position - previous.at) / (next.at - previous.at);\n const alpha = left.a + (right.a - left.a) * ratio;\n return emitRgb(\n clampByte(left.r + (right.r - left.r) * ratio),\n clampByte(left.g + (right.g - left.g) * ratio),\n clampByte(left.b + (right.b - left.b) * ratio),\n clampUnit(alpha),\n );\n}\n\n/**\n * Override an existing color's alpha channel. `alpha` is clamped to\n * `[0, 1]`. NaN returns the input color unchanged. Pine's `color.new(c,\n * transp)` analogue using direct alpha.\n *\n * @since 0.5\n * @stable\n * @example\n * const c = withAlpha(\"#ff0000\", 0.5);\n * void c;\n */\nexport function withAlpha(c: Color, alpha: number): Color {\n if (Number.isNaN(alpha)) return c;\n const parsed = parseColor(c);\n if (parsed === null) return c;\n return emitRgba(parsed.r, parsed.g, parsed.b, clampUnit(alpha));\n}\n\n/**\n * Construct a color from RGB(A) components. Each component is clamped to\n * `[0, 255]`; alpha defaults to `1`. NaN components clamp to `0`.\n *\n * @since 0.5\n * @stable\n * @example\n * const red = rgb(255, 0, 0);\n * void red;\n */\nexport function rgb(r: number, g: number, b: number, alpha?: number): Color {\n const red = clampByte(r);\n const green = clampByte(g);\n const blue = clampByte(b);\n if (alpha === undefined) return `rgb(${red}, ${green}, ${blue})`;\n return emitRgba(red, green, blue, clampUnit(alpha));\n}\n\n/**\n * Construct a color from HSL(A) components. `h` is clamped to `[0, 360)`;\n * `s` and `l` are clamped to `[0, 100]`. Alpha defaults to `1`. NaN\n * components clamp to `0`.\n *\n * @since 0.5\n * @stable\n * @example\n * const red = hsl(0, 100, 50);\n * void red;\n */\nexport function hsl(h: number, s: number, l: number, alpha?: number): Color {\n const hue = formatNumber(clampHue(h));\n const sat = formatNumber(clampPercent(s));\n const light = formatNumber(clampPercent(l));\n if (alpha === undefined) return `hsl(${hue}, ${sat}%, ${light}%)`;\n return `hsla(${hue}, ${sat}%, ${light}%, ${formatNumber(clampUnit(alpha))})`;\n}\n"]}
|
package/dist/color/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/color/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGtE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/B,GAAG,aAAa;IAChB,YAAY;IACZ,SAAS;IACT,GAAG;IACH,GAAG;CACN,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/color/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGtE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/B,GAAG,aAAa;IAChB,YAAY;IACZ,SAAS;IACT,GAAG;IACH,GAAG;CACN,CAAC,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 { fromGradient, hsl, rgb, withAlpha } from \"./colorHelpers.js\";\nimport { COLOR_PALETTE } from \"./parseColor.js\";\n\nexport { fromGradient, hsl, rgb, withAlpha } from \"./colorHelpers.js\";\nexport type { GradientStop } from \"./colorHelpers.js\";\n\n/**\n * Pine-style color namespace. Includes the named palette plus dynamic\n * helpers for compute-time colors.\n *\n * @since 0.5\n * @stable\n * @example\n * const c = color.withAlpha(color.red, 0.5);\n * void c;\n */\nexport const color = Object.freeze({\n ...COLOR_PALETTE,\n fromGradient,\n withAlpha,\n rgb,\n hsl,\n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AAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QACtE,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,CAAC;IAED,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 { Color } from \"../types.js\";\n\n/**\n * Pine-style named palette values accepted by the color parser and exposed\n * through the `color` namespace.\n *\n * @internal\n * @since 0.5\n * @example\n * const red = COLOR_PALETTE.red;\n * void red;\n */\nexport const COLOR_PALETTE = Object.freeze({\n aqua: \"#00ffff\",\n black: \"#000000\",\n blue: \"#0000ff\",\n fuchsia: \"#ff00ff\",\n gray: \"#808080\",\n green: \"#008000\",\n lime: \"#00ff00\",\n maroon: \"#800000\",\n navy: \"#000080\",\n olive: \"#808000\",\n orange: \"#ffa500\",\n purple: \"#800080\",\n red: \"#ff0000\",\n silver: \"#c0c0c0\",\n teal: \"#008080\",\n white: \"#ffffff\",\n yellow: \"#ffff00\",\n});\n\ntype PaletteName = keyof typeof COLOR_PALETTE;\n\nconst HEX_SHORT = /^#([0-9a-f]{3})$/i;\nconst HEX_LONG = /^#([0-9a-f]{6})$/i;\nconst RGB = /^rgba?\\(\\s*([^,\\s]+)\\s*,\\s*([^,\\s]+)\\s*,\\s*([^,\\s]+)(?:\\s*,\\s*([^,\\s]+))?\\s*\\)$/i;\nconst HSL = /^hsla?\\(\\s*([^,\\s]+)\\s*,\\s*([^,\\s%]+)%\\s*,\\s*([^,\\s%]+)%(?:\\s*,\\s*([^,\\s]+))?\\s*\\)$/i;\n\nfunction isPaletteName(value: string): value is PaletteName {\n return Object.prototype.hasOwnProperty.call(COLOR_PALETTE, value);\n}\n\nfunction clampByte(value: number): number {\n return Math.min(255, Math.max(0, Math.floor(value)));\n}\n\nfunction clampRoundedByte(value: number): number {\n return Math.min(255, Math.max(0, Math.round(value)));\n}\n\nfunction clampUnit(value: number): number {\n return Math.min(1, Math.max(0, value));\n}\n\nfunction parseNumber(value: string): number | null {\n const parsed = Number(value);\n if (Number.isNaN(parsed)) return null;\n return parsed;\n}\n\nfunction hslToRgb(h: number, s: number, l: number): Readonly<{ r: number; g: number; b: number }> {\n const hue = Math.min(359.999, Math.max(0, h)) / 360;\n const sat = Math.min(100, Math.max(0, s)) / 100;\n const light = Math.min(100, Math.max(0, l)) / 100;\n\n if (sat === 0) {\n const gray = clampRoundedByte(light * 255);\n return { r: gray, g: gray, b: gray };\n }\n\n const q = light < 0.5 ? light * (1 + sat) : light + sat - light * sat;\n const p = 2 * light - q;\n const channel = (t: number): number => {\n let adjusted = t;\n if (adjusted < 0) adjusted += 1;\n if (adjusted > 1) adjusted -= 1;\n if (adjusted < 1 / 6) return p + (q - p) * 6 * adjusted;\n if (adjusted < 1 / 2) return q;\n if (adjusted < 2 / 3) return p + (q - p) * (2 / 3 - adjusted) * 6;\n return p;\n };\n\n return {\n r: clampRoundedByte(channel(hue + 1 / 3) * 255),\n g: clampRoundedByte(channel(hue) * 255),\n b: clampRoundedByte(channel(hue - 1 / 3) * 255),\n };\n}\n\n/**\n * Parse the CSS color forms chartlang emits: `#rgb`, `#rrggbb`,\n * `rgb(...)`, `rgba(...)`, `hsl(...)`, `hsla(...)`, and the named palette.\n * Returns `null` for unparseable input.\n *\n * @internal\n * @since 0.5\n * @example\n * const parsed = parseColor(\"#ff0000\");\n * void parsed;\n */\nexport function parseColor(\n c: Color,\n): Readonly<{ r: number; g: number; b: number; a: number }> | null {\n const value = c.trim().toLowerCase();\n if (isPaletteName(value)) return parseColor(COLOR_PALETTE[value]);\n\n const shortHex = HEX_SHORT.exec(value);\n if (shortHex) {\n const hex = shortHex[1];\n return {\n r: Number.parseInt(`${hex[0]}${hex[0]}`, 16),\n g: Number.parseInt(`${hex[1]}${hex[1]}`, 16),\n b: Number.parseInt(`${hex[2]}${hex[2]}`, 16),\n a: 1,\n };\n }\n\n const longHex = HEX_LONG.exec(value);\n if (longHex) {\n const hex = longHex[1];\n return {\n r: Number.parseInt(hex.slice(0, 2), 16),\n g: Number.parseInt(hex.slice(2, 4), 16),\n b: Number.parseInt(hex.slice(4, 6), 16),\n a: 1,\n };\n }\n\n const rgbMatch = RGB.exec(value);\n if (rgbMatch) {\n const r = parseNumber(rgbMatch[1]);\n const g = parseNumber(rgbMatch[2]);\n const b = parseNumber(rgbMatch[3]);\n const a = rgbMatch[4] === undefined ? 1 : parseNumber(rgbMatch[4]);\n if (r === null || g === null || b === null || a === null) return null;\n return { r: clampByte(r), g: clampByte(g), b: clampByte(b), a: clampUnit(a) };\n }\n\n const hslMatch = HSL.exec(value);\n if (hslMatch) {\n const h = parseNumber(hslMatch[1]);\n const s = parseNumber(hslMatch[2]);\n const l = parseNumber(hslMatch[3]);\n const a = hslMatch[4] === undefined ? 1 : parseNumber(hslMatch[4]);\n if (h === null || s === null || l === null || a === null) return null;\n return { ...hslToRgb(h, s, l), a: clampUnit(a) };\n }\n\n return null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineAlert.d.ts","sourceRoot":"","sources":["../../src/define/defineAlert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"defineAlert.d.ts","sourceRoot":"","sources":["../../src/define/defineAlert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,KAAK,cAAc,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC,CAAC;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,CAAC,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC;CACtB,CAAC,GACE,cAAc,CAAC;AAEnB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,oBAAoB,CA6BvE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import { attachDepAccessorSentinels } from "./depAccessorSentinel.js";
|
|
3
4
|
/**
|
|
4
5
|
* Construct a Phase-1 alert script object. Returns a frozen
|
|
5
6
|
* `CompiledScriptObject` whose `manifest.kind` is `"alert"` and whose
|
|
@@ -41,9 +42,9 @@ export function defineAlert(opts) {
|
|
|
41
42
|
: { requiresIntervals: opts.requiresIntervals }),
|
|
42
43
|
...(opts.shortName === undefined ? {} : { shortName: opts.shortName }),
|
|
43
44
|
};
|
|
44
|
-
return Object.freeze({
|
|
45
|
+
return Object.freeze(attachDepAccessorSentinels({
|
|
45
46
|
manifest: Object.freeze(manifest),
|
|
46
47
|
compute: opts.compute,
|
|
47
|
-
});
|
|
48
|
+
}));
|
|
48
49
|
}
|
|
49
50
|
//# sourceMappingURL=defineAlert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineAlert.js","sourceRoot":"","sources":["../../src/define/defineAlert.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;
|
|
1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,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO;KACxB,CAAC,CACL,CAAC;AACN,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 { CompiledScriptObject, ComputeFn, InputSchema } from \"../types.js\";\nimport { attachDepAccessorSentinels } from \"./depAccessorSentinel.js\";\nimport type { ScriptOverrides } from \"./overrides.js\";\n\ntype AlertOverrides = Omit<ScriptOverrides, \"scale\" | \"format\" | \"precision\">;\n\n/**\n * Author-supplied options the script passes to `defineAlert(...)`. Same shape\n * as `DefineIndicatorOpts` minus the indicator-only `overlay` flag — alert\n * scripts have no plot output.\n *\n * @since 0.1\n * @example\n * const opts: DefineAlertOpts = {\n * name: \"RSI overbought\",\n * apiVersion: 1,\n * compute: () => {},\n * };\n */\nexport type DefineAlertOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n compute: ComputeFn;\n}> &\n AlertOverrides;\n\n/**\n * Construct a Phase-1 alert script object. Returns a frozen\n * `CompiledScriptObject` whose `manifest.kind` is `\"alert\"` and whose\n * declared `capabilities` is `[\"alerts\"]`. Same compile-time override\n * semantics as `defineIndicator`.\n *\n * @since 0.1\n * @example\n * ```ts\n * import { defineAlert } from \"@invinite-org/chartlang-core\";\n *\n * export default defineAlert({\n * name: \"RSI > 70\",\n * apiVersion: 1,\n * compute: ({ alert }) => { alert(\"overbought\"); },\n * });\n * ```\n */\nexport function defineAlert(opts: DefineAlertOpts): CompiledScriptObject {\n const capabilities: ReadonlyArray<\"alerts\"> = Object.freeze<[\"alerts\"]>([\"alerts\"]);\n const requestedIntervals: ReadonlyArray<string> = Object.freeze<string[]>([]);\n const seriesCapacities: Readonly<Record<string, number>> = Object.freeze({});\n const base = {\n apiVersion: 1 as const,\n kind: \"alert\" as const,\n name: opts.name,\n inputs: opts.inputs ?? {},\n capabilities,\n requestedIntervals,\n userPickableInterval: false,\n seriesCapacities,\n maxLookback: 0,\n };\n const manifest = {\n ...base,\n ...(opts.maxBarsBack === undefined ? {} : { maxBarsBack: opts.maxBarsBack }),\n ...(opts.requiresIntervals === undefined\n ? {}\n : { requiresIntervals: opts.requiresIntervals }),\n ...(opts.shortName === undefined ? {} : { shortName: opts.shortName }),\n };\n return Object.freeze(\n attachDepAccessorSentinels({\n manifest: Object.freeze(manifest),\n compute: opts.compute,\n }),\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineAlertCondition.d.ts","sourceRoot":"","sources":["../../src/define/defineAlertCondition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,wBAAwB,EAExB,oBAAoB,EACpB,SAAS,EACT,WAAW,EAEd,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"defineAlertCondition.d.ts","sourceRoot":"","sources":["../../src/define/defineAlertCondition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,wBAAwB,EAExB,oBAAoB,EACpB,SAAS,EACT,WAAW,EAEd,MAAM,aAAa,CAAC;AAGrB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,CAAC,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC;IAC/D,OAAO,EAAE,SAAS,CAAC;CACtB,CAAC,CAAC;AAcH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,wBAAwB,GAAG,oBAAoB,CAoBzF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import { attachDepAccessorSentinels } from "./depAccessorSentinel.js";
|
|
3
4
|
function freezeCondition(id, descriptor) {
|
|
4
5
|
return Object.freeze({
|
|
5
6
|
id,
|
|
@@ -59,6 +60,6 @@ export function defineAlertCondition(opts) {
|
|
|
59
60
|
maxLookback: 0,
|
|
60
61
|
alertConditions,
|
|
61
62
|
});
|
|
62
|
-
return Object.freeze({ manifest, compute: opts.compute });
|
|
63
|
+
return Object.freeze(attachDepAccessorSentinels({ manifest, compute: opts.compute }));
|
|
63
64
|
}
|
|
64
65
|
//# sourceMappingURL=defineAlertCondition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineAlertCondition.js","sourceRoot":"","sources":["../../src/define/defineAlertCondition.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;
|
|
1
|
+
{"version":3,"file":"defineAlertCondition.js","sourceRoot":"","sources":["../../src/define/defineAlertCondition.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAU/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AA+BtE,SAAS,eAAe,CACpB,EAAU,EACV,UAAoC;IAEpC,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,EAAE;QACF,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,cAAc,EAAE,UAAU,CAAC,cAAc;KAC5C,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAA8B;IAC/D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CACjC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAC7F,CAAC;IACF,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAmC,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC1F,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAW,EAAE,CAAC,CAAC;IACvD,MAAM,gBAAgB,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7E,MAAM,QAAQ,GAAmB,MAAM,CAAC,MAAM,CAAC;QAC3C,UAAU,EAAE,CAAC;QACb,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;QACzB,YAAY;QACZ,kBAAkB;QAClB,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB;QAChB,WAAW,EAAE,CAAC;QACd,eAAe;KAClB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC1F,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 {\n AlertConditionDescriptor,\n AlertConditionDefinition,\n CompiledScriptObject,\n ComputeFn,\n InputSchema,\n ScriptManifest,\n} from \"../types.js\";\nimport { attachDepAccessorSentinels } from \"./depAccessorSentinel.js\";\n\n/**\n * Author-supplied options for `defineAlertCondition(...)`. Mirrors\n * `DefineAlertOpts` plus the `conditions` map.\n *\n * @since 0.5\n * @stable\n * @example\n * const opts: DefineAlertConditionOpts = {\n * name: \"EMA cross\",\n * apiVersion: 1,\n * conditions: {\n * up: {\n * title: \"Up\",\n * description: \"Close > EMA\",\n * defaultMessage: \"{{ticker}} up\",\n * },\n * },\n * compute: () => {},\n * };\n * void opts;\n */\nexport type DefineAlertConditionOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n conditions: Readonly<Record<string, AlertConditionDescriptor>>;\n compute: ComputeFn;\n}>;\n\nfunction freezeCondition(\n id: string,\n descriptor: AlertConditionDescriptor,\n): AlertConditionDefinition {\n return Object.freeze({\n id,\n title: descriptor.title,\n description: descriptor.description,\n defaultMessage: descriptor.defaultMessage,\n });\n}\n\n/**\n * Construct a Phase-5 alert-condition script. Returns a frozen\n * `CompiledScriptObject` whose `manifest.kind` is `\"alertCondition\"`.\n *\n * @since 0.5\n * @stable\n * @example\n * ```ts\n * import { defineAlertCondition, input, ta } from \"@invinite-org/chartlang-core\";\n *\n * export default defineAlertCondition({\n * name: \"EMA cross\",\n * apiVersion: 1,\n * inputs: { length: input.int(20) },\n * conditions: {\n * up: {\n * title: \"Up\",\n * description: \"Close > EMA\",\n * defaultMessage: \"{{ticker}} up\",\n * },\n * down: {\n * title: \"Down\",\n * description: \"Close < EMA\",\n * defaultMessage: \"{{ticker}} down\",\n * },\n * },\n * compute({ bar, ta, inputs, signal }) {\n * const ema = ta.ema(bar.close, inputs.length as number);\n * signal?.(\"up\", ta.crossover(bar.close, ema).current);\n * signal?.(\"down\", ta.crossunder(bar.close, ema).current);\n * },\n * });\n * ```\n */\nexport function defineAlertCondition(opts: DefineAlertConditionOpts): CompiledScriptObject {\n const alertConditions = Object.freeze(\n Object.entries(opts.conditions).map(([id, descriptor]) => freezeCondition(id, descriptor)),\n );\n const capabilities = Object.freeze<ReadonlyArray<\"alertConditions\">>([\"alertConditions\"]);\n const requestedIntervals = Object.freeze<string[]>([]);\n const seriesCapacities: Readonly<Record<string, number>> = Object.freeze({});\n const manifest: ScriptManifest = Object.freeze({\n apiVersion: 1,\n kind: \"alertCondition\",\n name: opts.name,\n inputs: opts.inputs ?? {},\n capabilities,\n requestedIntervals,\n userPickableInterval: false,\n seriesCapacities,\n maxLookback: 0,\n alertConditions,\n });\n return Object.freeze(attachDepAccessorSentinels({ manifest, compute: opts.compute }));\n}\n"]}
|
|
@@ -30,13 +30,13 @@ export type DefineDrawingOpts = Readonly<{
|
|
|
30
30
|
* and drawing scripts identically at the per-bar level — the
|
|
31
31
|
* discriminator is a host-side hint the editor uses to distinguish
|
|
32
32
|
* drawing scripts from indicator scripts in the script-picker UI
|
|
33
|
-
|
|
33
|
+
*.
|
|
34
34
|
*
|
|
35
35
|
* `compute({ bar, draw, inputs, ... })` runs per bar; emit drawings via
|
|
36
36
|
* the `draw.*` namespace. Each `draw.<kind>(...)` returns a
|
|
37
37
|
* {@link DrawingHandle} the script can `update(...)` or `remove()`
|
|
38
38
|
* across bars. Phase 4 layers an interactive-anchor-picker UI on top of
|
|
39
|
-
* this constructor
|
|
39
|
+
* this constructor; Phase 3 ships the constructor
|
|
40
40
|
* with fixed anchors so the runtime path can be exercised.
|
|
41
41
|
*
|
|
42
42
|
* @since 0.3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineDrawing.d.ts","sourceRoot":"","sources":["../../src/define/defineDrawing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"defineDrawing.d.ts","sourceRoot":"","sources":["../../src/define/defineDrawing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,KAAK,gBAAgB,GAAG,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC;AAEvE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,CAAC,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC;IACnB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC,GACE,gBAAgB,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,oBAAoB,CA+B3E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import { attachDepAccessorSentinels } from "./depAccessorSentinel.js";
|
|
3
4
|
/**
|
|
4
5
|
* Construct a Phase-3 drawing script object. Mirrors `defineIndicator`
|
|
5
6
|
* structurally; only `manifest.kind` (`"drawing"`) and the declared
|
|
@@ -7,13 +8,13 @@
|
|
|
7
8
|
* and drawing scripts identically at the per-bar level — the
|
|
8
9
|
* discriminator is a host-side hint the editor uses to distinguish
|
|
9
10
|
* drawing scripts from indicator scripts in the script-picker UI
|
|
10
|
-
|
|
11
|
+
*.
|
|
11
12
|
*
|
|
12
13
|
* `compute({ bar, draw, inputs, ... })` runs per bar; emit drawings via
|
|
13
14
|
* the `draw.*` namespace. Each `draw.<kind>(...)` returns a
|
|
14
15
|
* {@link DrawingHandle} the script can `update(...)` or `remove()`
|
|
15
16
|
* across bars. Phase 4 layers an interactive-anchor-picker UI on top of
|
|
16
|
-
* this constructor
|
|
17
|
+
* this constructor; Phase 3 ships the constructor
|
|
17
18
|
* with fixed anchors so the runtime path can be exercised.
|
|
18
19
|
*
|
|
19
20
|
* @since 0.3
|
|
@@ -59,9 +60,9 @@ export function defineDrawing(opts) {
|
|
|
59
60
|
: { requiresIntervals: opts.requiresIntervals }),
|
|
60
61
|
...(opts.shortName === undefined ? {} : { shortName: opts.shortName }),
|
|
61
62
|
};
|
|
62
|
-
return Object.freeze({
|
|
63
|
+
return Object.freeze(attachDepAccessorSentinels({
|
|
63
64
|
manifest: Object.freeze(manifest),
|
|
64
65
|
compute: opts.compute,
|
|
65
|
-
});
|
|
66
|
+
}));
|
|
66
67
|
}
|
|
67
68
|
//# sourceMappingURL=defineDrawing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineDrawing.js","sourceRoot":"","sources":["../../src/define/defineDrawing.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;
|
|
1
|
+
{"version":3,"file":"defineDrawing.js","sourceRoot":"","sources":["../../src/define/defineDrawing.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AA6BtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,aAAa,CAAC,IAAuB;IACjD,MAAM,YAAY,GAA8B,MAAM,CAAC,MAAM,CAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1F,MAAM,kBAAkB,GAA0B,MAAM,CAAC,MAAM,CAAW,EAAE,CAAC,CAAC;IAC9E,MAAM,gBAAgB,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG;QACT,UAAU,EAAE,CAAU;QACtB,IAAI,EAAE,SAAkB;QACxB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;QACzB,YAAY;QACZ,kBAAkB;QAClB,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB;QAChB,WAAW,EAAE,CAAC;KACjB,CAAC;IACF,MAAM,QAAQ,GAAG;QACb,GAAG,IAAI;QACP,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5E,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7D,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;QACtE,GAAG,CAAC,IAAI,CAAC,iBAAiB,KAAK,SAAS;YACpC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACpD,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;KACzE,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAChB,0BAA0B,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO;KACxB,CAAC,CACL,CAAC;AACN,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 { CompiledScriptObject, ComputeFn, DrawingCounts, InputSchema } from \"../types.js\";\nimport { attachDepAccessorSentinels } from \"./depAccessorSentinel.js\";\nimport type { ScriptOverrides } from \"./overrides.js\";\n\ntype DrawingOverrides = Omit<ScriptOverrides, \"maxBarsBack\" | \"scale\">;\n\n/**\n * Author-supplied options the script passes to `defineDrawing(...)`. Same\n * shape as `DefineAlertOpts` (no indicator-only `overlay` flag) plus the\n * Phase-3 `maxDrawings` per-bucket cap from `DefineIndicatorOpts`.\n *\n * @since 0.3\n * @stable\n * @example\n * const opts: DefineDrawingOpts = {\n * name: \"Interactive Fib Retracement\",\n * apiVersion: 1,\n * compute: () => {},\n * };\n */\nexport type DefineDrawingOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n compute: ComputeFn;\n /** Per-bucket cap on `draw.*` emissions per bar. @since 0.3 */\n maxDrawings?: DrawingCounts;\n}> &\n DrawingOverrides;\n\n/**\n * Construct a Phase-3 drawing script object. Mirrors `defineIndicator`\n * structurally; only `manifest.kind` (`\"drawing\"`) and the declared\n * `capabilities` (`[\"drawings\"]`) differ. The runtime treats indicator\n * and drawing scripts identically at the per-bar level — the\n * discriminator is a host-side hint the editor uses to distinguish\n * drawing scripts from indicator scripts in the script-picker UI\n *.\n *\n * `compute({ bar, draw, inputs, ... })` runs per bar; emit drawings via\n * the `draw.*` namespace. Each `draw.<kind>(...)` returns a\n * {@link DrawingHandle} the script can `update(...)` or `remove()`\n * across bars. Phase 4 layers an interactive-anchor-picker UI on top of\n * this constructor; Phase 3 ships the constructor\n * with fixed anchors so the runtime path can be exercised.\n *\n * @since 0.3\n * @stable\n * @example\n * ```ts\n * import { defineDrawing } from \"@invinite-org/chartlang-core\";\n *\n * export default defineDrawing({\n * name: \"Interactive Fib Retracement\",\n * apiVersion: 1,\n * compute: ({ draw }) => {\n * draw.fibRetracement(\n * { time: 1_700_000_000_000, price: 100 },\n * { time: 1_700_086_400_000, price: 110 },\n * );\n * },\n * });\n * ```\n */\nexport function defineDrawing(opts: DefineDrawingOpts): CompiledScriptObject {\n const capabilities: ReadonlyArray<\"drawings\"> = Object.freeze<[\"drawings\"]>([\"drawings\"]);\n const requestedIntervals: ReadonlyArray<string> = Object.freeze<string[]>([]);\n const seriesCapacities: Readonly<Record<string, number>> = Object.freeze({});\n const base = {\n apiVersion: 1 as const,\n kind: \"drawing\" as const,\n name: opts.name,\n inputs: opts.inputs ?? {},\n capabilities,\n requestedIntervals,\n userPickableInterval: false,\n seriesCapacities,\n maxLookback: 0,\n };\n const manifest = {\n ...base,\n ...(opts.maxDrawings === undefined ? {} : { maxDrawings: opts.maxDrawings }),\n ...(opts.format === undefined ? {} : { format: opts.format }),\n ...(opts.precision === undefined ? {} : { precision: opts.precision }),\n ...(opts.requiresIntervals === undefined\n ? {}\n : { requiresIntervals: opts.requiresIntervals }),\n ...(opts.shortName === undefined ? {} : { shortName: opts.shortName }),\n };\n return Object.freeze(\n attachDepAccessorSentinels({\n manifest: Object.freeze(manifest),\n compute: opts.compute,\n }),\n );\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CompiledScriptObject, ComputeFn, DrawingCounts, InputSchema } from "../types.js";
|
|
2
|
+
import type { OutputDeclaration } from "./dependency.js";
|
|
2
3
|
import type { ScriptOverrides } from "./overrides.js";
|
|
3
4
|
/**
|
|
4
5
|
* Author-supplied options the script passes to `defineIndicator(...)`. The
|
|
@@ -24,6 +25,16 @@ export type DefineIndicatorOpts = Readonly<{
|
|
|
24
25
|
compute: ComputeFn;
|
|
25
26
|
/** Per-bucket cap on `draw.*` emissions per bar. @since 0.3 */
|
|
26
27
|
maxDrawings?: DrawingCounts;
|
|
28
|
+
/**
|
|
29
|
+
* Titled outputs this producer exposes for `<binding>.output(...)`
|
|
30
|
+
* consumption. Injected by the compiler from the producer's
|
|
31
|
+
* `plot(value, { title })` calls so the runtime object is
|
|
32
|
+
* self-describing — hosts read `manifest.outputs` to allocate the
|
|
33
|
+
* dep-output ring buffer. Hand-authored scripts omit it; absent
|
|
34
|
+
* `outputs` keeps the emitted manifest byte-identical to a script
|
|
35
|
+
* with no titled plots. @since 0.7
|
|
36
|
+
*/
|
|
37
|
+
outputs?: ReadonlyArray<OutputDeclaration>;
|
|
27
38
|
}> & ScriptOverrides;
|
|
28
39
|
/**
|
|
29
40
|
* Construct a Phase-1 indicator script object. Returns a frozen
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineIndicator.d.ts","sourceRoot":"","sources":["../../src/define/defineIndicator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"defineIndicator.d.ts","sourceRoot":"","sources":["../../src/define/defineIndicator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,CAAC,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC;IACnB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC,GACE,eAAe,CAAC;AAEpB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,oBAAoB,CAmC/E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import { attachDepAccessorSentinels } from "./depAccessorSentinel.js";
|
|
3
4
|
/**
|
|
4
5
|
* Construct a Phase-1 indicator script object. Returns a frozen
|
|
5
6
|
* `CompiledScriptObject` with a default manifest the compiler later overrides
|
|
@@ -36,6 +37,7 @@ export function defineIndicator(opts) {
|
|
|
36
37
|
};
|
|
37
38
|
const manifest = {
|
|
38
39
|
...base,
|
|
40
|
+
...(opts.overlay === undefined ? {} : { overlay: opts.overlay }),
|
|
39
41
|
...(opts.maxDrawings === undefined ? {} : { maxDrawings: opts.maxDrawings }),
|
|
40
42
|
...(opts.maxBarsBack === undefined ? {} : { maxBarsBack: opts.maxBarsBack }),
|
|
41
43
|
...(opts.format === undefined ? {} : { format: opts.format }),
|
|
@@ -45,10 +47,11 @@ export function defineIndicator(opts) {
|
|
|
45
47
|
? {}
|
|
46
48
|
: { requiresIntervals: opts.requiresIntervals }),
|
|
47
49
|
...(opts.shortName === undefined ? {} : { shortName: opts.shortName }),
|
|
50
|
+
...(opts.outputs === undefined ? {} : { outputs: opts.outputs }),
|
|
48
51
|
};
|
|
49
|
-
return Object.freeze({
|
|
52
|
+
return Object.freeze(attachDepAccessorSentinels({
|
|
50
53
|
manifest: Object.freeze(manifest),
|
|
51
54
|
compute: opts.compute,
|
|
52
|
-
});
|
|
55
|
+
}));
|
|
53
56
|
}
|
|
54
57
|
//# sourceMappingURL=defineIndicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineIndicator.js","sourceRoot":"","sources":["../../src/define/defineIndicator.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;
|
|
1
|
+
{"version":3,"file":"defineIndicator.js","sourceRoot":"","sources":["../../src/define/defineIndicator.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAyCtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,eAAe,CAAC,IAAyB;IACrD,MAAM,YAAY,GAAgC,MAAM,CAAC,MAAM,CAAiB,CAAC,YAAY,CAAC,CAAC,CAAC;IAChG,MAAM,kBAAkB,GAA0B,MAAM,CAAC,MAAM,CAAW,EAAE,CAAC,CAAC;IAC9E,MAAM,gBAAgB,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG;QACT,UAAU,EAAE,CAAU;QACtB,IAAI,EAAE,WAAoB;QAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAA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AC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;QACtE,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;KACnE,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAChB,0BAA0B,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO;KACxB,CAAC,CACL,CAAC;AACN,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 { CompiledScriptObject, ComputeFn, DrawingCounts, InputSchema } from \"../types.js\";\nimport { attachDepAccessorSentinels } from \"./depAccessorSentinel.js\";\nimport type { OutputDeclaration } from \"./dependency.js\";\nimport type { ScriptOverrides } from \"./overrides.js\";\n\n/**\n * Author-supplied options the script passes to `defineIndicator(...)`. The\n * compiler reads this object's static shape to build the script's manifest;\n * any field can be overridden at compile time via the AST transform.\n *\n * `maxDrawings` (Phase 3 / §10 / §4.1) caps the per-bucket `draw.*`\n * emission rate per bar. Omit to default to the adapter's cap.\n *\n * @since 0.1\n * @example\n * const opts: DefineIndicatorOpts = {\n * name: \"demo\",\n * apiVersion: 1,\n * compute: () => {},\n * };\n */\nexport type DefineIndicatorOpts = Readonly<{\n name: string;\n apiVersion: 1;\n overlay?: boolean;\n inputs?: InputSchema;\n compute: ComputeFn;\n /** Per-bucket cap on `draw.*` emissions per bar. @since 0.3 */\n maxDrawings?: DrawingCounts;\n /**\n * Titled outputs this producer exposes for `<binding>.output(...)`\n * consumption. Injected by the compiler from the producer's\n * `plot(value, { title })` calls so the runtime object is\n * self-describing — hosts read `manifest.outputs` to allocate the\n * dep-output ring buffer. Hand-authored scripts omit it; absent\n * `outputs` keeps the emitted manifest byte-identical to a script\n * with no titled plots. @since 0.7\n */\n outputs?: ReadonlyArray<OutputDeclaration>;\n}> &\n ScriptOverrides;\n\n/**\n * Construct a Phase-1 indicator script object. Returns a frozen\n * `CompiledScriptObject` with a default manifest the compiler later overrides\n * (extracts `capabilities` from primitive usage, `maxLookback` from\n * `series[N]` reads). The defaults let the constructor work in unit tests\n * before the compiler runs.\n *\n * @since 0.1\n * @example\n * ```ts\n * import { defineIndicator } from \"@invinite-org/chartlang-core\";\n *\n * export default defineIndicator({\n * name: \"EMA(20)\",\n * apiVersion: 1,\n * compute: ({ bar, plot }) => { plot(bar.close); },\n * });\n * ```\n */\nexport function defineIndicator(opts: DefineIndicatorOpts): CompiledScriptObject {\n const capabilities: ReadonlyArray<\"indicators\"> = Object.freeze<[\"indicators\"]>([\"indicators\"]);\n const requestedIntervals: ReadonlyArray<string> = Object.freeze<string[]>([]);\n const seriesCapacities: Readonly<Record<string, number>> = Object.freeze({});\n const base = {\n apiVersion: 1 as const,\n kind: \"indicator\" as const,\n name: opts.name,\n inputs: opts.inputs ?? {},\n capabilities,\n requestedIntervals,\n userPickableInterval: false,\n seriesCapacities,\n maxLookback: 0,\n };\n const manifest = {\n ...base,\n ...(opts.overlay === undefined ? {} : { overlay: opts.overlay }),\n ...(opts.maxDrawings === undefined ? {} : { maxDrawings: opts.maxDrawings }),\n ...(opts.maxBarsBack === undefined ? {} : { maxBarsBack: opts.maxBarsBack }),\n ...(opts.format === undefined ? {} : { format: opts.format }),\n ...(opts.precision === undefined ? {} : { precision: opts.precision }),\n ...(opts.scale === undefined ? {} : { scale: opts.scale }),\n ...(opts.requiresIntervals === undefined\n ? {}\n : { requiresIntervals: opts.requiresIntervals }),\n ...(opts.shortName === undefined ? {} : { shortName: opts.shortName }),\n ...(opts.outputs === undefined ? {} : { outputs: opts.outputs }),\n };\n return Object.freeze(\n attachDepAccessorSentinels({\n manifest: Object.freeze(manifest),\n compute: opts.compute,\n }),\n );\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { CompiledScriptObject, ComputeFn, ScriptManifest } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Sentinel thrown when `output` / `withInputs` are called outside the
|
|
4
|
+
* compiler-rewritten bundle path. The Phase-7 compiler statically
|
|
5
|
+
* replaces every consumer-side `.output("title")` call site with a
|
|
6
|
+
* synthesised `__chartlang_depOutput(...)` runtime call, and every
|
|
7
|
+
* `.withInputs({...})` chain with a folded dep manifest, so these
|
|
8
|
+
* bodies are unreachable when the bundle is loaded normally. Hand-
|
|
9
|
+
* running an un-compiled script in a unit test hits the sentinel,
|
|
10
|
+
* which is the desired failure.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.7
|
|
13
|
+
* @stable
|
|
14
|
+
* @example
|
|
15
|
+
* try {
|
|
16
|
+
* depAccessorSentinel("output(\"line\")");
|
|
17
|
+
* } catch (err) {
|
|
18
|
+
* void (err as Error).message;
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
export declare const depAccessorSentinel: (name: string) => never;
|
|
22
|
+
/**
|
|
23
|
+
* Attach the {@link depAccessorSentinel}-backed `output` /
|
|
24
|
+
* `withInputs` accessors to a `{ manifest, compute }` pair so the
|
|
25
|
+
* `defineIndicator` / `defineAlert` / `defineDrawing` /
|
|
26
|
+
* `defineAlertCondition` constructors return a complete
|
|
27
|
+
* {@link CompiledScriptObject}. The compiler rewrites both accessors
|
|
28
|
+
* to static dep lookups at bundle time — the throwing bodies only
|
|
29
|
+
* fire when an un-compiled module is invoked directly.
|
|
30
|
+
*
|
|
31
|
+
* @since 0.7
|
|
32
|
+
* @stable
|
|
33
|
+
* @example
|
|
34
|
+
* declare const manifest: ScriptManifest;
|
|
35
|
+
* declare const compute: ComputeFn;
|
|
36
|
+
* const cs: CompiledScriptObject = attachDepAccessorSentinels({
|
|
37
|
+
* manifest,
|
|
38
|
+
* compute,
|
|
39
|
+
* });
|
|
40
|
+
* void cs;
|
|
41
|
+
*/
|
|
42
|
+
export declare const attachDepAccessorSentinels: (base: Readonly<{
|
|
43
|
+
manifest: ScriptManifest;
|
|
44
|
+
compute: ComputeFn;
|
|
45
|
+
}>) => CompiledScriptObject;
|
|
46
|
+
//# sourceMappingURL=depAccessorSentinel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depAccessorSentinel.d.ts","sourceRoot":"","sources":["../../src/define/depAccessorSentinel.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,cAAc,EAAU,MAAM,aAAa,CAAC;AAE3F;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,KAIlD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,0BAA0B,GACnC,MAAM,QAAQ,CAAC;IAAE,QAAQ,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC,KACjE,oBAKD,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
/**
|
|
4
|
+
* Sentinel thrown when `output` / `withInputs` are called outside the
|
|
5
|
+
* compiler-rewritten bundle path. The Phase-7 compiler statically
|
|
6
|
+
* replaces every consumer-side `.output("title")` call site with a
|
|
7
|
+
* synthesised `__chartlang_depOutput(...)` runtime call, and every
|
|
8
|
+
* `.withInputs({...})` chain with a folded dep manifest, so these
|
|
9
|
+
* bodies are unreachable when the bundle is loaded normally. Hand-
|
|
10
|
+
* running an un-compiled script in a unit test hits the sentinel,
|
|
11
|
+
* which is the desired failure.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.7
|
|
14
|
+
* @stable
|
|
15
|
+
* @example
|
|
16
|
+
* try {
|
|
17
|
+
* depAccessorSentinel("output(\"line\")");
|
|
18
|
+
* } catch (err) {
|
|
19
|
+
* void (err as Error).message;
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
export const depAccessorSentinel = (name) => {
|
|
23
|
+
throw new Error(`${name} can only be called on a compiled chartlang indicator binding inside another indicator's compute body`);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Attach the {@link depAccessorSentinel}-backed `output` /
|
|
27
|
+
* `withInputs` accessors to a `{ manifest, compute }` pair so the
|
|
28
|
+
* `defineIndicator` / `defineAlert` / `defineDrawing` /
|
|
29
|
+
* `defineAlertCondition` constructors return a complete
|
|
30
|
+
* {@link CompiledScriptObject}. The compiler rewrites both accessors
|
|
31
|
+
* to static dep lookups at bundle time — the throwing bodies only
|
|
32
|
+
* fire when an un-compiled module is invoked directly.
|
|
33
|
+
*
|
|
34
|
+
* @since 0.7
|
|
35
|
+
* @stable
|
|
36
|
+
* @example
|
|
37
|
+
* declare const manifest: ScriptManifest;
|
|
38
|
+
* declare const compute: ComputeFn;
|
|
39
|
+
* const cs: CompiledScriptObject = attachDepAccessorSentinels({
|
|
40
|
+
* manifest,
|
|
41
|
+
* compute,
|
|
42
|
+
* });
|
|
43
|
+
* void cs;
|
|
44
|
+
*/
|
|
45
|
+
export const attachDepAccessorSentinels = (base) => ({
|
|
46
|
+
manifest: base.manifest,
|
|
47
|
+
compute: base.compute,
|
|
48
|
+
output: (name) => depAccessorSentinel(`output("${name}")`),
|
|
49
|
+
withInputs: () => depAccessorSentinel("withInputs"),
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=depAccessorSentinel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depAccessorSentinel.js","sourceRoot":"","sources":["../../src/define/depAccessorSentinel.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAS,EAAE;IACvD,MAAM,IAAI,KAAK,CACX,GAAG,IAAI,uGAAuG,CACjH,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACtC,IAAgE,EAC5C,EAAE,CAAC,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,MAAM,EAAE,CAAC,IAAY,EAAkB,EAAE,CAAC,mBAAmB,CAAC,WAAW,IAAI,IAAI,CAAC;IAClF,UAAU,EAAE,GAAyB,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC;CAC5E,CAAC,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 { CompiledScriptObject, ComputeFn, ScriptManifest, Series } from \"../types.js\";\n\n/**\n * Sentinel thrown when `output` / `withInputs` are called outside the\n * compiler-rewritten bundle path. The Phase-7 compiler statically\n * replaces every consumer-side `.output(\"title\")` call site with a\n * synthesised `__chartlang_depOutput(...)` runtime call, and every\n * `.withInputs({...})` chain with a folded dep manifest, so these\n * bodies are unreachable when the bundle is loaded normally. Hand-\n * running an un-compiled script in a unit test hits the sentinel,\n * which is the desired failure.\n *\n * @since 0.7\n * @stable\n * @example\n * try {\n * depAccessorSentinel(\"output(\\\"line\\\")\");\n * } catch (err) {\n * void (err as Error).message;\n * }\n */\nexport const depAccessorSentinel = (name: string): never => {\n throw new Error(\n `${name} can only be called on a compiled chartlang indicator binding inside another indicator's compute body`,\n );\n};\n\n/**\n * Attach the {@link depAccessorSentinel}-backed `output` /\n * `withInputs` accessors to a `{ manifest, compute }` pair so the\n * `defineIndicator` / `defineAlert` / `defineDrawing` /\n * `defineAlertCondition` constructors return a complete\n * {@link CompiledScriptObject}. The compiler rewrites both accessors\n * to static dep lookups at bundle time — the throwing bodies only\n * fire when an un-compiled module is invoked directly.\n *\n * @since 0.7\n * @stable\n * @example\n * declare const manifest: ScriptManifest;\n * declare const compute: ComputeFn;\n * const cs: CompiledScriptObject = attachDepAccessorSentinels({\n * manifest,\n * compute,\n * });\n * void cs;\n */\nexport const attachDepAccessorSentinels = (\n base: Readonly<{ manifest: ScriptManifest; compute: ComputeFn }>,\n): CompiledScriptObject => ({\n manifest: base.manifest,\n compute: base.compute,\n output: (name: string): Series<number> => depAccessorSentinel(`output(\"${name}\")`),\n withInputs: (): CompiledScriptObject => depAccessorSentinel(\"withInputs\"),\n});\n"]}
|