@invinite-org/chartlang-runtime 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +236 -0
- package/dist/barPoint.d.ts +20 -0
- package/dist/barPoint.d.ts.map +1 -0
- package/dist/barPoint.js +72 -0
- package/dist/barPoint.js.map +1 -0
- package/dist/bufferSnapshot.d.ts +102 -0
- package/dist/bufferSnapshot.d.ts.map +1 -0
- package/dist/bufferSnapshot.js +119 -0
- package/dist/bufferSnapshot.js.map +1 -0
- package/dist/createScriptRunner.d.ts +6 -3
- package/dist/createScriptRunner.d.ts.map +1 -1
- package/dist/createScriptRunner.js +29 -5
- package/dist/createScriptRunner.js.map +1 -1
- package/dist/dep/DepRunner.d.ts.map +1 -1
- package/dist/dep/DepRunner.js +1 -0
- package/dist/dep/DepRunner.js.map +1 -1
- package/dist/emit/draw/boxes/fillBetween.d.ts +45 -0
- package/dist/emit/draw/boxes/fillBetween.d.ts.map +1 -0
- package/dist/emit/draw/boxes/fillBetween.js +36 -0
- package/dist/emit/draw/boxes/fillBetween.js.map +1 -0
- package/dist/emit/draw/handle.d.ts +9 -0
- package/dist/emit/draw/handle.d.ts.map +1 -1
- package/dist/emit/draw/handle.js +65 -10
- package/dist/emit/draw/handle.js.map +1 -1
- package/dist/emit/draw/namespace.d.ts +4 -3
- package/dist/emit/draw/namespace.d.ts.map +1 -1
- package/dist/emit/draw/namespace.js +6 -3
- package/dist/emit/draw/namespace.js.map +1 -1
- package/dist/emit/plot.d.ts +7 -0
- package/dist/emit/plot.d.ts.map +1 -1
- package/dist/emit/plot.js +13 -0
- package/dist/emit/plot.js.map +1 -1
- package/dist/execution/dispose.d.ts.map +1 -1
- package/dist/execution/dispose.js +16 -0
- package/dist/execution/dispose.js.map +1 -1
- package/dist/execution/runComputeStep.d.ts.map +1 -1
- package/dist/execution/runComputeStep.js +10 -1
- package/dist/execution/runComputeStep.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/persistentStateStore.runtime.d.ts.map +1 -1
- package/dist/persistentStateStore.runtime.js +21 -7
- package/dist/persistentStateStore.runtime.js.map +1 -1
- package/dist/request/index.d.ts +2 -1
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +2 -1
- package/dist/request/index.js.map +1 -1
- package/dist/request/requestNamespace.d.ts.map +1 -1
- package/dist/request/requestNamespace.js +16 -3
- package/dist/request/requestNamespace.js.map +1 -1
- package/dist/request/security.d.ts +20 -1
- package/dist/request/security.d.ts.map +1 -1
- package/dist/request/security.js +62 -23
- package/dist/request/security.js.map +1 -1
- package/dist/request/securityExprRunner.d.ts +133 -0
- package/dist/request/securityExprRunner.d.ts.map +1 -0
- package/dist/request/securityExprRunner.js +235 -0
- package/dist/request/securityExprRunner.js.map +1 -0
- package/dist/request/streamBars.d.ts +14 -1
- package/dist/request/streamBars.d.ts.map +1 -1
- package/dist/request/streamBars.js +39 -1
- package/dist/request/streamBars.js.map +1 -1
- package/dist/runtimeContext.d.ts +48 -0
- package/dist/runtimeContext.d.ts.map +1 -1
- package/dist/runtimeContext.js.map +1 -1
- package/dist/seriesView.d.ts +42 -17
- package/dist/seriesView.d.ts.map +1 -1
- package/dist/seriesView.js +65 -42
- package/dist/seriesView.js.map +1 -1
- package/dist/state/index.d.ts +2 -1
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +2 -1
- package/dist/state/index.js.map +1 -1
- package/dist/state/lifecycle.d.ts +40 -0
- package/dist/state/lifecycle.d.ts.map +1 -1
- package/dist/state/lifecycle.js +53 -0
- package/dist/state/lifecycle.js.map +1 -1
- package/dist/state/seriesPersistence.d.ts +48 -0
- package/dist/state/seriesPersistence.d.ts.map +1 -0
- package/dist/state/seriesPersistence.js +87 -0
- package/dist/state/seriesPersistence.js.map +1 -0
- package/dist/state/seriesSlot.d.ts +105 -0
- package/dist/state/seriesSlot.d.ts.map +1 -0
- package/dist/state/seriesSlot.js +123 -0
- package/dist/state/seriesSlot.js.map +1 -0
- package/dist/state/stateNamespace.d.ts.map +1 -1
- package/dist/state/stateNamespace.js +28 -0
- package/dist/state/stateNamespace.js.map +1 -1
- package/dist/streamState.d.ts +25 -19
- package/dist/streamState.d.ts.map +1 -1
- package/dist/streamState.js +40 -66
- package/dist/streamState.js.map +1 -1
- package/dist/ta/adx.d.ts +3 -2
- package/dist/ta/adx.d.ts.map +1 -1
- package/dist/ta/adx.js +3 -2
- package/dist/ta/adx.js.map +1 -1
- package/dist/ta/alma.d.ts +6 -4
- package/dist/ta/alma.d.ts.map +1 -1
- package/dist/ta/alma.js +19 -6
- package/dist/ta/alma.js.map +1 -1
- package/dist/ta/atr.d.ts +3 -2
- package/dist/ta/atr.d.ts.map +1 -1
- package/dist/ta/atr.js +3 -2
- package/dist/ta/atr.js.map +1 -1
- package/dist/ta/bb.d.ts +3 -2
- package/dist/ta/bb.d.ts.map +1 -1
- package/dist/ta/bb.js +3 -2
- package/dist/ta/bb.js.map +1 -1
- package/dist/ta/chaikinOsc.d.ts +3 -2
- package/dist/ta/chaikinOsc.d.ts.map +1 -1
- package/dist/ta/chaikinOsc.js +3 -2
- package/dist/ta/chaikinOsc.js.map +1 -1
- package/dist/ta/crossover.d.ts +3 -2
- package/dist/ta/crossover.d.ts.map +1 -1
- package/dist/ta/crossover.js +3 -2
- package/dist/ta/crossover.js.map +1 -1
- package/dist/ta/crossunder.d.ts +3 -2
- package/dist/ta/crossunder.d.ts.map +1 -1
- package/dist/ta/crossunder.js +3 -2
- package/dist/ta/crossunder.js.map +1 -1
- package/dist/ta/dmi.d.ts +4 -3
- package/dist/ta/dmi.d.ts.map +1 -1
- package/dist/ta/dmi.js +4 -3
- package/dist/ta/dmi.js.map +1 -1
- package/dist/ta/ema.d.ts +3 -2
- package/dist/ta/ema.d.ts.map +1 -1
- package/dist/ta/ema.js +3 -2
- package/dist/ta/ema.js.map +1 -1
- package/dist/ta/eom.d.ts +3 -1
- package/dist/ta/eom.d.ts.map +1 -1
- package/dist/ta/eom.js +3 -1
- package/dist/ta/eom.js.map +1 -1
- package/dist/ta/highestbars.d.ts +25 -0
- package/dist/ta/highestbars.d.ts.map +1 -0
- package/dist/ta/highestbars.js +106 -0
- package/dist/ta/highestbars.js.map +1 -0
- package/dist/ta/historicalVolatility.d.ts +3 -2
- package/dist/ta/historicalVolatility.d.ts.map +1 -1
- package/dist/ta/historicalVolatility.js +3 -2
- package/dist/ta/historicalVolatility.js.map +1 -1
- package/dist/ta/ichimoku.d.ts +3 -1
- package/dist/ta/ichimoku.d.ts.map +1 -1
- package/dist/ta/ichimoku.js +3 -1
- package/dist/ta/ichimoku.js.map +1 -1
- package/dist/ta/lowestbars.d.ts +25 -0
- package/dist/ta/lowestbars.d.ts.map +1 -0
- package/dist/ta/lowestbars.js +102 -0
- package/dist/ta/lowestbars.js.map +1 -0
- package/dist/ta/macd.d.ts +3 -2
- package/dist/ta/macd.d.ts.map +1 -1
- package/dist/ta/macd.js +3 -2
- package/dist/ta/macd.js.map +1 -1
- package/dist/ta/massIndex.d.ts +3 -2
- package/dist/ta/massIndex.d.ts.map +1 -1
- package/dist/ta/massIndex.js +3 -2
- package/dist/ta/massIndex.js.map +1 -1
- package/dist/ta/mfi.d.ts +3 -1
- package/dist/ta/mfi.d.ts.map +1 -1
- package/dist/ta/mfi.js +3 -1
- package/dist/ta/mfi.js.map +1 -1
- package/dist/ta/netVolume.d.ts +3 -1
- package/dist/ta/netVolume.d.ts.map +1 -1
- package/dist/ta/netVolume.js +3 -1
- package/dist/ta/netVolume.js.map +1 -1
- package/dist/ta/nvi.d.ts +3 -1
- package/dist/ta/nvi.d.ts.map +1 -1
- package/dist/ta/nvi.js +3 -1
- package/dist/ta/nvi.js.map +1 -1
- package/dist/ta/persistence.d.ts.map +1 -1
- package/dist/ta/persistence.js +1 -40
- package/dist/ta/persistence.js.map +1 -1
- package/dist/ta/ppo.d.ts +3 -2
- package/dist/ta/ppo.d.ts.map +1 -1
- package/dist/ta/ppo.js +3 -2
- package/dist/ta/ppo.js.map +1 -1
- package/dist/ta/pvi.d.ts +3 -1
- package/dist/ta/pvi.d.ts.map +1 -1
- package/dist/ta/pvi.js +3 -1
- package/dist/ta/pvi.js.map +1 -1
- package/dist/ta/pvo.d.ts +3 -1
- package/dist/ta/pvo.d.ts.map +1 -1
- package/dist/ta/pvo.js +3 -1
- package/dist/ta/pvo.js.map +1 -1
- package/dist/ta/pvt.d.ts +3 -1
- package/dist/ta/pvt.d.ts.map +1 -1
- package/dist/ta/pvt.js +3 -1
- package/dist/ta/pvt.js.map +1 -1
- package/dist/ta/registry.d.ts +7 -1
- package/dist/ta/registry.d.ts.map +1 -1
- package/dist/ta/registry.js +4 -0
- package/dist/ta/registry.js.map +1 -1
- package/dist/ta/rsi.d.ts +3 -2
- package/dist/ta/rsi.d.ts.map +1 -1
- package/dist/ta/rsi.js +3 -2
- package/dist/ta/rsi.js.map +1 -1
- package/dist/ta/rvi.d.ts +3 -2
- package/dist/ta/rvi.d.ts.map +1 -1
- package/dist/ta/rvi.js +3 -2
- package/dist/ta/rvi.js.map +1 -1
- package/dist/ta/sma.d.ts +6 -3
- package/dist/ta/sma.d.ts.map +1 -1
- package/dist/ta/sma.js +6 -3
- package/dist/ta/sma.js.map +1 -1
- package/dist/ta/stdev.d.ts +3 -2
- package/dist/ta/stdev.d.ts.map +1 -1
- package/dist/ta/stdev.js +3 -2
- package/dist/ta/stdev.js.map +1 -1
- package/dist/ta/trendStrengthIndex.d.ts +3 -2
- package/dist/ta/trendStrengthIndex.d.ts.map +1 -1
- package/dist/ta/trendStrengthIndex.js +3 -2
- package/dist/ta/trendStrengthIndex.js.map +1 -1
- package/dist/ta/trix.d.ts +4 -3
- package/dist/ta/trix.d.ts.map +1 -1
- package/dist/ta/trix.js +4 -3
- package/dist/ta/trix.js.map +1 -1
- package/dist/ta/vortex.d.ts +3 -2
- package/dist/ta/vortex.d.ts.map +1 -1
- package/dist/ta/vortex.js +3 -2
- package/dist/ta/vortex.js.map +1 -1
- package/package.json +3 -3
- package/dist/ta/lib/applyOffset.d.ts +0 -19
- package/dist/ta/lib/applyOffset.d.ts.map +0 -1
- package/dist/ta/lib/applyOffset.js +0 -38
- package/dist/ta/lib/applyOffset.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../../../src/emit/draw/handle.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,mBAAmB,GAAG,2CAA2C,CAAC;AAExE,SAAS,UAAU,CAAC,IAAkB,EAAE,KAA4B;IAChE,4DAA4D;IAC5D,kEAAkE;IAClE,kEAAkE;IAClE,+DAA+D;IAC/D,iEAAiE;IACjE,iEAAiE;IACjE,4CAA4C;IAC5C,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAkB,CAAC;AAClE,CAAC;AAED,SAAS,IAAI,CACT,GAAmB,EACnB,QAAgB,EAChB,IAAiB,EACjB,EAAkC,EAClC,KAAmB;IAEnB,WAAW,CAAC,GAAG,EAAE;QACb,IAAI,EAAE,SAAS;QACf,QAAQ;QACR,WAAW,EAAE,IAAI;QACjB,EAAE;QACF,KAAK;QACL,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;QACnB,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI;KAC5B,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,mBAAmB,CAC/B,MAAc,EACd,KAAa,EACb,IAAiB,EACjB,YAA0B;IAE1B,MAAM,GAAG,GAAG,sBAAsB,C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AC7C,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO;gBAAE,OAAO;YACzC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACrC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC;QACD,MAAM;YACF,MAAM,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAC;YAC/C,IAAI,OAAO,KAAK,IAAI;gBAAE,OAAO;YAC7B,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC7C,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO;gBAAE,OAAO;YACzC,uDAAuD;YACvD,4DAA4D;YAC5D,0DAA0D;YAC1D,4DAA4D;YAC5D,sBAAsB;YACtB,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC;KACJ,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 { DrawingHandle, DrawingKind, DrawingState } from \"@invinite-org/chartlang-core\";\n\nimport { ACTIVE_RUNTIME_CONTEXT, type RuntimeContext } from \"../../runtimeContext.js\";\nimport { pushDrawing } from \"./pushDrawing.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"draw called outside an active script step\";\n\nfunction mergeState(prev: DrawingState, patch: Partial<DrawingState>): DrawingState {\n // Spread the patch over `prev` and force `kind` back to the\n // previous variant. A cross-variant patch from a script is a type\n // error at the script's callsite — the runtime defends against it\n // here so the runtime cannot accidentally emit a drift between\n // `drawingKind` and `state.kind`. The cast is safe because every\n // variant of `DrawingState` shares the shape `{ kind, ... }` and\n // discriminants stay pinned to `prev.kind`.\n return { ...prev, ...patch, kind: prev.kind } as DrawingState;\n}\n\nfunction emit(\n ctx: RuntimeContext,\n handleId: string,\n kind: DrawingKind,\n op: \"create\" | \"update\" | \"remove\",\n state: DrawingState,\n): void {\n pushDrawing(ctx, {\n kind: \"drawing\",\n handleId,\n drawingKind: kind,\n op,\n state,\n bar: ctx.barIndex(),\n time: ctx.stream.bar.time,\n });\n}\n\n/**\n * Construct a {@link DrawingHandle} for `slotId#subId` in the active\n * runtime context. Allocates the slot in `ctx.drawingSlots` on the\n * first call (`op: \"create\"`); subsequent calls at the same callsite\n * across bars find the existing slot and emit `op: \"update\"` with the\n * full merged state.\n *\n * `update(patch)` merges the patch with the current slot state and\n * re-emits the FULL merged state under `op: \"update\"`. `remove()`\n * emits one final `op: \"remove\"` with the\n * last-known state and flags the slot `removed: true`; subsequent\n * `update` / `remove` calls on the returned handle are no-ops.\n *\n * The handle's `id` is `slotId#subId` — stable across bars.\n *\n * @since 0.3\n * @stable\n * @example\n * // import {\n * // createDrawingHandle,\n * // } from \"@invinite-org/chartlang-runtime\";\n * // const h = createDrawingHandle(\n * // \"demo.chart.ts:5:13#0\",\n * // 0,\n * // \"line\",\n * // {\n * // kind: \"line\",\n * // anchors: [{ time: 0, price: 0 }, { time: 1, price: 1 }],\n * // style: {},\n * // },\n * // );\n * // h.update({ style: { color: \"#3b82f6\" } });\n * // h.remove();\n */\nexport function createDrawingHandle(\n slotId: string,\n subId: number,\n kind: DrawingKind,\n initialState: DrawingState,\n): DrawingHandle {\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (ctx === null) throw new Error(OUTSIDE_CTX_MESSAGE);\n\n const handleId = `${slotId}#${subId}`;\n const existing = ctx.drawingSlots.get(handleId);\n\n let slot: { handleId: string; kind: DrawingKind; state: DrawingState; removed: boolean };\n let op: \"create\" | \"update\";\n if (existing === undefined) {\n slot = { handleId, kind, state: initialState, removed: false };\n ctx.drawingSlots.set(handleId, slot);\n op = \"create\";\n } else {\n // Cross-bar re-entry. Merge initialState into the existing slot\n // (script-author may pass new anchors / style); resurrect if it\n // was previously removed.\n existing.state = mergeState(existing.state, initialState);\n existing.removed = false;\n slot = existing;\n op = \"update\";\n }\n\n emit(ctx, handleId, kind, op, slot.state);\n\n return {\n id: handleId,\n update(patch: Partial<DrawingState>): void {\n // `ACTIVE_RUNTIME_CONTEXT.current` can be null when the\n // host calls `handle.update(...)` outside a compute step\n // (e.g. from an async callback). Drop silently in that\n // case — the handle's slot still persists and the next\n // in-step `update` will fire.\n const liveCtx = ACTIVE_RUNTIME_CONTEXT.current;\n if (liveCtx === null) return;\n const s = liveCtx.drawingSlots.get(handleId);\n if (s === undefined || s.removed) return;\n s.state = mergeState(s.state, patch);\n emit(liveCtx, handleId, kind, \"update\", s.state);\n },\n remove(): void {\n const liveCtx = ACTIVE_RUNTIME_CONTEXT.current;\n if (liveCtx === null) return;\n const s = liveCtx.drawingSlots.get(handleId);\n if (s === undefined || s.removed) return;\n // Flag-before-emit is safe: capabilities are invariant\n // mid-run, so a previously-created handle's \"remove\" always\n // reaches `pushDrawing`. The slot stays flagged even if a\n // future drop path swallows the emission — a removed handle\n // must never re-emit.\n s.removed = true;\n emit(liveCtx, handleId, kind, \"remove\", s.state);\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../../../src/emit/draw/handle.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EACH,sBAAsB,GAGzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,mBAAmB,GAAG,2CAA2C,CAAC;AAExE,SAAS,UAAU,CAAC,IAAkB,EAAE,KAA4B;IAChE,4DAA4D;IAC5D,kEAAkE;IAClE,kEAAkE;IAClE,+DAA+D;IAC/D,iEAAiE;IACjE,iEAAiE;IACjE,4CAA4C;IAC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AC5D,0DAA0D;YAC1D,4DAA4D;YAC5D,0DAA0D;YAC1D,0BAA0B;YAC1B,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;KACJ,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 { DrawingHandle, DrawingKind, DrawingState } from \"@invinite-org/chartlang-core\";\n\nimport {\n ACTIVE_RUNTIME_CONTEXT,\n type DrawingSlot,\n type RuntimeContext,\n} from \"../../runtimeContext.js\";\nimport { pushDrawing } from \"./pushDrawing.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"draw called outside an active script step\";\n\nfunction mergeState(prev: DrawingState, patch: Partial<DrawingState>): DrawingState {\n // Spread the patch over `prev` and force `kind` back to the\n // previous variant. A cross-variant patch from a script is a type\n // error at the script's callsite — the runtime defends against it\n // here so the runtime cannot accidentally emit a drift between\n // `drawingKind` and `state.kind`. The cast is safe because every\n // variant of `DrawingState` shares the shape `{ kind, ... }` and\n // discriminants stay pinned to `prev.kind`.\n return { ...prev, ...patch, kind: prev.kind } as DrawingState;\n}\n\n/**\n * Lift the presentation-only `z` (render-order key) **out** of a\n * drawing's `state.style` and hand it back to the caller, returning a\n * state with `z` removed from a **shallow clone** of `style` (the\n * caller's style object is never mutated). Every `draw.*` option bag\n * carries `z` via core's `ZOrdered` mixin, and the per-kind impls fold\n * that bag into `state.style`, so `z` arrives nested at `state.style.z`.\n * `z` is a **top-level** `DrawingEmission` field, not part of\n * `DrawingState`, so it must not ride the wire inside `state` — strip it\n * here. Returns `z: 0` (the omit-when-`0` default) for states with no\n * `style` (e.g. `group`) or no `z`, leaving the state object **untouched**\n * in that case so a no-`z` drawing stays byte-identical to the\n * pre-feature baseline.\n */\nfunction splitZ(state: DrawingState): { state: DrawingState; z: number } {\n if (!(\"style\" in state) || state.style === undefined) {\n return { state, z: 0 };\n }\n const style: { z?: number } = state.style;\n if (style.z === undefined) {\n return { state, z: 0 };\n }\n // Shallow-clone style with `z` removed — never mutate the caller's\n // object. `rest` is z-free, so the wire `state.style` carries no `z`.\n const { z, ...rest } = style;\n return { state: { ...state, style: rest } as DrawingState, z };\n}\n\nfunction emit(\n ctx: RuntimeContext,\n handleId: string,\n kind: DrawingKind,\n op: \"create\" | \"update\" | \"remove\",\n state: DrawingState,\n z: number,\n): void {\n pushDrawing(ctx, {\n kind: \"drawing\",\n handleId,\n drawingKind: kind,\n op,\n state,\n bar: ctx.barIndex(),\n time: ctx.stream.bar.time,\n // `z` is presentation-only and top-level (never inside `state`);\n // omit it when `0` so a no-`z` drawing is byte-identical to the\n // pre-feature baseline — mirrors `PlotEmission.xShift` / `.z`.\n ...(z === 0 ? {} : { z }),\n });\n}\n\n/**\n * Construct a {@link DrawingHandle} for `slotId#subId` in the active\n * runtime context. Allocates the slot in `ctx.drawingSlots` on the\n * first call (`op: \"create\"`); subsequent calls at the same callsite\n * across bars find the existing slot and emit `op: \"update\"` with the\n * full merged state.\n *\n * `update(patch)` merges the patch with the current slot state and\n * re-emits the FULL merged state under `op: \"update\"`. `remove()`\n * emits one final `op: \"remove\"` with the\n * last-known state and flags the slot `removed: true`; subsequent\n * `update` / `remove` calls on the returned handle are no-ops.\n *\n * The handle's `id` is `slotId#subId` — stable across bars.\n *\n * `z` is the presentation-only render-order key the `draw.*` opts bag\n * carried (core's `ZOrdered` mixin) folded into `state.style`. It is\n * {@link splitZ | lifted out} of `state.style` so it rides the wire as\n * the top-level {@link DrawingEmission.z} field, **never** inside\n * `DrawingState` (Task 3 forbids `z` in `state`), and is persisted on\n * the slot. An `update` that does not re-specify a non-zero `z` retains\n * the last value; a re-specified non-zero `z` overrides; `remove`\n * carries the last-known `z`.\n *\n * @since 0.3\n * @stable\n * @example\n * // import {\n * // createDrawingHandle,\n * // } from \"@invinite-org/chartlang-runtime\";\n * // const h = createDrawingHandle(\n * // \"demo.chart.ts:5:13#0\",\n * // 0,\n * // \"line\",\n * // {\n * // kind: \"line\",\n * // anchors: [{ time: 0, price: 0 }, { time: 1, price: 1 }],\n * // style: {},\n * // },\n * // );\n * // h.update({ style: { color: \"#3b82f6\" } });\n * // h.remove();\n */\nexport function createDrawingHandle(\n slotId: string,\n subId: number,\n kind: DrawingKind,\n initialState: DrawingState,\n): DrawingHandle {\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (ctx === null) throw new Error(OUTSIDE_CTX_MESSAGE);\n\n const handleId = `${slotId}#${subId}`;\n const existing = ctx.drawingSlots.get(handleId);\n\n // Lift `z` out of `state.style` so it rides the emission top-level,\n // not inside `DrawingState`. The remaining `style` (z removed) is\n // what persists in the slot.\n const initial = splitZ(initialState);\n\n let slot: DrawingSlot;\n let op: \"create\" | \"update\";\n if (existing === undefined) {\n slot = { handleId, kind, state: initial.state, z: initial.z, removed: false };\n ctx.drawingSlots.set(handleId, slot);\n op = \"create\";\n } else {\n // Cross-bar re-entry. Merge initialState into the existing slot\n // (script-author may pass new anchors / style); resurrect if it\n // was previously removed. A re-specified `z` (non-default)\n // overrides the retained one; an omitted/`0` `z` keeps the last.\n existing.state = mergeState(existing.state, initial.state);\n if (initial.z !== 0) existing.z = initial.z;\n existing.removed = false;\n slot = existing;\n op = \"update\";\n }\n\n emit(ctx, handleId, kind, op, slot.state, slot.z);\n\n return {\n id: handleId,\n update(patch: Partial<DrawingState>): void {\n // `ACTIVE_RUNTIME_CONTEXT.current` can be null when the\n // host calls `handle.update(...)` outside a compute step\n // (e.g. from an async callback). Drop silently in that\n // case — the handle's slot still persists and the next\n // in-step `update` will fire.\n const liveCtx = ACTIVE_RUNTIME_CONTEXT.current;\n if (liveCtx === null) return;\n const s = liveCtx.drawingSlots.get(handleId);\n if (s === undefined || s.removed) return;\n // A patch may re-specify `z` inside `style`; split it out so\n // it never merges into `state.style`. A re-specified\n // non-default `z` overrides; an omitted/`0` `z` retains the\n // slot's last value.\n const split = splitZ(mergeState(s.state, patch));\n s.state = split.state;\n if (split.z !== 0) s.z = split.z;\n emit(liveCtx, handleId, kind, \"update\", s.state, s.z);\n },\n remove(): void {\n const liveCtx = ACTIVE_RUNTIME_CONTEXT.current;\n if (liveCtx === null) return;\n const s = liveCtx.drawingSlots.get(handleId);\n if (s === undefined || s.removed) return;\n // Flag-before-emit is safe: capabilities are invariant\n // mid-run, so a previously-created handle's \"remove\" always\n // reaches `pushDrawing`. The slot stays flagged even if a\n // future drop path swallows the emission — a removed handle\n // must never re-emit. `remove` carries the last-known `z`\n // (harmless — no render).\n s.removed = true;\n emit(liveCtx, handleId, kind, \"remove\", s.state, s.z);\n },\n };\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { DrawNamespace } from "@invinite-org/chartlang-core";
|
|
2
2
|
/**
|
|
3
|
-
* Runtime `draw` namespace.
|
|
4
|
-
*
|
|
5
|
-
* Phase 5
|
|
3
|
+
* Runtime `draw` namespace. Every one of the 63 `DrawingKind`s has a
|
|
4
|
+
* real per-kind impl wired into `KIND_IMPLS` (Task 18 brought the count
|
|
5
|
+
* to 61; Phase 5 added the viewport-anchored `table` kind; the
|
|
6
|
+
* fill-between feature added `fill-between`).
|
|
6
7
|
* the Proxy's `else` branch (fall-through to the core throwing-stub
|
|
7
8
|
* Proxy) is dead code at runtime — kept as defence-in-depth for
|
|
8
9
|
* unknown property access (e.g. JS code accessing a property name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/emit/draw/namespace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/emit/draw/namespace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAuJlE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,cAAc,EAAE,aAe3B,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { arrowMarker } from "./annotations/arrowMarker.js";
|
|
|
8
8
|
import { text } from "./annotations/text.js";
|
|
9
9
|
import { circle } from "./boxes/circle.js";
|
|
10
10
|
import { ellipse } from "./boxes/ellipse.js";
|
|
11
|
+
import { fillBetween } from "./boxes/fillBetween.js";
|
|
11
12
|
import { marker } from "./boxes/marker.js";
|
|
12
13
|
import { path } from "./boxes/path.js";
|
|
13
14
|
import { polyline } from "./boxes/polyline.js";
|
|
@@ -80,6 +81,7 @@ const KIND_IMPLS = {
|
|
|
80
81
|
circle,
|
|
81
82
|
ellipse,
|
|
82
83
|
path,
|
|
84
|
+
fillBetween,
|
|
83
85
|
marker,
|
|
84
86
|
// Task 8 — Curves
|
|
85
87
|
arc,
|
|
@@ -145,9 +147,10 @@ const KIND_IMPLS = {
|
|
|
145
147
|
};
|
|
146
148
|
const IMPL_KIND_NAMES = new Set(Object.keys(KIND_IMPLS));
|
|
147
149
|
/**
|
|
148
|
-
* Runtime `draw` namespace.
|
|
149
|
-
*
|
|
150
|
-
* Phase 5
|
|
150
|
+
* Runtime `draw` namespace. Every one of the 63 `DrawingKind`s has a
|
|
151
|
+
* real per-kind impl wired into `KIND_IMPLS` (Task 18 brought the count
|
|
152
|
+
* to 61; Phase 5 added the viewport-anchored `table` kind; the
|
|
153
|
+
* fill-between feature added `fill-between`).
|
|
151
154
|
* the Proxy's `else` branch (fall-through to the core throwing-stub
|
|
152
155
|
* Proxy) is dead code at runtime — kept as defence-in-depth for
|
|
153
156
|
* unknown property access (e.g. JS code accessing a property name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/emit/draw/namespace.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG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LICENSE file in the repo root for full license text.\n\nimport type { DrawNamespace } from \"@invinite-org/chartlang-core\";\nimport { draw as CORE_DRAW_STUB } from \"@invinite-org/chartlang-core\";\n\nimport { arrow } from \"./annotations/arrow.js\";\nimport { arrowMarkDown } from \"./annotations/arrowMarkDown.js\";\nimport { arrowMarkUp } from \"./annotations/arrowMarkUp.js\";\nimport { arrowMarker } from \"./annotations/arrowMarker.js\";\nimport { text } from \"./annotations/text.js\";\nimport { circle } from \"./boxes/circle.js\";\nimport { ellipse } from \"./boxes/ellipse.js\";\nimport { marker } from \"./boxes/marker.js\";\nimport { path } from \"./boxes/path.js\";\nimport { polyline } from \"./boxes/polyline.js\";\nimport { rectangle } from \"./boxes/rectangle.js\";\nimport { rotatedRectangle } from \"./boxes/rotatedRectangle.js\";\nimport { triangle } from \"./boxes/triangle.js\";\nimport { disjointChannel } from \"./channels/disjointChannel.js\";\nimport { flatTopBottom } from \"./channels/flatTopBottom.js\";\nimport { regressionTrend } from \"./channels/regressionTrend.js\";\nimport { trendChannel } from \"./channels/trendChannel.js\";\nimport { frame } from \"./containers/frame.js\";\nimport { group } from \"./containers/group.js\";\nimport { arc } from \"./curves/arc.js\";\nimport { brush } from \"./curves/brush.js\";\nimport { curve } from \"./curves/curve.js\";\nimport { doubleCurve } from \"./curves/doubleCurve.js\";\nimport { highlighter } from \"./curves/highlighter.js\";\nimport { pen } from \"./curves/pen.js\";\nimport { cyclicLines } from \"./cycles/cyclicLines.js\";\nimport { sineLine } from \"./cycles/sineLine.js\";\nimport { timeCycles } from \"./cycles/timeCycles.js\";\nimport { elliottCorrectionWave } from \"./elliott/elliottCorrectionWave.js\";\nimport { elliottDoubleCombo } from \"./elliott/elliottDoubleCombo.js\";\nimport { elliottImpulseWave } from \"./elliott/elliottImpulseWave.js\";\nimport { elliottTriangleWave } from \"./elliott/elliottTriangleWave.js\";\nimport { elliottTripleCombo } from \"./elliott/elliottTripleCombo.js\";\nimport { fibChannel } from \"./fibA/fibChannel.js\";\nimport { fibRetracement } from \"./fibA/fibRetracement.js\";\nimport { fibTimeZone } from \"./fibA/fibTimeZone.js\";\nimport { fibTrendExtension } from \"./fibA/fibTrendExtension.js\";\nimport { fibWedge } from \"./fibA/fibWedge.js\";\nimport { fibCircles } from \"./fibB/fibCircles.js\";\nimport { fibSpeedArcs } from \"./fibB/fibSpeedArcs.js\";\nimport { fibSpeedFan } from \"./fibB/fibSpeedFan.js\";\nimport { fibSpiral } from \"./fibB/fibSpiral.js\";\nimport { fibTrendTime } from \"./fibB/fibTrendTime.js\";\nimport { gannBox } from \"./gann/gannBox.js\";\nimport { gannFan } from \"./gann/gannFan.js\";\nimport { gannSquare } from \"./gann/gannSquare.js\";\nimport { gannSquareFixed } from \"./gann/gannSquareFixed.js\";\nimport { crossLine } from \"./lines/crossLine.js\";\nimport { horizontalLine } from \"./lines/horizontalLine.js\";\nimport { horizontalRay } from \"./lines/horizontalRay.js\";\nimport { line } from \"./lines/line.js\";\nimport { trendAngle } from \"./lines/trendAngle.js\";\nimport { verticalLine } from \"./lines/verticalLine.js\";\nimport { abcdPattern } from \"./patterns/abcdPattern.js\";\nimport { cypherPattern } from \"./patterns/cypherPattern.js\";\nimport { headAndShoulders } from \"./patterns/headAndShoulders.js\";\nimport { threeDrivesPattern } from \"./patterns/threeDrivesPattern.js\";\nimport { trianglePattern } from \"./patterns/trianglePattern.js\";\nimport { xabcdPattern } from \"./patterns/xabcdPattern.js\";\nimport { pitchfan } from \"./pitchforks/pitchfan.js\";\nimport { pitchfork } from \"./pitchforks/pitchfork.js\";\nimport { table } from \"./table/table.js\";\n\nconst KIND_IMPLS = {\n // Task 5 — Lines/Rays\n line,\n horizontalLine,\n horizontalRay,\n verticalLine,\n crossLine,\n trendAngle,\n // Task 6 — Boxes A\n rectangle,\n rotatedRectangle,\n triangle,\n polyline,\n // Task 7 — Boxes B\n circle,\n ellipse,\n path,\n marker,\n // Task 8 — Curves\n arc,\n curve,\n doubleCurve,\n // Task 8 — Freehand\n pen,\n highlighter,\n brush,\n // Task 9 — Annotations\n text,\n arrow,\n arrowMarker,\n arrowMarkUp,\n arrowMarkDown,\n // Task 10 — Channels\n trendChannel,\n flatTopBottom,\n disjointChannel,\n regressionTrend,\n // Task 11 — Fibonacci A\n fibRetracement,\n fibTrendExtension,\n fibChannel,\n fibTimeZone,\n fibWedge,\n // Task 12 — Fibonacci B\n fibSpeedFan,\n fibSpeedArcs,\n fibSpiral,\n fibCircles,\n fibTrendTime,\n // Task 13 — Gann\n gannBox,\n gannSquareFixed,\n gannSquare,\n gannFan,\n // Task 14 — Pitchforks\n pitchfork,\n pitchfan,\n // Task 15 — Harmonic Patterns\n xabcdPattern,\n cypherPattern,\n headAndShoulders,\n abcdPattern,\n trianglePattern,\n threeDrivesPattern,\n // Task 16 — Elliott Waves\n elliottImpulseWave,\n elliottCorrectionWave,\n elliottTriangleWave,\n elliottDoubleCombo,\n elliottTripleCombo,\n // Task 17 — Cycles\n cyclicLines,\n timeCycles,\n sineLine,\n // Task 18 — Containers\n group,\n frame,\n // Phase 5 — Viewport overlays\n table,\n} as const;\n\nconst IMPL_KIND_NAMES: ReadonlySet<string> = new Set(Object.keys(KIND_IMPLS));\n\n/**\n * Runtime `draw` namespace. After Task 18 every one of the 61\n * `DrawingKind`s has a real per-kind impl wired into `KIND_IMPLS`;\n * Phase 5 adds the viewport-anchored `table` kind.\n * the Proxy's `else` branch (fall-through to the core throwing-stub\n * Proxy) is dead code at runtime — kept as defence-in-depth for\n * unknown property access (e.g. JS code accessing a property name\n * outside the `DrawNamespace` type surface).\n *\n * Each per-kind impl is the compiler-injected overload — the\n * dispatch branches on `typeof arg1 === \"string\"` to discriminate the\n * slot-id-prefixed compiler form from the bare script-facing form\n * which always throws. This is the Phase-3 swap seam for the\n * `primitives.ts:draw` re-export, mirroring how `TA_REGISTRY` swaps\n * in Phase 2.\n *\n * @since 0.3\n * @stable\n * @example\n * import { draw } from \"@invinite-org/chartlang-runtime\";\n * // type S = typeof draw;\n * void draw;\n */\nexport const DRAW_NAMESPACE: DrawNamespace = new Proxy(KIND_IMPLS as unknown as DrawNamespace, {\n get(target, property): unknown {\n const name = String(property);\n if (IMPL_KIND_NAMES.has(name)) {\n return Reflect.get(target, property);\n }\n // After Task 18 every `DrawingKind` has a real impl in\n // `KIND_IMPLS` so this branch is unreachable through the\n // `DrawNamespace` type surface — it stays as defence-in-depth\n // for non-kind property access (e.g. JS code that reads\n // `draw[\"foo\"]` through a typed-erased view). Falling through\n // to core's throwing-stub keeps the failure mode consistent\n // with the pre-Task-18 behaviour.\n return Reflect.get(CORE_DRAW_STUB, property);\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/emit/draw/namespace.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,IAAI,IAAI,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC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;;GAuBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB,IAAI,KAAK,CAAC,UAAsC,EAAE;IAC3F,GAAG,CAAC,MAAM,EAAE,QAAQ;QAChB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACzC,CAAC;QACD,uDAAuD;QACvD,yDAAyD;QACzD,8DAA8D;QAC9D,wDAAwD;QACxD,8DAA8D;QAC9D,4DAA4D;QAC5D,kCAAkC;QAClC,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;CACJ,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 { DrawNamespace } from \"@invinite-org/chartlang-core\";\nimport { draw as CORE_DRAW_STUB } from \"@invinite-org/chartlang-core\";\n\nimport { arrow } from \"./annotations/arrow.js\";\nimport { arrowMarkDown } from \"./annotations/arrowMarkDown.js\";\nimport { arrowMarkUp } from \"./annotations/arrowMarkUp.js\";\nimport { arrowMarker } from \"./annotations/arrowMarker.js\";\nimport { text } from \"./annotations/text.js\";\nimport { circle } from \"./boxes/circle.js\";\nimport { ellipse } from \"./boxes/ellipse.js\";\nimport { fillBetween } from \"./boxes/fillBetween.js\";\nimport { marker } from \"./boxes/marker.js\";\nimport { path } from \"./boxes/path.js\";\nimport { polyline } from \"./boxes/polyline.js\";\nimport { rectangle } from \"./boxes/rectangle.js\";\nimport { rotatedRectangle } from \"./boxes/rotatedRectangle.js\";\nimport { triangle } from \"./boxes/triangle.js\";\nimport { disjointChannel } from \"./channels/disjointChannel.js\";\nimport { flatTopBottom } from \"./channels/flatTopBottom.js\";\nimport { regressionTrend } from \"./channels/regressionTrend.js\";\nimport { trendChannel } from \"./channels/trendChannel.js\";\nimport { frame } from \"./containers/frame.js\";\nimport { group } from \"./containers/group.js\";\nimport { arc } from \"./curves/arc.js\";\nimport { brush } from \"./curves/brush.js\";\nimport { curve } from \"./curves/curve.js\";\nimport { doubleCurve } from \"./curves/doubleCurve.js\";\nimport { highlighter } from \"./curves/highlighter.js\";\nimport { pen } from \"./curves/pen.js\";\nimport { cyclicLines } from \"./cycles/cyclicLines.js\";\nimport { sineLine } from \"./cycles/sineLine.js\";\nimport { timeCycles } from \"./cycles/timeCycles.js\";\nimport { elliottCorrectionWave } from \"./elliott/elliottCorrectionWave.js\";\nimport { elliottDoubleCombo } from \"./elliott/elliottDoubleCombo.js\";\nimport { elliottImpulseWave } from \"./elliott/elliottImpulseWave.js\";\nimport { elliottTriangleWave } from \"./elliott/elliottTriangleWave.js\";\nimport { elliottTripleCombo } from \"./elliott/elliottTripleCombo.js\";\nimport { fibChannel } from \"./fibA/fibChannel.js\";\nimport { fibRetracement } from \"./fibA/fibRetracement.js\";\nimport { fibTimeZone } from \"./fibA/fibTimeZone.js\";\nimport { fibTrendExtension } from \"./fibA/fibTrendExtension.js\";\nimport { fibWedge } from \"./fibA/fibWedge.js\";\nimport { fibCircles } from \"./fibB/fibCircles.js\";\nimport { fibSpeedArcs } from \"./fibB/fibSpeedArcs.js\";\nimport { fibSpeedFan } from \"./fibB/fibSpeedFan.js\";\nimport { fibSpiral } from \"./fibB/fibSpiral.js\";\nimport { fibTrendTime } from \"./fibB/fibTrendTime.js\";\nimport { gannBox } from \"./gann/gannBox.js\";\nimport { gannFan } from \"./gann/gannFan.js\";\nimport { gannSquare } from \"./gann/gannSquare.js\";\nimport { gannSquareFixed } from \"./gann/gannSquareFixed.js\";\nimport { crossLine } from \"./lines/crossLine.js\";\nimport { horizontalLine } from \"./lines/horizontalLine.js\";\nimport { horizontalRay } from \"./lines/horizontalRay.js\";\nimport { line } from \"./lines/line.js\";\nimport { trendAngle } from \"./lines/trendAngle.js\";\nimport { verticalLine } from \"./lines/verticalLine.js\";\nimport { abcdPattern } from \"./patterns/abcdPattern.js\";\nimport { cypherPattern } from \"./patterns/cypherPattern.js\";\nimport { headAndShoulders } from \"./patterns/headAndShoulders.js\";\nimport { threeDrivesPattern } from \"./patterns/threeDrivesPattern.js\";\nimport { trianglePattern } from \"./patterns/trianglePattern.js\";\nimport { xabcdPattern } from \"./patterns/xabcdPattern.js\";\nimport { pitchfan } from \"./pitchforks/pitchfan.js\";\nimport { pitchfork } from \"./pitchforks/pitchfork.js\";\nimport { table } from \"./table/table.js\";\n\nconst KIND_IMPLS = {\n // Task 5 — Lines/Rays\n line,\n horizontalLine,\n horizontalRay,\n verticalLine,\n crossLine,\n trendAngle,\n // Task 6 — Boxes A\n rectangle,\n rotatedRectangle,\n triangle,\n polyline,\n // Task 7 — Boxes B\n circle,\n ellipse,\n path,\n fillBetween,\n marker,\n // Task 8 — Curves\n arc,\n curve,\n doubleCurve,\n // Task 8 — Freehand\n pen,\n highlighter,\n brush,\n // Task 9 — Annotations\n text,\n arrow,\n arrowMarker,\n arrowMarkUp,\n arrowMarkDown,\n // Task 10 — Channels\n trendChannel,\n flatTopBottom,\n disjointChannel,\n regressionTrend,\n // Task 11 — Fibonacci A\n fibRetracement,\n fibTrendExtension,\n fibChannel,\n fibTimeZone,\n fibWedge,\n // Task 12 — Fibonacci B\n fibSpeedFan,\n fibSpeedArcs,\n fibSpiral,\n fibCircles,\n fibTrendTime,\n // Task 13 — Gann\n gannBox,\n gannSquareFixed,\n gannSquare,\n gannFan,\n // Task 14 — Pitchforks\n pitchfork,\n pitchfan,\n // Task 15 — Harmonic Patterns\n xabcdPattern,\n cypherPattern,\n headAndShoulders,\n abcdPattern,\n trianglePattern,\n threeDrivesPattern,\n // Task 16 — Elliott Waves\n elliottImpulseWave,\n elliottCorrectionWave,\n elliottTriangleWave,\n elliottDoubleCombo,\n elliottTripleCombo,\n // Task 17 — Cycles\n cyclicLines,\n timeCycles,\n sineLine,\n // Task 18 — Containers\n group,\n frame,\n // Phase 5 — Viewport overlays\n table,\n} as const;\n\nconst IMPL_KIND_NAMES: ReadonlySet<string> = new Set(Object.keys(KIND_IMPLS));\n\n/**\n * Runtime `draw` namespace. Every one of the 63 `DrawingKind`s has a\n * real per-kind impl wired into `KIND_IMPLS` (Task 18 brought the count\n * to 61; Phase 5 added the viewport-anchored `table` kind; the\n * fill-between feature added `fill-between`).\n * the Proxy's `else` branch (fall-through to the core throwing-stub\n * Proxy) is dead code at runtime — kept as defence-in-depth for\n * unknown property access (e.g. JS code accessing a property name\n * outside the `DrawNamespace` type surface).\n *\n * Each per-kind impl is the compiler-injected overload — the\n * dispatch branches on `typeof arg1 === \"string\"` to discriminate the\n * slot-id-prefixed compiler form from the bare script-facing form\n * which always throws. This is the Phase-3 swap seam for the\n * `primitives.ts:draw` re-export, mirroring how `TA_REGISTRY` swaps\n * in Phase 2.\n *\n * @since 0.3\n * @stable\n * @example\n * import { draw } from \"@invinite-org/chartlang-runtime\";\n * // type S = typeof draw;\n * void draw;\n */\nexport const DRAW_NAMESPACE: DrawNamespace = new Proxy(KIND_IMPLS as unknown as DrawNamespace, {\n get(target, property): unknown {\n const name = String(property);\n if (IMPL_KIND_NAMES.has(name)) {\n return Reflect.get(target, property);\n }\n // After Task 18 every `DrawingKind` has a real impl in\n // `KIND_IMPLS` so this branch is unreachable through the\n // `DrawNamespace` type surface — it stays as defence-in-depth\n // for non-kind property access (e.g. JS code that reads\n // `draw[\"foo\"]` through a typed-erased view). Falling through\n // to core's throwing-stub keeps the failure mode consistent\n // with the pre-Task-18 behaviour.\n return Reflect.get(CORE_DRAW_STUB, property);\n },\n});\n"]}
|
package/dist/emit/plot.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ import type { PlotOpts, Series } from "@invinite-org/chartlang-core";
|
|
|
14
14
|
* via the sibling {@link hline} primitive. Phase 2+ extends the `kind`
|
|
15
15
|
* variants additively.
|
|
16
16
|
*
|
|
17
|
+
* When the plotted value is a `ta.*` series declared with an `offset`
|
|
18
|
+
* (or ALMA's `barShift`), that signed bar count rides the emission as
|
|
19
|
+
* `PlotEmission.xShift` (presentation-only — `+n` renders the series `n`
|
|
20
|
+
* bars right, `−n` `n` bars left); the emitted `value` itself is
|
|
21
|
+
* unshifted, so alerts and `state.*` see the value computed at the
|
|
22
|
+
* current bar.
|
|
23
|
+
*
|
|
17
24
|
* @since 0.1
|
|
18
25
|
* @example
|
|
19
26
|
* import { defineIndicator, ta, plot } from "@invinite-org/chartlang-core";
|
package/dist/emit/plot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../src/emit/plot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../src/emit/plot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAuIrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;AAC5E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC"}
|
package/dist/emit/plot.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
3
|
import { ACTIVE_RUNTIME_CONTEXT } from "../runtimeContext.js";
|
|
4
|
+
import { seriesOffsetOf } from "../seriesView.js";
|
|
4
5
|
import { applyPlotOverride } from "./applyPlotOverride.js";
|
|
5
6
|
import { pushDiagnostic, pushPlot } from "./emissionsQueue.js";
|
|
6
7
|
import { resolvePane } from "./paneResolver.js";
|
|
@@ -88,6 +89,16 @@ function plotImpl(ctx, slotId, value, opts) {
|
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
91
|
const pane = resolvePane(opts.pane, ctx, slotId);
|
|
92
|
+
// A `ta.*` series carries its declared `offset` (ALMA: `barShift`) as a
|
|
93
|
+
// presentation x-shift recorded on the series view; thread it onto the
|
|
94
|
+
// emission. A plain numeric value or an untagged series omits `xShift`,
|
|
95
|
+
// keeping the no-offset wire byte-identical to the pre-feature baseline.
|
|
96
|
+
const xShift = typeof value === "number" ? 0 : seriesOffsetOf(value);
|
|
97
|
+
// `z` is a direct plot-call option (a render-order key), unlike
|
|
98
|
+
// `xShift` (derived from the series view). Normalize undefined → `0`
|
|
99
|
+
// and append it with the same omit-when-`0` conditional spread so a
|
|
100
|
+
// no-`z` plot stays byte-identical to the pre-feature baseline.
|
|
101
|
+
const z = opts.z ?? 0;
|
|
91
102
|
const emission = {
|
|
92
103
|
kind: "plot",
|
|
93
104
|
slotId,
|
|
@@ -99,6 +110,8 @@ function plotImpl(ctx, slotId, value, opts) {
|
|
|
99
110
|
color: opts.color ?? null,
|
|
100
111
|
meta: {},
|
|
101
112
|
pane,
|
|
113
|
+
...(xShift === 0 ? {} : { xShift }),
|
|
114
|
+
...(z === 0 ? {} : { z }),
|
|
102
115
|
};
|
|
103
116
|
pushPlot(ctx.emissions, applyPlotOverride(emission, ctx.plotOverrides[slotId]));
|
|
104
117
|
}
|
package/dist/emit/plot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/emit/plot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAK/D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,sBAAsB,CA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AAiB;QAC3B,IAAI,EAAE,MAAM;QACZ,MAAM;QACN,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;QACvB,KAAK;QACL,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;QACnB,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI;QACzB,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC;QAC1B,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI;QACzB,IAAI,EAAE,EAAE;QACR,IAAI;KACP,CAAC;IAEF,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,iBAAiB,CAAC,QAAQ,EAAE,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC;AA6CD;;;;;;;;;GASG;AACH,MAAM,UAAU,IAAI,CAChB,IAAsC,EACtC,IAAyC,EACzC,IAAe;IAEf,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC;IAC3C,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC/C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAC1C,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 { PlotEmission, PlotStyle } from \"@invinite-org/chartlang-adapter-kit\";\nimport type { PlotOpts, Series } from \"@invinite-org/chartlang-core\";\n\nimport { ACTIVE_RUNTIME_CONTEXT, type RuntimeContext } from \"../runtimeContext.js\";\nimport { applyPlotOverride } from \"./applyPlotOverride.js\";\nimport { pushDiagnostic, pushPlot } from \"./emissionsQueue.js\";\nimport { resolvePane } from \"./paneResolver.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"plot called outside an active script step\";\n\nfunction isSeriesNumber(v: unknown): v is Series<number> {\n return typeof v === \"object\" && v !== null && \"current\" in v;\n}\n\nfunction isNumberOrSeries(v: unknown): v is number | Series<number> {\n return typeof v === \"number\" || isSeriesNumber(v);\n}\n\nfunction resolveValue(value: number | Series<number>): number | null {\n const resolved = typeof value === \"number\" ? value : value.current;\n return Number.isFinite(resolved) ? resolved : null;\n}\n\nfunction buildStyle(opts: PlotOpts): PlotStyle {\n const style = opts.style;\n if (style === undefined) {\n return {\n kind: \"line\",\n lineWidth: opts.lineWidth ?? 1,\n lineStyle: opts.lineStyle ?? \"solid\",\n };\n }\n switch (style.kind) {\n case \"histogram\":\n return { kind: \"histogram\", baseline: style.baseline ?? 0 };\n case \"marker\":\n return { kind: \"marker\", shape: style.shape, size: style.size };\n case \"shape\":\n return {\n kind: \"shape\",\n shape: style.shape,\n size: style.size,\n ...(style.location === undefined ? {} : { location: style.location }),\n };\n case \"character\":\n return {\n kind: \"character\",\n char: style.char,\n size: style.size,\n ...(style.location === undefined ? {} : { location: style.location }),\n };\n case \"arrow\":\n return { kind: \"arrow\", direction: style.direction, size: style.size };\n case \"candle-override\":\n return {\n kind: \"candle-override\",\n bull: style.bull,\n bear: style.bear,\n ...(style.doji === undefined ? {} : { doji: style.doji }),\n };\n case \"bar-override\":\n return { kind: \"bar-override\", color: style.color };\n case \"bg-color\":\n return {\n kind: \"bg-color\",\n color: style.color,\n ...(style.transp === undefined ? {} : { transp: style.transp }),\n };\n case \"bar-color\":\n return { kind: \"bar-color\", color: style.color };\n case \"horizontal-histogram\":\n return { kind: \"horizontal-histogram\", buckets: style.buckets };\n case \"line\":\n case \"step-line\":\n case \"horizontal-line\":\n return {\n kind: style.kind,\n lineWidth: opts.lineWidth ?? 1,\n lineStyle: opts.lineStyle ?? \"solid\",\n };\n }\n}\n\nfunction plotImpl(\n ctx: RuntimeContext,\n slotId: string,\n value: number | Series<number>,\n opts: PlotOpts,\n): void {\n const style: PlotStyle = buildStyle(opts);\n\n if (!ctx.capabilities.plots.has(style.kind)) {\n pushDiagnostic(ctx.emissions, {\n kind: \"diagnostic\",\n severity: \"warning\",\n code: \"unsupported-plot-kind\",\n message: `Adapter cannot render plot kind \"${style.kind}\".`,\n slotId,\n bar: ctx.barIndex(),\n });\n return;\n }\n\n const pane = resolvePane(opts.pane, ctx, slotId);\n\n const emission: PlotEmission = {\n kind: \"plot\",\n slotId,\n title: opts.title ?? \"\",\n style,\n bar: ctx.barIndex(),\n time: ctx.stream.bar.time,\n value: resolveValue(value),\n color: opts.color ?? null,\n meta: {},\n pane,\n };\n\n pushPlot(ctx.emissions, applyPlotOverride(emission, ctx.plotOverrides[slotId]));\n}\n\n/**\n * Emit a plot line for the current bar (script-facing overload).\n *\n * The runtime export is dual-signature: scripts call `plot(value, opts?)`\n * (the surface declared on `@invinite-org/chartlang-core`'s\n * `ComputeContext`), and Task 2's compiler transformer rewrites every\n * callsite to inject the compiler-issued slot id as the leading\n * argument — see the sibling `plot(slotId, value, opts?)` overload.\n * A direct invocation without a slot id (i.e. outside a compiled\n * bundle) throws the sentinel error.\n *\n * Plot kind is always `\"line\"` in Phase 1; `\"horizontal-line\"` ships\n * via the sibling {@link hline} primitive. Phase 2+ extends the `kind`\n * variants additively.\n *\n * @since 0.1\n * @example\n * import { defineIndicator, ta, plot } from \"@invinite-org/chartlang-core\";\n * export default defineIndicator({\n * name: \"EMA(20)\",\n * apiVersion: 1,\n * compute({ bar, ta, plot }) {\n * plot(ta.ema(bar.close, 20), { color: \"#26a69a\", title: \"EMA\" });\n * },\n * });\n */\nexport function plot(value: number | Series<number>, opts?: PlotOpts): void;\n/**\n * Emit a plot line for the current bar (compiler-injected overload).\n *\n * Task 2's callsite-id transformer rewrites every script-side\n * `plot(value, opts?)` into `plot(slotId, value, opts?)`. The runtime\n * branches on `typeof arg1 === \"string\"` so the compiler-emitted\n * bundle dispatches here directly.\n *\n * @since 0.1\n * @example\n * // Internal — the compiler rewrites every script callsite, e.g.\n * // `plot(close)` becomes `plot(\"demo.chart.ts:5:13#0\", close)`.\n * // const fn: typeof plot = plot;\n * // void fn;\n */\nexport function plot(slotId: string, value: number | Series<number>, opts?: PlotOpts): void;\n/**\n * Implementation signature for {@link plot}. Branches on\n * `typeof arg1 === \"string\"` to dispatch the script-facing vs\n * compiler-injected overload.\n *\n * @since 0.1\n * @example\n * // const fn: typeof plot = plot;\n * // void fn;\n */\nexport function plot(\n arg1: string | number | Series<number>,\n arg2?: number | Series<number> | PlotOpts,\n arg3?: PlotOpts,\n): void {\n if (typeof arg1 !== \"string\") {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (!ctx) throw new Error(OUTSIDE_CTX_MESSAGE);\n if (!isNumberOrSeries(arg2)) {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n plotImpl(ctx, arg1, arg2, arg3 ?? {});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/emit/plot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAK/D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,mBAAmB,GAAG,2CAA2C,CAAC;AAExE,SAAS,cAAc,CAAC,CAAU;IAC9B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC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cesContent":["// 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 { PlotEmission, PlotStyle } from \"@invinite-org/chartlang-adapter-kit\";\nimport type { PlotOpts, Series } from \"@invinite-org/chartlang-core\";\n\nimport { ACTIVE_RUNTIME_CONTEXT, type RuntimeContext } from \"../runtimeContext.js\";\nimport { seriesOffsetOf } from \"../seriesView.js\";\nimport { applyPlotOverride } from \"./applyPlotOverride.js\";\nimport { pushDiagnostic, pushPlot } from \"./emissionsQueue.js\";\nimport { resolvePane } from \"./paneResolver.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"plot called outside an active script step\";\n\nfunction isSeriesNumber(v: unknown): v is Series<number> {\n return typeof v === \"object\" && v !== null && \"current\" in v;\n}\n\nfunction isNumberOrSeries(v: unknown): v is number | Series<number> {\n return typeof v === \"number\" || isSeriesNumber(v);\n}\n\nfunction resolveValue(value: number | Series<number>): number | null {\n const resolved = typeof value === \"number\" ? value : value.current;\n return Number.isFinite(resolved) ? resolved : null;\n}\n\nfunction buildStyle(opts: PlotOpts): PlotStyle {\n const style = opts.style;\n if (style === undefined) {\n return {\n kind: \"line\",\n lineWidth: opts.lineWidth ?? 1,\n lineStyle: opts.lineStyle ?? \"solid\",\n };\n }\n switch (style.kind) {\n case \"histogram\":\n return { kind: \"histogram\", baseline: style.baseline ?? 0 };\n case \"marker\":\n return { kind: \"marker\", shape: style.shape, size: style.size };\n case \"shape\":\n return {\n kind: \"shape\",\n shape: style.shape,\n size: style.size,\n ...(style.location === undefined ? {} : { location: style.location }),\n };\n case \"character\":\n return {\n kind: \"character\",\n char: style.char,\n size: style.size,\n ...(style.location === undefined ? {} : { location: style.location }),\n };\n case \"arrow\":\n return { kind: \"arrow\", direction: style.direction, size: style.size };\n case \"candle-override\":\n return {\n kind: \"candle-override\",\n bull: style.bull,\n bear: style.bear,\n ...(style.doji === undefined ? {} : { doji: style.doji }),\n };\n case \"bar-override\":\n return { kind: \"bar-override\", color: style.color };\n case \"bg-color\":\n return {\n kind: \"bg-color\",\n color: style.color,\n ...(style.transp === undefined ? {} : { transp: style.transp }),\n };\n case \"bar-color\":\n return { kind: \"bar-color\", color: style.color };\n case \"horizontal-histogram\":\n return { kind: \"horizontal-histogram\", buckets: style.buckets };\n case \"line\":\n case \"step-line\":\n case \"horizontal-line\":\n return {\n kind: style.kind,\n lineWidth: opts.lineWidth ?? 1,\n lineStyle: opts.lineStyle ?? \"solid\",\n };\n }\n}\n\nfunction plotImpl(\n ctx: RuntimeContext,\n slotId: string,\n value: number | Series<number>,\n opts: PlotOpts,\n): void {\n const style: PlotStyle = buildStyle(opts);\n\n if (!ctx.capabilities.plots.has(style.kind)) {\n pushDiagnostic(ctx.emissions, {\n kind: \"diagnostic\",\n severity: \"warning\",\n code: \"unsupported-plot-kind\",\n message: `Adapter cannot render plot kind \"${style.kind}\".`,\n slotId,\n bar: ctx.barIndex(),\n });\n return;\n }\n\n const pane = resolvePane(opts.pane, ctx, slotId);\n\n // A `ta.*` series carries its declared `offset` (ALMA: `barShift`) as a\n // presentation x-shift recorded on the series view; thread it onto the\n // emission. A plain numeric value or an untagged series omits `xShift`,\n // keeping the no-offset wire byte-identical to the pre-feature baseline.\n const xShift = typeof value === \"number\" ? 0 : seriesOffsetOf(value);\n\n // `z` is a direct plot-call option (a render-order key), unlike\n // `xShift` (derived from the series view). Normalize undefined → `0`\n // and append it with the same omit-when-`0` conditional spread so a\n // no-`z` plot stays byte-identical to the pre-feature baseline.\n const z = opts.z ?? 0;\n\n const emission: PlotEmission = {\n kind: \"plot\",\n slotId,\n title: opts.title ?? \"\",\n style,\n bar: ctx.barIndex(),\n time: ctx.stream.bar.time,\n value: resolveValue(value),\n color: opts.color ?? null,\n meta: {},\n pane,\n ...(xShift === 0 ? {} : { xShift }),\n ...(z === 0 ? {} : { z }),\n };\n\n pushPlot(ctx.emissions, applyPlotOverride(emission, ctx.plotOverrides[slotId]));\n}\n\n/**\n * Emit a plot line for the current bar (script-facing overload).\n *\n * The runtime export is dual-signature: scripts call `plot(value, opts?)`\n * (the surface declared on `@invinite-org/chartlang-core`'s\n * `ComputeContext`), and Task 2's compiler transformer rewrites every\n * callsite to inject the compiler-issued slot id as the leading\n * argument — see the sibling `plot(slotId, value, opts?)` overload.\n * A direct invocation without a slot id (i.e. outside a compiled\n * bundle) throws the sentinel error.\n *\n * Plot kind is always `\"line\"` in Phase 1; `\"horizontal-line\"` ships\n * via the sibling {@link hline} primitive. Phase 2+ extends the `kind`\n * variants additively.\n *\n * When the plotted value is a `ta.*` series declared with an `offset`\n * (or ALMA's `barShift`), that signed bar count rides the emission as\n * `PlotEmission.xShift` (presentation-only — `+n` renders the series `n`\n * bars right, `−n` `n` bars left); the emitted `value` itself is\n * unshifted, so alerts and `state.*` see the value computed at the\n * current bar.\n *\n * @since 0.1\n * @example\n * import { defineIndicator, ta, plot } from \"@invinite-org/chartlang-core\";\n * export default defineIndicator({\n * name: \"EMA(20)\",\n * apiVersion: 1,\n * compute({ bar, ta, plot }) {\n * plot(ta.ema(bar.close, 20), { color: \"#26a69a\", title: \"EMA\" });\n * },\n * });\n */\nexport function plot(value: number | Series<number>, opts?: PlotOpts): void;\n/**\n * Emit a plot line for the current bar (compiler-injected overload).\n *\n * Task 2's callsite-id transformer rewrites every script-side\n * `plot(value, opts?)` into `plot(slotId, value, opts?)`. The runtime\n * branches on `typeof arg1 === \"string\"` so the compiler-emitted\n * bundle dispatches here directly.\n *\n * @since 0.1\n * @example\n * // Internal — the compiler rewrites every script callsite, e.g.\n * // `plot(close)` becomes `plot(\"demo.chart.ts:5:13#0\", close)`.\n * // const fn: typeof plot = plot;\n * // void fn;\n */\nexport function plot(slotId: string, value: number | Series<number>, opts?: PlotOpts): void;\n/**\n * Implementation signature for {@link plot}. Branches on\n * `typeof arg1 === \"string\"` to dispatch the script-facing vs\n * compiler-injected overload.\n *\n * @since 0.1\n * @example\n * // const fn: typeof plot = plot;\n * // void fn;\n */\nexport function plot(\n arg1: string | number | Series<number>,\n arg2?: number | Series<number> | PlotOpts,\n arg3?: PlotOpts,\n): void {\n if (typeof arg1 !== \"string\") {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (!ctx) throw new Error(OUTSIDE_CTX_MESSAGE);\n if (!isNumberOrSeries(arg2)) {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n plotImpl(ctx, arg1, arg2, arg3 ?? {});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispose.d.ts","sourceRoot":"","sources":["../../src/execution/dispose.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"dispose.d.ts","sourceRoot":"","sources":["../../src/execution/dispose.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAuDhD"}
|
|
@@ -47,10 +47,26 @@ export function dispose(state) {
|
|
|
47
47
|
state.runtimeContext.drawingSlots.clear();
|
|
48
48
|
state.runtimeContext.drawingSubIdCounters.clear();
|
|
49
49
|
state.runtimeContext.stateSlots.clear();
|
|
50
|
+
state.runtimeContext.seriesSlots.clear();
|
|
50
51
|
state.runtimeContext.secondaryStreams.clear();
|
|
51
52
|
state.runtimeContext.requestSecurityBars.clear();
|
|
52
53
|
state.runtimeContext.requestSecurityAlignments.clear();
|
|
53
54
|
state.runtimeContext.requestSecurityAscendingBars.clear();
|
|
55
|
+
state.runtimeContext.requestSecurityExprSeries?.clear();
|
|
56
|
+
const exprRunners = state.runtimeContext.securityExprRunners;
|
|
57
|
+
if (exprRunners !== undefined) {
|
|
58
|
+
for (const runner of exprRunners.values()) {
|
|
59
|
+
for (const buf of Object.values(runner.foldStream.ohlcv)) {
|
|
60
|
+
buf.reset();
|
|
61
|
+
}
|
|
62
|
+
runner.foldStream.taSlots.clear();
|
|
63
|
+
runner.output.reset();
|
|
64
|
+
}
|
|
65
|
+
// Drops every runner reference; the per-interval index holds the same
|
|
66
|
+
// (now-reset) objects, so clearing `bySlot` is the authoritative
|
|
67
|
+
// teardown. The whole `RuntimeContext` is discarded after dispose.
|
|
68
|
+
exprRunners.clear();
|
|
69
|
+
}
|
|
54
70
|
state.runtimeContext.requestLowerTfViews.clear();
|
|
55
71
|
state.runtimeContext.diagnosedRequestKeys.clear();
|
|
56
72
|
state.runtimeContext.diagnosedInputKeys.clear();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispose.js","sourceRoot":"","sources":["../../src/execution/dispose.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAC,KAAkB;IACtC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;IAChC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,GAAG,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;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,cAAc,CAAC,qBAAqB,CAAC;IAC5D,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC;IACvB,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;AACvB,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 { RunnerState } from \"../createScriptRunner.js\";\nimport { flushStateSlots } from \"../state/index.js\";\n\n/**\n * Tear down the runner's buffers and state. After `dispose`:\n *\n * - Every OHLCV ring buffer's `length` is 0 (via `RingBufferLike.reset`).\n * - The `taSlots` map is empty (Task 7 primitives lose their hidden\n * state).\n * - Runtime `state.*` slots are flushed into `StateStore`, then the\n * runner-local slot map is cleared. The backing `StateStore` remains\n * host-owned so warm restart can restore the snapshot.\n * - The four emission arrays are reset to empty (`drain()` after\n * `dispose` returns empty arrays).\n *\n * `state.barIndex` is NOT reset — `dispose` is one-shot. Re-use after\n * `dispose` is not supported and not tested.\n *\n * @since 0.1\n * @example\n * // import { dispose } from \"@invinite-org/chartlang-runtime\";\n * // dispose(state);\n */\nexport function dispose(state: RunnerState): void {\n for (const dep of state.depRunners) {\n dispose(dep.state);\n }\n for (const sibling of state.siblingRunners) {\n dispose(sibling.state);\n }\n state.depOutputStore?.dispose();\n flushStateSlots(state.runtimeContext);\n for (const buf of Object.values(state.mainStream.ohlcv)) {\n buf.reset();\n }\n for (const stream of state.runtimeContext.secondaryStreams.values()) {\n for (const buf of Object.values(stream.ohlcv)) {\n buf.reset();\n }\n stream.taSlots.clear();\n }\n state.mainStream.taSlots.clear();\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.diagnostics = [];\n state.runtimeContext.drawingSlots.clear();\n state.runtimeContext.drawingSubIdCounters.clear();\n state.runtimeContext.stateSlots.clear();\n state.runtimeContext.secondaryStreams.clear();\n state.runtimeContext.requestSecurityBars.clear();\n state.runtimeContext.requestSecurityAlignments.clear();\n state.runtimeContext.requestSecurityAscendingBars.clear();\n state.runtimeContext.requestLowerTfViews.clear();\n state.runtimeContext.diagnosedRequestKeys.clear();\n state.runtimeContext.diagnosedInputKeys.clear();\n const counters = state.runtimeContext.drawingBucketCounters;\n counters.lines = 0;\n counters.labels = 0;\n counters.boxes = 0;\n counters.polylines = 0;\n counters.other = 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dispose.js","sourceRoot":"","sources":["../../src/execution/dispose.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAC,KAAkB;IACtC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;IAChC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,GAAG,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;QAClE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;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GAAG,CAAC,KAAK,EAAE,CAAC;YAChB,CAAC;YACD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAClC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;QACD,sEAAsE;QACtE,iEAAiE;QACjE,mEAAmE;QACnE,WAAW,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;IACjD,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;IAClD,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAChD,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC;IAC5D,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC;IACvB,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;AACvB,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 { RunnerState } from \"../createScriptRunner.js\";\nimport { flushStateSlots } from \"../state/index.js\";\n\n/**\n * Tear down the runner's buffers and state. After `dispose`:\n *\n * - Every OHLCV ring buffer's `length` is 0 (via `RingBufferLike.reset`).\n * - The `taSlots` map is empty (Task 7 primitives lose their hidden\n * state).\n * - Runtime `state.*` slots are flushed into `StateStore`, then the\n * runner-local slot map is cleared. The backing `StateStore` remains\n * host-owned so warm restart can restore the snapshot.\n * - The four emission arrays are reset to empty (`drain()` after\n * `dispose` returns empty arrays).\n *\n * `state.barIndex` is NOT reset — `dispose` is one-shot. Re-use after\n * `dispose` is not supported and not tested.\n *\n * @since 0.1\n * @example\n * // import { dispose } from \"@invinite-org/chartlang-runtime\";\n * // dispose(state);\n */\nexport function dispose(state: RunnerState): void {\n for (const dep of state.depRunners) {\n dispose(dep.state);\n }\n for (const sibling of state.siblingRunners) {\n dispose(sibling.state);\n }\n state.depOutputStore?.dispose();\n flushStateSlots(state.runtimeContext);\n for (const buf of Object.values(state.mainStream.ohlcv)) {\n buf.reset();\n }\n for (const stream of state.runtimeContext.secondaryStreams.values()) {\n for (const buf of Object.values(stream.ohlcv)) {\n buf.reset();\n }\n stream.taSlots.clear();\n }\n state.mainStream.taSlots.clear();\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.diagnostics = [];\n state.runtimeContext.drawingSlots.clear();\n state.runtimeContext.drawingSubIdCounters.clear();\n state.runtimeContext.stateSlots.clear();\n state.runtimeContext.seriesSlots.clear();\n state.runtimeContext.secondaryStreams.clear();\n state.runtimeContext.requestSecurityBars.clear();\n state.runtimeContext.requestSecurityAlignments.clear();\n state.runtimeContext.requestSecurityAscendingBars.clear();\n state.runtimeContext.requestSecurityExprSeries?.clear();\n const exprRunners = state.runtimeContext.securityExprRunners;\n if (exprRunners !== undefined) {\n for (const runner of exprRunners.values()) {\n for (const buf of Object.values(runner.foldStream.ohlcv)) {\n buf.reset();\n }\n runner.foldStream.taSlots.clear();\n runner.output.reset();\n }\n // Drops every runner reference; the per-interval index holds the same\n // (now-reset) objects, so clearing `bySlot` is the authoritative\n // teardown. The whole `RuntimeContext` is discarded after dispose.\n exprRunners.clear();\n }\n state.runtimeContext.requestLowerTfViews.clear();\n state.runtimeContext.diagnosedRequestKeys.clear();\n state.runtimeContext.diagnosedInputKeys.clear();\n const counters = state.runtimeContext.drawingBucketCounters;\n counters.lines = 0;\n counters.labels = 0;\n counters.boxes = 0;\n counters.polylines = 0;\n counters.other = 0;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runComputeStep.d.ts","sourceRoot":"","sources":["../../src/execution/runComputeStep.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"runComputeStep.d.ts","sourceRoot":"","sources":["../../src/execution/runComputeStep.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAY5D,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,mBAAmB,CAAC;AAExE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qBAAqB,GAC3B,QAAQ,CAAC;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,GACxB,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE3D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC5B,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAc1D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA8C7F"}
|
|
@@ -4,7 +4,7 @@ import { buildComputeContext } from "../buildComputeContext.js";
|
|
|
4
4
|
import { resetSubIdCounters } from "../emit/draw/index.js";
|
|
5
5
|
import { isRuntimeErrorHalt, pushDiagnostic } from "../emit/index.js";
|
|
6
6
|
import { ACTIVE_RUNTIME_CONTEXT } from "../runtimeContext.js";
|
|
7
|
-
import { commitStateSlots, flushStateSlots, resetTentativeStateSlots } from "../state/index.js";
|
|
7
|
+
import { advanceSeriesSlots, commitSeriesSlots, commitStateSlots, flushStateSlots, resetSeriesHeads, resetTentativeStateSlots, } from "../state/index.js";
|
|
8
8
|
import { refreshRuntimeViews } from "../views/index.js";
|
|
9
9
|
/**
|
|
10
10
|
* Reset the per-bar emission queues on a runner before its compute
|
|
@@ -28,6 +28,7 @@ export function resetBarEmissions(state) {
|
|
|
28
28
|
state.emissions.toBar = state.barIndex;
|
|
29
29
|
state.runtimeContext.requestSecurityAlignments.clear();
|
|
30
30
|
state.runtimeContext.requestSecurityAscendingBars.clear();
|
|
31
|
+
state.runtimeContext.requestSecurityExprSeries?.clear();
|
|
31
32
|
state.runtimeContext.logBudget = 0;
|
|
32
33
|
state.runtimeContext.logBudgetExceededDiagnosed = false;
|
|
33
34
|
}
|
|
@@ -58,6 +59,13 @@ export async function runComputeBody(args) {
|
|
|
58
59
|
resetSubIdCounters(state.runtimeContext);
|
|
59
60
|
if (isTick) {
|
|
60
61
|
resetTentativeStateSlots(state.runtimeContext);
|
|
62
|
+
resetSeriesHeads(state.runtimeContext);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Advance every already-allocated series ring with a fresh NaN
|
|
66
|
+
// head BEFORE compute, so a slot first allocated mid-compute (it
|
|
67
|
+
// already holds its seeded head) is not double-advanced.
|
|
68
|
+
advanceSeriesSlots(state.runtimeContext);
|
|
61
69
|
}
|
|
62
70
|
refreshRuntimeViews(state, eventKind);
|
|
63
71
|
try {
|
|
@@ -65,6 +73,7 @@ export async function runComputeBody(args) {
|
|
|
65
73
|
if (!isTick) {
|
|
66
74
|
commitStateSlots(state.runtimeContext);
|
|
67
75
|
flushStateSlots(state.runtimeContext);
|
|
76
|
+
commitSeriesSlots(state.runtimeContext);
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runComputeStep.js","sourceRoot":"","sources":["../../src/execution/runComputeStep.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D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CAAC;gBACV,gBAAgB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;gBACvC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;gBACtC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAC5C,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC;gBAAE,MAAM,GAAG,CAAC;YACxC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE,CAAC;YAC3B,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAG,EAAE,CAAC;YAC9B,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC;YAC5B,KAAK,CAAC,SAAS,CAAC,eAAe,GAAG,EAAE,CAAC;YACrC,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC;YAC1B,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE;gBAC5B,IAAI,EAAE,YAAY;gBAClB,QAAQ,EAAE,OAAO;gBACjB,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,MAAM,EAAE,IAAI;gBACZ,GAAG,EAAE,KAAK,CAAC,QAAQ;aACtB,CAAC,CAAC;YACH,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QACrD,CAAC;IACL,CAAC;YAAS,CAAC;QACP,IAAI,MAAM;YAAE,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,KAAK,CAAC;QAChD,sBAAsB,CAAC,OAAO,GAAG,IAAI,CAAC;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,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 { buildComputeContext } from \"../buildComputeContext.js\";\nimport type { RunnerState } from \"../createScriptRunner.js\";\nimport { resetSubIdCounters } from \"../emit/draw/index.js\";\nimport { isRuntimeErrorHalt, pushDiagnostic } from \"../emit/index.js\";\nimport { ACTIVE_RUNTIME_CONTEXT } from \"../runtimeContext.js\";\nimport {\n advanceSeriesSlots,\n commitSeriesSlots,\n commitStateSlots,\n flushStateSlots,\n resetSeriesHeads,\n resetTentativeStateSlots,\n} from \"../state/index.js\";\nimport { type EventKind, refreshRuntimeViews } from \"../views/index.js\";\n\n/**\n * Outcome of a single compute step. `ok` means the script's `compute`\n * returned normally; `halt` means `runtime.error(...)` was thrown (the\n * compute body deliberately aborted the bar). Non-halt throws propagate\n * out of {@link runComputeStep} unchanged.\n *\n * @since 0.7\n * @stable\n * @example\n * const r: RunComputeStepOutcome = { kind: \"ok\" };\n * void r;\n */\nexport type RunComputeStepOutcome =\n | Readonly<{ kind: \"ok\" }>\n | Readonly<{ kind: \"halt\"; readonly message: string }>;\n\n/**\n * Configuration for {@link runComputeStep}. `eventKind` reaches the\n * runtime views so `barstate.*` picks up the right snapshot; `isTick`\n * discriminates the close-vs-tick state-slot lifecycle.\n *\n * @since 0.7\n * @stable\n * @example\n * const args = { state, eventKind: \"close\" as const, isTick: false };\n * void args;\n */\nexport type RunComputeStepArgs = Readonly<{\n readonly state: RunnerState;\n readonly eventKind: EventKind;\n readonly isTick: boolean;\n}>;\n\n/**\n * Reset the per-bar emission queues on a runner before its compute\n * runs. Exported for the dep / sibling step driver — single-script\n * callers go through {@link runComputeStep} which calls this\n * internally.\n *\n * @since 0.7\n * @stable\n * @example\n * // resetBarEmissions(state);\n */\nexport function resetBarEmissions(state: RunnerState): void {\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.alertConditions = [];\n state.emissions.logs = [];\n state.emissions.diagnostics = [];\n state.emissions.fromBar = state.barIndex;\n state.emissions.toBar = state.barIndex;\n state.runtimeContext.requestSecurityAlignments.clear();\n state.runtimeContext.requestSecurityAscendingBars.clear();\n state.runtimeContext.requestSecurityExprSeries?.clear();\n state.runtimeContext.logBudget = 0;\n state.runtimeContext.logBudgetExceededDiagnosed = false;\n}\n\n/**\n * Run the inner compute body of `state.compute` — set\n * `ACTIVE_RUNTIME_CONTEXT`, reset sub-id counters, optionally reset\n * tentative state slots, refresh views, invoke `compute`, commit /\n * flush state slots on close. Does NOT reset the per-bar emission\n * queues; callers do that exactly once via {@link resetBarEmissions}.\n *\n * `runtime.error(...)` halts clear the runner's visual emissions and\n * push a `runtime-error-thrown` diagnostic, matching the Phase-1\n * single-script behaviour byte-for-byte. Non-halt throws propagate\n * out unchanged.\n *\n * @since 0.7\n * @stable\n * @example\n * // const outcome = await runComputeBody({ state, eventKind: \"close\", isTick: false });\n * // void outcome;\n */\nexport async function runComputeBody(args: RunComputeStepArgs): Promise<RunComputeStepOutcome> {\n const { state, eventKind, isTick } = args;\n ACTIVE_RUNTIME_CONTEXT.current = state.runtimeContext;\n state.runtimeContext.isTick = isTick;\n let outcome: RunComputeStepOutcome = { kind: \"ok\" };\n try {\n resetSubIdCounters(state.runtimeContext);\n if (isTick) {\n resetTentativeStateSlots(state.runtimeContext);\n resetSeriesHeads(state.runtimeContext);\n } else {\n // Advance every already-allocated series ring with a fresh NaN\n // head BEFORE compute, so a slot first allocated mid-compute (it\n // already holds its seeded head) is not double-advanced.\n advanceSeriesSlots(state.runtimeContext);\n }\n refreshRuntimeViews(state, eventKind);\n try {\n await Promise.resolve(state.compute(buildComputeContext(state)));\n if (!isTick) {\n commitStateSlots(state.runtimeContext);\n flushStateSlots(state.runtimeContext);\n commitSeriesSlots(state.runtimeContext);\n }\n } catch (err) {\n if (!isRuntimeErrorHalt(err)) throw err;\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.alertConditions = [];\n state.emissions.logs = [];\n pushDiagnostic(state.emissions, {\n kind: \"diagnostic\",\n severity: \"error\",\n code: \"runtime-error-thrown\",\n message: err.message,\n slotId: null,\n bar: state.barIndex,\n });\n outcome = { kind: \"halt\", message: err.message };\n }\n } finally {\n if (isTick) state.runtimeContext.isTick = false;\n ACTIVE_RUNTIME_CONTEXT.current = null;\n }\n return outcome;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Float64RingBuffer, RingBuffer } from "./ringBuffer.js";
|
|
2
2
|
export type { RingBufferLike } from "./ringBuffer.js";
|
|
3
|
-
export { makeSeriesView, makeShiftedSeriesView } from "./seriesView.js";
|
|
3
|
+
export { makeSeriesView, makeShiftedSeriesView, seriesOffsetOf } from "./seriesView.js";
|
|
4
4
|
export type { BarView, OhlcvBuffers, StreamState } from "./streamState.js";
|
|
5
5
|
export { createStreamState } from "./streamState.js";
|
|
6
6
|
export type { StateStore } from "./stateStore.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxF,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EA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T,aAAa,EACb,aAAa,EACb,iBAAiB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,cAAc,GACjB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
3
|
export { Float64RingBuffer, RingBuffer } from "./ringBuffer.js";
|
|
4
|
-
export { makeSeriesView, makeShiftedSeriesView } from "./seriesView.js";
|
|
4
|
+
export { makeSeriesView, makeShiftedSeriesView, seriesOffsetOf } from "./seriesView.js";
|
|
5
5
|
export { createStreamState } from "./streamState.js";
|
|
6
6
|
export { inMemoryStateStore } from "./stateStore.js";
|
|
7
7
|
export { inMemoryPersistentStateStore } from "./persistentStateStore.js";
|
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,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,sEAAsE;AACtE,gEAAgE;AAChE,uDAAuD;AACvD,oEAAoE;AACpE,mEAAmE;AACnE,uEAAuE;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAYhE,OAAO,EACH,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,cAAc,GACjB,MAAM,gBAAgB,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 { Float64RingBuffer, RingBuffer } from \"./ringBuffer.js\";\nexport type { RingBufferLike } from \"./ringBuffer.js\";\nexport { makeSeriesView, makeShiftedSeriesView, seriesOffsetOf } from \"./seriesView.js\";\nexport type { BarView, OhlcvBuffers, StreamState } from \"./streamState.js\";\nexport { createStreamState } from \"./streamState.js\";\nexport type { StateStore } from \"./stateStore.js\";\nexport { inMemoryStateStore } from \"./stateStore.js\";\nexport type { PersistentStateStore } from \"./persistentStateStore.js\";\nexport { inMemoryPersistentStateStore } from \"./persistentStateStore.js\";\nexport { asMutableSlot, buildStateNamespace, StateSlot } from \"./state/index.js\";\nexport { resolveInputs } from \"./inputs/index.js\";\nexport { buildRequestNamespace, makeNanSecurityBar } from \"./request/index.js\";\nexport type { DrawingSlot, MutableRunnerEmissions, RuntimeContext } from \"./runtimeContext.js\";\nexport {\n createRuntimeViews,\n makeBarStateView,\n makeSymInfoView,\n makeTimeframeView,\n} from \"./views/index.js\";\nexport type { AdapterSymInfo, BarStateInputs, EventKind, RuntimeViews } from \"./views/index.js\";\nexport { ACTIVE_RUNTIME_CONTEXT } from \"./runtimeContext.js\";\nexport { createScriptRunner } from \"./createScriptRunner.js\";\nexport type { CreateScriptRunnerArgs, ScriptRunner } from \"./createScriptRunner.js\";\nexport { alert, applyPlotOverride, draw, hline, plot, pushDrawing } from \"./emit/index.js\";\nexport { TA_REGISTRY, ta } from \"./ta/index.js\";\nexport { maRibbonOutputKeys } from \"./ta/index.js\";\nexport type { RuntimeTaNamespace, ScalarOrSeries } from \"./ta/index.js\";\n// Public re-export added in Phase 3 Task 10 so consumer adapters that\n// render `draw.regressionTrend` can compute the OLS fit without\n// duplicating math. The Phase-2 helper signature stays\n// `(source: Float64Array, length: number): LinearRegressionFrame` —\n// pass `length === source.length` for a single-window fit over the\n// bar range; the line value at the last index is the end-of-range fit.\nexport { linearRegression } from \"./ta/lib/linearRegression.js\";\nexport type { LinearRegressionFrame } from \"./ta/lib/linearRegression.js\";\n// Indicator-composition surface (Phase 7).\nexport type {\n CreateDepRunnerArgs,\n DepOutputDeclaration,\n DepOutputStore,\n DepRunner,\n DepRunnerLike,\n SiblingRunner,\n SiblingRunnerLike,\n} from \"./dep/index.js\";\nexport {\n applyDepEmissionPolicy,\n createDepOutputStore,\n createDepRunner,\n createSiblingRunner,\n runDepStep,\n runSiblingStep,\n} from \"./dep/index.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistentStateStore.runtime.d.ts","sourceRoot":"","sources":["../src/persistentStateStore.runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGR,aAAa,EAEhB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"persistentStateStore.runtime.d.ts","sourceRoot":"","sources":["../src/persistentStateStore.runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGR,aAAa,EAEhB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAa3D;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAwD9C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAe9F;AAgGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAuBtF;AA2BD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8B7F;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CACxC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
3
|
import { pushDiagnostic } from "./emit/index.js";
|
|
4
4
|
import { validateSnapshot } from "./persistentStateStore.validate.js";
|
|
5
|
-
import { restoreStateSlots, serialiseStateSlots } from "./state/index.js";
|
|
5
|
+
import { isSeriesSlotSnapshotKey, restoreSeriesSlots, restoreStateSlots, serialiseSeriesSlots, serialiseStateSlots, } from "./state/index.js";
|
|
6
6
|
import { isTaSlotSnapshotKey, restoreTaSlots, serialiseTaSlots } from "./ta/persistence.js";
|
|
7
7
|
/**
|
|
8
8
|
* Default PLAN §6.9 write cadence for persistent snapshots.
|
|
@@ -32,12 +32,16 @@ function captureStreams(state) {
|
|
|
32
32
|
function primarySectionSlots(state) {
|
|
33
33
|
return Object.freeze({
|
|
34
34
|
...serialiseStateSlots(state.runtimeContext),
|
|
35
|
+
...serialiseSeriesSlots(state.runtimeContext),
|
|
35
36
|
...serialiseTaSlots(state.mainStream),
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
function runnerSection(ctx) {
|
|
39
40
|
return Object.freeze({
|
|
40
|
-
slots: Object.freeze({
|
|
41
|
+
slots: Object.freeze({
|
|
42
|
+
...serialiseStateSlots(ctx),
|
|
43
|
+
...serialiseSeriesSlots(ctx),
|
|
44
|
+
}),
|
|
41
45
|
});
|
|
42
46
|
}
|
|
43
47
|
function captureSiblings(state) {
|
|
@@ -101,15 +105,25 @@ function resolveMainStreamSnapshot(snapshot, mainInterval) {
|
|
|
101
105
|
const fallback = firstStreamKey(snapshot);
|
|
102
106
|
return fallback === null ? undefined : snapshot.streams[fallback];
|
|
103
107
|
}
|
|
104
|
-
|
|
108
|
+
// Scalar `state.*` keys only — strip both `ta:` (restored onto the stream)
|
|
109
|
+
// and `:series` (restored into `ctx.seriesSlots`) so the scalar slot store
|
|
110
|
+
// receives neither.
|
|
111
|
+
function scalarStateSlots(slots) {
|
|
105
112
|
const out = {};
|
|
106
113
|
for (const [slotKey, value] of Object.entries(slots)) {
|
|
107
|
-
if (!isTaSlotSnapshotKey(slotKey)) {
|
|
114
|
+
if (!isTaSlotSnapshotKey(slotKey) && !isSeriesSlotSnapshotKey(slotKey)) {
|
|
108
115
|
out[slotKey] = value;
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
118
|
return out;
|
|
112
119
|
}
|
|
120
|
+
// Restore a runner's scalar `state.*` slots and `state.series` slots from
|
|
121
|
+
// one merged `slots` record. Series rings are sized to the runner's current
|
|
122
|
+
// ring capacity (the close buffer's capacity).
|
|
123
|
+
function restoreRunnerSlots(ctx, slots, capacity) {
|
|
124
|
+
restoreStateSlots(ctx, scalarStateSlots(slots));
|
|
125
|
+
restoreSeriesSlots(ctx, slots, capacity);
|
|
126
|
+
}
|
|
113
127
|
function pushMalformedSection(state, message) {
|
|
114
128
|
pushDiagnostic(state.emissions, {
|
|
115
129
|
kind: "diagnostic",
|
|
@@ -128,7 +142,7 @@ function restoreSiblingSections(state, siblings) {
|
|
|
128
142
|
pushMalformedSection(state, `persistent state snapshot referenced unknown sibling "${exportName}"`);
|
|
129
143
|
continue;
|
|
130
144
|
}
|
|
131
|
-
|
|
145
|
+
restoreRunnerSlots(sibling.state.runtimeContext, section.slots, state.mainStream.ohlcv.close.capacity);
|
|
132
146
|
}
|
|
133
147
|
}
|
|
134
148
|
function restoreDependencySections(state, dependencies) {
|
|
@@ -139,7 +153,7 @@ function restoreDependencySections(state, dependencies) {
|
|
|
139
153
|
pushMalformedSection(state, `persistent state snapshot referenced unknown dependency "${localId}"`);
|
|
140
154
|
continue;
|
|
141
155
|
}
|
|
142
|
-
|
|
156
|
+
restoreRunnerSlots(dep.state.runtimeContext, section.slots, state.mainStream.ohlcv.close.capacity);
|
|
143
157
|
}
|
|
144
158
|
}
|
|
145
159
|
/**
|
|
@@ -175,7 +189,7 @@ export function restoreStateSnapshot(state, snapshot) {
|
|
|
175
189
|
}
|
|
176
190
|
const primarySlots = primarySlotsOf(snapshot);
|
|
177
191
|
restoreTaSlots(state.mainStream, primarySlots);
|
|
178
|
-
|
|
192
|
+
restoreRunnerSlots(state.runtimeContext, primarySlots, state.mainStream.ohlcv.close.capacity);
|
|
179
193
|
if (snapshot.siblings !== undefined) {
|
|
180
194
|
restoreSiblingSections(state, snapshot.siblings);
|
|
181
195
|
}
|