@invinite-org/chartlang-runtime 1.2.0 → 1.3.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 +71 -0
- package/dist/buildComputeContext.d.ts.map +1 -1
- package/dist/buildComputeContext.js +6 -1
- package/dist/buildComputeContext.js.map +1 -1
- package/dist/createScriptRunner.d.ts.map +1 -1
- package/dist/createScriptRunner.js +37 -7
- package/dist/createScriptRunner.js.map +1 -1
- package/dist/dep/DepRunner.d.ts +7 -0
- package/dist/dep/DepRunner.d.ts.map +1 -1
- package/dist/dep/DepRunner.js +3 -0
- package/dist/dep/DepRunner.js.map +1 -1
- package/dist/emit/barcolor.d.ts +44 -0
- package/dist/emit/barcolor.d.ts.map +1 -0
- package/dist/emit/barcolor.js +40 -0
- package/dist/emit/barcolor.js.map +1 -0
- package/dist/emit/bgcolor.d.ts +44 -0
- package/dist/emit/bgcolor.d.ts.map +1 -0
- package/dist/emit/bgcolor.js +45 -0
- package/dist/emit/bgcolor.js.map +1 -0
- package/dist/emit/index.d.ts +2 -0
- package/dist/emit/index.d.ts.map +1 -1
- package/dist/emit/index.js +2 -0
- package/dist/emit/index.js.map +1 -1
- package/dist/emit/plot.d.ts +23 -1
- package/dist/emit/plot.d.ts.map +1 -1
- package/dist/emit/plot.js +32 -1
- package/dist/emit/plot.js.map +1 -1
- package/dist/execution/dispose.d.ts.map +1 -1
- package/dist/execution/dispose.js +3 -1
- package/dist/execution/dispose.js.map +1 -1
- package/dist/execution/runComputeStep.d.ts.map +1 -1
- package/dist/execution/runComputeStep.js +3 -1
- package/dist/execution/runComputeStep.js.map +1 -1
- package/dist/inputs/resolveInputs.js +1 -0
- package/dist/inputs/resolveInputs.js.map +1 -1
- package/dist/persistentStateStore.runtime.d.ts.map +1 -1
- package/dist/persistentStateStore.runtime.js +10 -5
- package/dist/persistentStateStore.runtime.js.map +1 -1
- package/dist/primitives.d.ts +1 -1
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +7 -1
- package/dist/primitives.js.map +1 -1
- package/dist/request/lowerTf.d.ts.map +1 -1
- package/dist/request/lowerTf.js +6 -0
- package/dist/request/lowerTf.js.map +1 -1
- package/dist/request/requestNamespace.d.ts.map +1 -1
- package/dist/request/requestNamespace.js +17 -3
- package/dist/request/requestNamespace.js.map +1 -1
- package/dist/request/security.d.ts +23 -6
- package/dist/request/security.d.ts.map +1 -1
- package/dist/request/security.js +64 -29
- package/dist/request/security.js.map +1 -1
- package/dist/request/securityExprRunner.d.ts +12 -8
- package/dist/request/securityExprRunner.d.ts.map +1 -1
- package/dist/request/securityExprRunner.js +32 -14
- package/dist/request/securityExprRunner.js.map +1 -1
- package/dist/ringBuffer.d.ts +19 -0
- package/dist/ringBuffer.d.ts.map +1 -1
- package/dist/ringBuffer.js +23 -0
- package/dist/ringBuffer.js.map +1 -1
- package/dist/runtimeContext.d.ts +49 -12
- package/dist/runtimeContext.d.ts.map +1 -1
- package/dist/runtimeContext.js.map +1 -1
- package/dist/state/arrayPersistence.d.ts +48 -0
- package/dist/state/arrayPersistence.d.ts.map +1 -0
- package/dist/state/arrayPersistence.js +88 -0
- package/dist/state/arrayPersistence.js.map +1 -0
- package/dist/state/arrayStateSlot.d.ts +78 -0
- package/dist/state/arrayStateSlot.d.ts.map +1 -0
- package/dist/state/arrayStateSlot.js +116 -0
- package/dist/state/arrayStateSlot.js.map +1 -0
- package/dist/state/index.d.ts +3 -1
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +3 -1
- package/dist/state/index.js.map +1 -1
- package/dist/state/lifecycle.d.ts +28 -0
- package/dist/state/lifecycle.d.ts.map +1 -1
- package/dist/state/lifecycle.js +36 -0
- package/dist/state/lifecycle.js.map +1 -1
- package/dist/state/stateNamespace.d.ts.map +1 -1
- package/dist/state/stateNamespace.js +27 -0
- package/dist/state/stateNamespace.js.map +1 -1
- package/dist/ta/sessionVolumeProfile.d.ts.map +1 -1
- package/dist/ta/sessionVolumeProfile.js +1 -17
- package/dist/ta/sessionVolumeProfile.js.map +1 -1
- package/dist/time-accessors/civil.d.ts +73 -0
- package/dist/time-accessors/civil.d.ts.map +1 -0
- package/dist/time-accessors/civil.js +105 -0
- package/dist/time-accessors/civil.js.map +1 -0
- package/dist/time-accessors/index.d.ts +8 -0
- package/dist/time-accessors/index.d.ts.map +1 -0
- package/dist/time-accessors/index.js +9 -0
- package/dist/time-accessors/index.js.map +1 -0
- package/dist/time-accessors/sessionAccessors.d.ts +50 -0
- package/dist/time-accessors/sessionAccessors.d.ts.map +1 -0
- package/dist/time-accessors/sessionAccessors.js +79 -0
- package/dist/time-accessors/sessionAccessors.js.map +1 -0
- package/dist/time-accessors/sessionWindow.d.ts +17 -0
- package/dist/time-accessors/sessionWindow.d.ts.map +1 -0
- package/dist/time-accessors/sessionWindow.js +41 -0
- package/dist/time-accessors/sessionWindow.js.map +1 -0
- package/dist/time-accessors/timeAccessors.d.ts +54 -0
- package/dist/time-accessors/timeAccessors.d.ts.map +1 -0
- package/dist/time-accessors/timeAccessors.js +132 -0
- package/dist/time-accessors/timeAccessors.js.map +1 -0
- package/dist/time-accessors/tzDiagnostic.d.ts +17 -0
- package/dist/time-accessors/tzDiagnostic.d.ts.map +1 -0
- package/dist/time-accessors/tzDiagnostic.js +34 -0
- package/dist/time-accessors/tzDiagnostic.js.map +1 -0
- package/dist/time-accessors/tzOffset.d.ts +31 -0
- package/dist/time-accessors/tzOffset.d.ts.map +1 -0
- package/dist/time-accessors/tzOffset.js +67 -0
- package/dist/time-accessors/tzOffset.js.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeContext.d.ts","sourceRoot":"","sources":["../src/runtimeContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACpB,MAAM,qCAAqC,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MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAClD;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;;OAMG;IACH,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IACtD;;;OAGG;IACH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sBAAsB,EAAE;IAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAAA;CAEpE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeContext.js","sourceRoot":"","sources":["../src/runtimeContext.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AA2V/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAuC;IACtE,OAAO,EAAE,IAAI;CAChB,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 AlertConditionEmission,\n AlertEmission,\n Capabilities,\n DrawingEmission,\n LogEmission,\n PlotEmission,\n PlotOverride,\n RuntimeDiagnostic,\n} from \"@invinite-org/chartlang-adapter-kit\";\nimport type {\n AlertConditionDefinition,\n Bar,\n DrawingBucket,\n DrawingCounts,\n DrawingKind,\n DrawingState,\n SecurityBar,\n Series,\n} from \"@invinite-org/chartlang-core\";\n\nimport type { DepOutputStore } from \"./dep/DepOutputStore.js\";\nimport type { PersistentStateStore } from \"./persistentStateStore.js\";\nimport type { SecurityExprRunner } from \"./request/securityExprRunner.js\";\nimport type { SeriesSlot } from \"./state/seriesSlot.js\";\nimport type { StateSlot } from \"./state/stateSlot.js\";\nimport type { StateStore } from \"./stateStore.js\";\nimport type { StreamState } from \"./streamState.js\";\nimport type { RuntimeViews } from \"./views/index.js\";\n\n/**\n * Per-handle drawing slot the runtime persists across bars. The key is\n * `slotId#subId` (compiler-injected callsite id + per-bar sub-id from\n * {@link nextSubId}). `state` holds the last full {@link DrawingState}\n * emitted for the handle; subsequent `update(patch)` calls merge into\n * it and re-emit the full payload. `removed: true`\n * is sticky — further `update` / `remove` on the handle no-op.\n *\n * `z` is the presentation-only render-order key `handle.ts`'s `splitZ`\n * lifted out of the drawing's `state.style` (default `0`). It is stored\n * **beside** `state` — never inside `state` / `state.style` — because\n * the wire carries it as the top-level {@link DrawingEmission.z} field,\n * not as part of {@link DrawingState}. It persists across bars; an\n * `update` that does not re-specify a non-zero `z` retains it, a\n * re-specified non-zero `z` overrides, and a cross-bar re-entry\n * re-specifies it from the new call.\n *\n * @since 0.3\n * @stable\n * @example\n * // const slot: DrawingSlot = {\n * // handleId: \"x.chart.ts:1:1#0\",\n * // kind: \"line\",\n * // state: { kind: \"line\", anchors: [...], style: {} },\n * // z: 0,\n * // removed: false,\n * // };\n */\nexport type DrawingSlot = {\n readonly handleId: string;\n readonly kind: DrawingKind;\n state: DrawingState;\n z: number;\n removed: boolean;\n};\n\n/**\n * Mutable counterpart of `RunnerEmissions` (from adapter-kit) that the\n * runtime accumulates into per bar. Task 6's execution loop pushes\n * here during `compute`; `drain()` snapshots into the readonly\n * `RunnerEmissions` shape the adapter receives.\n *\n * @since 0.1\n * @example\n * // const emissions: MutableRunnerEmissions = {\n * // plots: [],\n * // drawings: [],\n * // alerts: [],\n * // diagnostics: [],\n * // fromBar: 0,\n * // toBar: 0,\n * // };\n */\nexport type MutableRunnerEmissions = {\n plots: PlotEmission[];\n drawings: DrawingEmission[];\n alerts: AlertEmission[];\n alertConditions?: AlertConditionEmission[];\n logs: LogEmission[];\n diagnostics: RuntimeDiagnostic[];\n fromBar: number;\n toBar: number;\n};\n\n/**\n * The contract Task 6's execution loop hands to stateful primitives\n * (Tasks 7-8) inside a single `compute` step. Tasks 7-8 read this\n * through {@link ACTIVE_RUNTIME_CONTEXT} — the runtime sets `.current`\n * around `compute` in a `try/finally`, so primitives can find their\n * series, slot store, capability bag, emission destination, and bar\n * index without an explicit argument.\n *\n * `isTick` discriminates `onBarTick` calls (head-replace mode) from\n * `onBarClose` / `onHistory` (append mode). Stateful primitives in\n * Task 7 use it to swap append vs replace-head behaviour.\n *\n * `stateSlots` stores Phase-4 `state.*` / `state.tick.*` slots keyed by\n * `${slotId}:state`; values flush into `stateStore` at close/dispose.\n *\n * `views` is a mutable container whose fields are replaced with fresh frozen\n * `barstate.*`, `syminfo.*`, and `timeframe.*` snapshots as the runner\n * advances.\n *\n * `resolvedInputs` is the frozen bag handed to `compute({ inputs })`,\n * resolved once at mount from manifest defaults plus adapter overrides.\n *\n * @since 0.1\n * @example\n * // const ctx: RuntimeContext = {\n * // stream, stateStore, capabilities, emissions,\n * // barIndex: () => 0,\n * // isTick: false,\n * // };\n */\nexport type RuntimeContext = {\n readonly stream: StreamState;\n readonly stateStore: StateStore;\n readonly persistentStateStore?: PersistentStateStore;\n lastPersistTime: number;\n readonly capabilities: Capabilities;\n readonly emissions: MutableRunnerEmissions;\n readonly barIndex: () => number;\n isTick: boolean;\n /**\n * Per-handle drawing slot store keyed by `slotId#subId`. Allocated\n * on first `op: \"create\"`; mutated by `update(patch)` to merge the\n * patch into the slot's `state`; flagged `removed: true` on\n * `remove()`. Cleared on `dispose`. Persists across bars.\n * @since 0.3\n */\n readonly drawingSlots: Map<string, DrawingSlot>;\n /**\n * Per-callsite per-bar sub-id counter. Each `draw.<kind>(...)` call\n * inside a bar reads `nextSubId(ctx, slotId)`; the counter resets\n * at the top of each `onBarClose` / `onBarTick` so iteration `i` at\n * the same callsite yields the same `slotId#i` across bars.\n * Cleared on `dispose`. @since 0.3\n */\n readonly drawingSubIdCounters: Map<string, number>;\n /**\n * Live per-bucket allocation tally for the current script. Each\n * `op: \"create\"` increments the relevant bucket; each\n * `op: \"remove\"` decrements (clamped at 0). `op: \"update\"` is\n * free. `pushDrawing` drops the emission with\n * `drawing-budget-exceeded` once a bucket hits its effective\n * budget (min of adapter cap + `scriptMaxDrawings`). Reset to\n * zero on `dispose`. @since 0.3\n */\n readonly drawingBucketCounters: Record<DrawingBucket, number>;\n /**\n * The script's per-bucket cap from `defineIndicator({ maxDrawings:\n * ... })` / `defineDrawing({ maxDrawings: ... })`. `null` when\n * omitted — `pushDrawing` then enforces the adapter cap alone.\n * Effective budget is `min(scriptMaxDrawings[b],\n * capabilities.maxDrawingsPerScript[b])`. @since 0.3\n */\n readonly scriptMaxDrawings: DrawingCounts | null;\n /**\n * Runtime `state.*` / `state.tick.*` slot store keyed by\n * `${slotIdPrefix ?? \"\"}${slotId}:state`. Non-tick slots keep\n * committed/tentative values; tick slots commit writes immediately.\n * Cleared on `dispose` after flushing snapshots to `stateStore`.\n * @since 0.4\n */\n readonly stateSlots: Map<string, StateSlot<unknown>>;\n /**\n * Runtime `state.series` slot store keyed by\n * `${slotIdPrefix ?? \"\"}${slotId}:series`. Each holds a history ring +\n * the identity-stable script-facing view + the last committed head.\n * The ring advances once per close (script-invisible lockstep), so\n * `s[1]` is always one committed bar back. Cleared on `dispose` after\n * the final snapshot captures it. @since 0.9\n */\n readonly seriesSlots: Map<string, SeriesSlot>;\n /**\n * Secondary candle streams keyed by `IntervalDescriptor.value`.\n * Mutated only by `createScriptRunner` mount/restore/routing. @since 0.5\n */\n readonly secondaryStreams: Map<string, StreamState>;\n /**\n * Per-`request.security` slot cache keyed by `slotId|interval`. Phase 4\n * stores NaN fallback bars here; Phase 5 replaces the value producer with\n * aligned secondary stream series while preserving stable identity.\n * @since 0.4\n */\n readonly requestSecurityBars: Map<string, SecurityBar>;\n /**\n * Per-compute aligned numeric arrays keyed by\n * `slotId|interval|sourceKey`. Cleared on main-stream close/tick before\n * `compute` so `request.security` re-aligns against the latest\n * secondary buffers. @since 0.5\n */\n readonly requestSecurityAlignments: Map<string, ReadonlyArray<number>>;\n /**\n * Per-compute cache of ascending `Bar[]` materialisations keyed by the\n * source `StreamState`. Shared by `request.security` and `request.lowerTf`\n * (via `request/streamBars.ts:ascendingBarsFor`) so a stable bar-array\n * identity is reused across every consumer in a bar — the `getOrAlign` /\n * `getOrBucket` WeakMap caches actually hit and the same ring buffer is\n * walked once per bar instead of 10×. Cleared alongside\n * {@link requestSecurityAlignments}. @since 0.5\n */\n readonly requestSecurityAscendingBars: Map<StreamState, ReadonlyArray<Bar>>;\n /**\n * Mounted HTF expression runners keyed by `slotId`. One entry per\n * `manifest.securityExpressions` callsite. `request.security(slotId,\n * opts, expr)` dispatches the expression overload off this registry\n * (rather than `expr !== undefined`) and captures the callback here.\n * Absent on dep / sibling contexts and single-timeframe scripts.\n * Cleared on `dispose`. @since 0.7\n */\n securityExprRunners?: Map<string, SecurityExprRunner>;\n /**\n * Per-interval index into {@link securityExprRunners}, keyed by\n * `IntervalDescriptor.value`. `driveSecurityExpressions` fans a\n * secondary close / tick out to every runner on that interval.\n * Absent when no expression callsites are declared. Cleared on\n * `dispose`. @since 0.7\n */\n securityExprRunnersByInterval?: ReadonlyMap<string, ReadonlyArray<SecurityExprRunner>>;\n /**\n * Per-compute aligned expression-output series cache keyed by\n * `slotId|interval`. Holds the stable `Series<number>` Proxy each\n * expression-form `request.security` returns; cleared each bar\n * (alongside {@link requestSecurityAlignments}) so the proxy re-aligns\n * the runner's output buffer against the latest secondary buffers.\n * @since 0.7\n */\n requestSecurityExprSeries?: Map<string, Series<number>>;\n /**\n * Per-`request.lowerTf` slot cache keyed by `slotId|interval`. Values are\n * stable `Series<ReadonlyArray<Bar>>` proxies over the latest LTF bucket\n * materialisation. @since 0.6\n */\n readonly requestLowerTfViews: Map<string, Series<ReadonlyArray<Bar>>>;\n /**\n * Runtime diagnostic dedupe for `request.*` capability gates, keyed by\n * `code|slotId|interval|kind`. Cleared on `dispose`. @since 0.4\n */\n readonly diagnosedRequestKeys: Set<string>;\n /**\n * Manifest-declared alert conditions keyed by condition id. Used by\n * `signal(conditionId, fired)` to reject unknown ids without\n * re-reading the manifest each bar. @since 0.5\n */\n readonly alertConditions?: ReadonlyMap<string, AlertConditionDefinition>;\n /**\n * Dedupe for alert-condition capability/unknown-id diagnostics, keyed\n * by `code|conditionId`. Cleared on dispose. @since 0.5\n */\n readonly diagnosedAlertConditionKeys?: Set<string>;\n /**\n * Number of `runtime.log.*` emissions accepted in the active compute\n * step. Reset at the start of each close/tick. @since 0.5\n */\n logBudget: number;\n /**\n * Per-step dedupe flag for `runtime-log-budget-exceeded`. Reset with\n * `logBudget` at the start of each close/tick. @since 0.5\n */\n logBudgetExceededDiagnosed: boolean;\n /**\n * Frozen effective input values keyed by script input name. Resolved once\n * at mount and reused by every compute step. @since 0.4\n */\n resolvedInputs: Readonly<Record<string, unknown>>;\n /**\n * Mount-time script pane default. The runner sets it from\n * `manifest.overlay`:\n * - `overlay` absent / `true` → `\"overlay\"`.\n * - `overlay === false` → `\"script:<sanitised(manifest.name)>\"`.\n * `resolvePane` reads this value when a `plot()` / `hline()` call\n * has no explicit `pane` opt.\n * @since 0.2\n */\n readonly defaultPane: string;\n /**\n * Stable non-overlay pane key for this script. Explicit\n * `pane: \"new\"` resolves here even when `defaultPane === \"overlay\"`\n * so every `\"new\"` plot in a script joins one script-owned subpane.\n * @since 0.2\n */\n readonly scriptPane: string;\n /**\n * Host-supplied per-slot presentation overrides, keyed by\n * `PlotEmission.slotId`. Applied at emit time by `applyPlotOverride`.\n * Mutable — `setPlotOverrides` swaps it live (presentation-only, so\n * it does not break the frozen-input determinism guarantee). Entries\n * themselves are frozen. @since 0.8\n */\n plotOverrides: Readonly<Record<string, PlotOverride>>;\n /**\n * Runtime diagnostic dedupe for mount-time input override failures,\n * keyed by manifest input key. Cleared on `dispose`. @since 0.4\n */\n readonly diagnosedInputKeys: Set<string>;\n /**\n * Runtime `barstate.*`, `syminfo.*`, and `timeframe.*` views. The\n * container is mutable; each assigned view snapshot is frozen.\n * @since 0.4\n */\n readonly views: RuntimeViews;\n /**\n * Prefix prepended when emissions from this context flow into the\n * parent runner's queues, and mirrored into every `stateSlots` /\n * `StateStore` key written by `state.*` / `state.tick.*` so each\n * runner's persisted state is isolated. `\"dep:<localId>/\"` for\n * private dep runners, `\"export:<exportName>/\"` for sibling\n * runners, and `\"\"` (or absent) for primary single-script and\n * bundle-primary runners.\n *\n * @since 0.7\n */\n slotIdPrefix?: string;\n /**\n * `true` when this context belongs to a private dep runner — its\n * emissions are dropped (or captured into the dep output store) by\n * `applyDepEmissionPolicy`. `false` / absent for primary and\n * sibling runners.\n *\n * @since 0.7\n */\n isDep?: boolean;\n /**\n * Per-bar titled-output buffer shared by the primary and every\n * sibling of a `CompiledScriptBundle`. Populated by\n * `applyDepEmissionPolicy` after each dep/sibling's compute; read\n * by `__chartlang_depOutput` during the consumer's compute. `null`\n * / absent for single-script runners with no deps.\n *\n * @since 0.7\n */\n depOutputStore?: DepOutputStore | null;\n};\n\n/**\n * Process-wide context slot. Task 6's `createScriptRunner` mutates\n * `.current` inside `try { ... } finally { current = null }` around\n * every `compute` invocation; Tasks 7-8 read it inside primitive\n * implementations. JavaScript's single-threaded execution model\n * guarantees only one `compute` runs at a time, so this ambient\n * slot is safe.\n *\n * The export is intentionally just a holder — no class, no methods,\n * no validation. Responsibility for setting and clearing lives in\n * Task 6.\n *\n * @since 0.1\n * @example\n * // import { ACTIVE_RUNTIME_CONTEXT }\n * // from \"@invinite-org/chartlang-runtime\";\n * // ACTIVE_RUNTIME_CONTEXT.current; // null at module load\n */\nexport const ACTIVE_RUNTIME_CONTEXT: { current: RuntimeContext | null } = {\n current: null,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"runtimeContext.js","sourceRoot":"","sources":["../src/runtimeContext.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAgY/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAuC;IACtE,OAAO,EAAE,IAAI;CAChB,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 AlertConditionEmission,\n AlertEmission,\n Capabilities,\n DrawingEmission,\n LogEmission,\n PlotEmission,\n PlotOverride,\n RuntimeDiagnostic,\n} from \"@invinite-org/chartlang-adapter-kit\";\nimport type {\n AlertConditionDefinition,\n Bar,\n DrawingBucket,\n DrawingCounts,\n DrawingKind,\n DrawingState,\n SecurityBar,\n Series,\n} from \"@invinite-org/chartlang-core\";\n\nimport type { DepOutputStore } from \"./dep/DepOutputStore.js\";\nimport type { PersistentStateStore } from \"./persistentStateStore.js\";\nimport type { SecurityExprRunner } from \"./request/securityExprRunner.js\";\nimport type { ArrayStateSlot } from \"./state/arrayStateSlot.js\";\nimport type { SeriesSlot } from \"./state/seriesSlot.js\";\nimport type { StateSlot } from \"./state/stateSlot.js\";\nimport type { StateStore } from \"./stateStore.js\";\nimport type { StreamState } from \"./streamState.js\";\nimport type { RuntimeViews } from \"./views/index.js\";\n\n/**\n * Per-handle drawing slot the runtime persists across bars. The key is\n * `slotId#subId` (compiler-injected callsite id + per-bar sub-id from\n * {@link nextSubId}). `state` holds the last full {@link DrawingState}\n * emitted for the handle; subsequent `update(patch)` calls merge into\n * it and re-emit the full payload. `removed: true`\n * is sticky — further `update` / `remove` on the handle no-op.\n *\n * `z` is the presentation-only render-order key `handle.ts`'s `splitZ`\n * lifted out of the drawing's `state.style` (default `0`). It is stored\n * **beside** `state` — never inside `state` / `state.style` — because\n * the wire carries it as the top-level {@link DrawingEmission.z} field,\n * not as part of {@link DrawingState}. It persists across bars; an\n * `update` that does not re-specify a non-zero `z` retains it, a\n * re-specified non-zero `z` overrides, and a cross-bar re-entry\n * re-specifies it from the new call.\n *\n * @since 0.3\n * @stable\n * @example\n * // const slot: DrawingSlot = {\n * // handleId: \"x.chart.ts:1:1#0\",\n * // kind: \"line\",\n * // state: { kind: \"line\", anchors: [...], style: {} },\n * // z: 0,\n * // removed: false,\n * // };\n */\nexport type DrawingSlot = {\n readonly handleId: string;\n readonly kind: DrawingKind;\n state: DrawingState;\n z: number;\n removed: boolean;\n};\n\n/**\n * Mutable counterpart of `RunnerEmissions` (from adapter-kit) that the\n * runtime accumulates into per bar. Task 6's execution loop pushes\n * here during `compute`; `drain()` snapshots into the readonly\n * `RunnerEmissions` shape the adapter receives.\n *\n * @since 0.1\n * @example\n * // const emissions: MutableRunnerEmissions = {\n * // plots: [],\n * // drawings: [],\n * // alerts: [],\n * // diagnostics: [],\n * // fromBar: 0,\n * // toBar: 0,\n * // };\n */\nexport type MutableRunnerEmissions = {\n plots: PlotEmission[];\n drawings: DrawingEmission[];\n alerts: AlertEmission[];\n alertConditions?: AlertConditionEmission[];\n logs: LogEmission[];\n diagnostics: RuntimeDiagnostic[];\n fromBar: number;\n toBar: number;\n};\n\n/**\n * The contract Task 6's execution loop hands to stateful primitives\n * (Tasks 7-8) inside a single `compute` step. Tasks 7-8 read this\n * through {@link ACTIVE_RUNTIME_CONTEXT} — the runtime sets `.current`\n * around `compute` in a `try/finally`, so primitives can find their\n * series, slot store, capability bag, emission destination, and bar\n * index without an explicit argument.\n *\n * `isTick` discriminates `onBarTick` calls (head-replace mode) from\n * `onBarClose` / `onHistory` (append mode). Stateful primitives in\n * Task 7 use it to swap append vs replace-head behaviour.\n *\n * `stateSlots` stores Phase-4 `state.*` / `state.tick.*` slots keyed by\n * `${slotId}:state`; values flush into `stateStore` at close/dispose.\n *\n * `views` is a mutable container whose fields are replaced with fresh frozen\n * `barstate.*`, `syminfo.*`, and `timeframe.*` snapshots as the runner\n * advances.\n *\n * `resolvedInputs` is the frozen bag handed to `compute({ inputs })`,\n * resolved once at mount from manifest defaults plus adapter overrides.\n *\n * @since 0.1\n * @example\n * // const ctx: RuntimeContext = {\n * // stream, stateStore, capabilities, emissions,\n * // barIndex: () => 0,\n * // isTick: false,\n * // };\n */\nexport type RuntimeContext = {\n readonly stream: StreamState;\n readonly stateStore: StateStore;\n readonly persistentStateStore?: PersistentStateStore;\n lastPersistTime: number;\n readonly capabilities: Capabilities;\n readonly emissions: MutableRunnerEmissions;\n readonly barIndex: () => number;\n isTick: boolean;\n /**\n * Per-handle drawing slot store keyed by `slotId#subId`. Allocated\n * on first `op: \"create\"`; mutated by `update(patch)` to merge the\n * patch into the slot's `state`; flagged `removed: true` on\n * `remove()`. Cleared on `dispose`. Persists across bars.\n * @since 0.3\n */\n readonly drawingSlots: Map<string, DrawingSlot>;\n /**\n * Per-callsite per-bar sub-id counter. Each `draw.<kind>(...)` call\n * inside a bar reads `nextSubId(ctx, slotId)`; the counter resets\n * at the top of each `onBarClose` / `onBarTick` so iteration `i` at\n * the same callsite yields the same `slotId#i` across bars.\n * Cleared on `dispose`. @since 0.3\n */\n readonly drawingSubIdCounters: Map<string, number>;\n /**\n * Live per-bucket allocation tally for the current script. Each\n * `op: \"create\"` increments the relevant bucket; each\n * `op: \"remove\"` decrements (clamped at 0). `op: \"update\"` is\n * free. `pushDrawing` drops the emission with\n * `drawing-budget-exceeded` once a bucket hits its effective\n * budget (min of adapter cap + `scriptMaxDrawings`). Reset to\n * zero on `dispose`. @since 0.3\n */\n readonly drawingBucketCounters: Record<DrawingBucket, number>;\n /**\n * The script's per-bucket cap from `defineIndicator({ maxDrawings:\n * ... })` / `defineDrawing({ maxDrawings: ... })`. `null` when\n * omitted — `pushDrawing` then enforces the adapter cap alone.\n * Effective budget is `min(scriptMaxDrawings[b],\n * capabilities.maxDrawingsPerScript[b])`. @since 0.3\n */\n readonly scriptMaxDrawings: DrawingCounts | null;\n /**\n * Runtime `state.*` / `state.tick.*` slot store keyed by\n * `${slotIdPrefix ?? \"\"}${slotId}:state`. Non-tick slots keep\n * committed/tentative values; tick slots commit writes immediately.\n * Cleared on `dispose` after flushing snapshots to `stateStore`.\n * @since 0.4\n */\n readonly stateSlots: Map<string, StateSlot<unknown>>;\n /**\n * Runtime `state.series` slot store keyed by\n * `${slotIdPrefix ?? \"\"}${slotId}:series`. Each holds a history ring +\n * the identity-stable script-facing view + the last committed head.\n * The ring advances once per close (script-invisible lockstep), so\n * `s[1]` is always one committed bar back. Cleared on `dispose` after\n * the final snapshot captures it. @since 0.9\n */\n readonly seriesSlots: Map<string, SeriesSlot>;\n /**\n * Runtime `state.array` slot store keyed by\n * `${slotIdPrefix ?? \"\"}${slotId}:array`. Each holds two\n * `Float64RingBuffer`s (committed + tentative) behind an identity-stable\n * bounded-FIFO handle. A parallel map (vs folding into `stateSlots`)\n * mirrors the `state.series` precedent — both collection primitives share\n * the two-ring shape and snapshot directly from the live map with no\n * `StateStore` flush. Cleared on `dispose`. @since 1.3\n */\n readonly arraySlots: Map<string, ArrayStateSlot>;\n /**\n * The chart's own symbol, resolved once at mount from the adapter\n * `syminfo.ticker` (`\"\"` when the adapter supplies none). A\n * `request.security` call that omits `symbol` — or passes this exact\n * ticker — resolves to it and collapses to the bare-interval\n * {@link feedKey}, so the chart-symbol path is byte-identical to the\n * pre-multi-symbol baseline. Only a *different* symbol allocates a\n * `\"<symbol>@<interval>\"` feed. @since 1.3\n */\n readonly chartSymbol: string;\n /**\n * Secondary candle streams keyed by the composite\n * `feedKey(symbol, interval)` (the shared core helper). A symbol-omitted\n * feed collapses to the bare interval — `feedKey(undefined, \"1D\") === \"1D\"`\n * — so the chart-symbol path is byte-identical to the pre-multi-symbol\n * baseline; a non-chart symbol keys as `\"<symbol>@<interval>\"`. Mutated only\n * by `createScriptRunner` mount/restore/routing. @since 0.5\n */\n readonly secondaryStreams: Map<string, StreamState>;\n /**\n * Per-`request.security` slot cache keyed by `slotId|feedKey`. Phase 4\n * stores NaN fallback bars here; Phase 5 replaces the value producer with\n * aligned secondary stream series while preserving stable identity. The\n * `feedKey` collapses to the bare interval for chart-symbol requests, so\n * the omitted-symbol cache key is byte-identical to the baseline.\n * @since 0.4\n */\n readonly requestSecurityBars: Map<string, SecurityBar>;\n /**\n * Per-compute aligned numeric arrays keyed by\n * `slotId|feedKey|sourceKey`. Cleared on main-stream close/tick before\n * `compute` so `request.security` re-aligns against the latest\n * secondary buffers. @since 0.5\n */\n readonly requestSecurityAlignments: Map<string, ReadonlyArray<number>>;\n /**\n * Per-compute cache of ascending `Bar[]` materialisations keyed by the\n * source `StreamState`. Shared by `request.security` and `request.lowerTf`\n * (via `request/streamBars.ts:ascendingBarsFor`) so a stable bar-array\n * identity is reused across every consumer in a bar — the `getOrAlign` /\n * `getOrBucket` WeakMap caches actually hit and the same ring buffer is\n * walked once per bar instead of 10×. Cleared alongside\n * {@link requestSecurityAlignments}. @since 0.5\n */\n readonly requestSecurityAscendingBars: Map<StreamState, ReadonlyArray<Bar>>;\n /**\n * Mounted HTF expression runners keyed by `slotId`. One entry per\n * `manifest.securityExpressions` callsite. `request.security(slotId,\n * opts, expr)` dispatches the expression overload off this registry\n * (rather than `expr !== undefined`) and captures the callback here.\n * Absent on dep / sibling contexts and single-timeframe scripts.\n * Cleared on `dispose`. @since 0.7\n */\n securityExprRunners?: Map<string, SecurityExprRunner>;\n /**\n * Per-feed index into {@link securityExprRunners}, keyed by the composite\n * `feedKey(symbol, interval)`. `driveSecurityExpressions` fans a secondary\n * close / tick (tagged with that same composite key on\n * `CandleEvent.streamKey`) out to every runner on that feed. A\n * symbol-omitted callsite collapses to the bare interval, byte-identical to\n * the pre-multi-symbol baseline. Absent when no expression callsites are\n * declared. Cleared on `dispose`. @since 0.7\n */\n securityExprRunnersByFeed?: ReadonlyMap<string, ReadonlyArray<SecurityExprRunner>>;\n /**\n * Per-compute aligned expression-output series cache keyed by\n * `slotId|feedKey`. Holds the stable `Series<number>` Proxy each\n * expression-form `request.security` returns; cleared each bar\n * (alongside {@link requestSecurityAlignments}) so the proxy re-aligns\n * the runner's output buffer against the latest secondary buffers.\n * @since 0.7\n */\n requestSecurityExprSeries?: Map<string, Series<number>>;\n /**\n * Per-`request.lowerTf` slot cache keyed by `slotId|interval`. Values are\n * stable `Series<ReadonlyArray<Bar>>` proxies over the latest LTF bucket\n * materialisation. @since 0.6\n */\n readonly requestLowerTfViews: Map<string, Series<ReadonlyArray<Bar>>>;\n /**\n * Runtime diagnostic dedupe for `request.*` capability gates, keyed by\n * `code|slotId|interval|kind`. Cleared on `dispose`. @since 0.4\n */\n readonly diagnosedRequestKeys: Set<string>;\n /**\n * Runtime diagnostic dedupe for `time.*` / `session.*` DST-zone\n * fallbacks, keyed by `tz-dst-unsupported|<tz>`. The calendar accessors\n * are `slot: false` (no slotId to key on), so they dedupe on the\n * timezone string here — a DST zone warns at most once per distinct tz\n * per mount. Cleared on `dispose`. @since 1.5\n */\n readonly diagnosedTzKeys: Set<string>;\n /**\n * Manifest-declared alert conditions keyed by condition id. Used by\n * `signal(conditionId, fired)` to reject unknown ids without\n * re-reading the manifest each bar. @since 0.5\n */\n readonly alertConditions?: ReadonlyMap<string, AlertConditionDefinition>;\n /**\n * Dedupe for alert-condition capability/unknown-id diagnostics, keyed\n * by `code|conditionId`. Cleared on dispose. @since 0.5\n */\n readonly diagnosedAlertConditionKeys?: Set<string>;\n /**\n * Number of `runtime.log.*` emissions accepted in the active compute\n * step. Reset at the start of each close/tick. @since 0.5\n */\n logBudget: number;\n /**\n * Per-step dedupe flag for `runtime-log-budget-exceeded`. Reset with\n * `logBudget` at the start of each close/tick. @since 0.5\n */\n logBudgetExceededDiagnosed: boolean;\n /**\n * Frozen effective input values keyed by script input name. Resolved once\n * at mount and reused by every compute step. @since 0.4\n */\n resolvedInputs: Readonly<Record<string, unknown>>;\n /**\n * Mount-time script pane default. The runner sets it from\n * `manifest.overlay`:\n * - `overlay` absent / `true` → `\"overlay\"`.\n * - `overlay === false` → `\"script:<sanitised(manifest.name)>\"`.\n * `resolvePane` reads this value when a `plot()` / `hline()` call\n * has no explicit `pane` opt.\n * @since 0.2\n */\n readonly defaultPane: string;\n /**\n * Stable non-overlay pane key for this script. Explicit\n * `pane: \"new\"` resolves here even when `defaultPane === \"overlay\"`\n * so every `\"new\"` plot in a script joins one script-owned subpane.\n * @since 0.2\n */\n readonly scriptPane: string;\n /**\n * Host-supplied per-slot presentation overrides, keyed by\n * `PlotEmission.slotId`. Applied at emit time by `applyPlotOverride`.\n * Mutable — `setPlotOverrides` swaps it live (presentation-only, so\n * it does not break the frozen-input determinism guarantee). Entries\n * themselves are frozen. @since 0.8\n */\n plotOverrides: Readonly<Record<string, PlotOverride>>;\n /**\n * Runtime diagnostic dedupe for mount-time input override failures,\n * keyed by manifest input key. Cleared on `dispose`. @since 0.4\n */\n readonly diagnosedInputKeys: Set<string>;\n /**\n * Runtime `barstate.*`, `syminfo.*`, and `timeframe.*` views. The\n * container is mutable; each assigned view snapshot is frozen.\n * @since 0.4\n */\n readonly views: RuntimeViews;\n /**\n * Prefix prepended when emissions from this context flow into the\n * parent runner's queues, and mirrored into every `stateSlots` /\n * `StateStore` key written by `state.*` / `state.tick.*` so each\n * runner's persisted state is isolated. `\"dep:<localId>/\"` for\n * private dep runners, `\"export:<exportName>/\"` for sibling\n * runners, and `\"\"` (or absent) for primary single-script and\n * bundle-primary runners.\n *\n * @since 0.7\n */\n slotIdPrefix?: string;\n /**\n * `true` when this context belongs to a private dep runner — its\n * emissions are dropped (or captured into the dep output store) by\n * `applyDepEmissionPolicy`. `false` / absent for primary and\n * sibling runners.\n *\n * @since 0.7\n */\n isDep?: boolean;\n /**\n * Per-bar titled-output buffer shared by the primary and every\n * sibling of a `CompiledScriptBundle`. Populated by\n * `applyDepEmissionPolicy` after each dep/sibling's compute; read\n * by `__chartlang_depOutput` during the consumer's compute. `null`\n * / absent for single-script runners with no deps.\n *\n * @since 0.7\n */\n depOutputStore?: DepOutputStore | null;\n};\n\n/**\n * Process-wide context slot. Task 6's `createScriptRunner` mutates\n * `.current` inside `try { ... } finally { current = null }` around\n * every `compute` invocation; Tasks 7-8 read it inside primitive\n * implementations. JavaScript's single-threaded execution model\n * guarantees only one `compute` runs at a time, so this ambient\n * slot is safe.\n *\n * The export is intentionally just a holder — no class, no methods,\n * no validation. Responsibility for setting and clearing lives in\n * Task 6.\n *\n * @since 0.1\n * @example\n * // import { ACTIVE_RUNTIME_CONTEXT }\n * // from \"@invinite-org/chartlang-runtime\";\n * // ACTIVE_RUNTIME_CONTEXT.current; // null at module load\n */\nexport const ACTIVE_RUNTIME_CONTEXT: { current: RuntimeContext | null } = {\n current: null,\n};\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { JsonValue } from "@invinite-org/chartlang-core";
|
|
2
|
+
import type { RuntimeContext } from "../runtimeContext.js";
|
|
3
|
+
/**
|
|
4
|
+
* Return whether a snapshot slot key belongs to the `state.array` namespace
|
|
5
|
+
* (a `${slotIdPrefix}${slotId}:array` key). Lets the restore router separate
|
|
6
|
+
* array slots from scalar `state.*` (`:state`), `state.series` (`:series`), and
|
|
7
|
+
* `ta.*` (`ta:`) slots, all of which share one `slots` record.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.3
|
|
10
|
+
* @internal
|
|
11
|
+
* @stable
|
|
12
|
+
* @example
|
|
13
|
+
* isArraySlotSnapshotKey("x.chart.ts:1:1:array"); // true
|
|
14
|
+
*/
|
|
15
|
+
export declare function isArraySlotSnapshotKey(key: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Serialise the runner's `state.array` slots into JSON-clean snapshot entries
|
|
18
|
+
* keyed by the same `${prefix}${slotId}:array` key the slot store uses. Both
|
|
19
|
+
* rings ride {@link Float64RingBuffer.serialiseSnapshotBuffer}; `capacity` is
|
|
20
|
+
* recorded so restore can detect a script-edited capacity and degrade.
|
|
21
|
+
*
|
|
22
|
+
* @since 1.3
|
|
23
|
+
* @internal
|
|
24
|
+
* @stable
|
|
25
|
+
* @example
|
|
26
|
+
* // const entries = serialiseArraySlots(ctx);
|
|
27
|
+
* const entries = {};
|
|
28
|
+
* void entries;
|
|
29
|
+
*/
|
|
30
|
+
export declare function serialiseArraySlots(ctx: RuntimeContext): Readonly<Record<string, JsonValue>>;
|
|
31
|
+
/**
|
|
32
|
+
* Restore `state.array` slots from namespaced snapshot entries into
|
|
33
|
+
* `ctx.arraySlots`, rebuilding each ring at the *persisted* `capacity`. Non-array
|
|
34
|
+
* keys are ignored; a malformed snapshot — or one whose ring shape no longer
|
|
35
|
+
* matches its recorded `capacity` — is skipped so the slot starts fresh (a
|
|
36
|
+
* script-edited `state.array(cap)` literal degrades, it does not throw). The
|
|
37
|
+
* handle identity is recreated on restore (acceptable — same as `state.series`).
|
|
38
|
+
*
|
|
39
|
+
* @since 1.3
|
|
40
|
+
* @internal
|
|
41
|
+
* @stable
|
|
42
|
+
* @example
|
|
43
|
+
* // restoreArraySlots(ctx, snapshot.slots);
|
|
44
|
+
* const restored = true;
|
|
45
|
+
* void restored;
|
|
46
|
+
*/
|
|
47
|
+
export declare function restoreArraySlots(ctx: RuntimeContext, slots: Readonly<Record<string, unknown>>): void;
|
|
48
|
+
//# sourceMappingURL=arrayPersistence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayPersistence.d.ts","sourceRoot":"","sources":["../../src/state/arrayPersistence.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAS9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAW5F;AAaD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAC7B,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACzC,IAAI,CASN"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import { isBufferSnapshot, isInteger, isRecord, restoreBuffer, serialiseBuffer, } from "../bufferSnapshot.js";
|
|
4
|
+
import { restoreArrayStateSlot } from "./arrayStateSlot.js";
|
|
5
|
+
const ARRAY_SLOT_SUFFIX = ":array";
|
|
6
|
+
/**
|
|
7
|
+
* Return whether a snapshot slot key belongs to the `state.array` namespace
|
|
8
|
+
* (a `${slotIdPrefix}${slotId}:array` key). Lets the restore router separate
|
|
9
|
+
* array slots from scalar `state.*` (`:state`), `state.series` (`:series`), and
|
|
10
|
+
* `ta.*` (`ta:`) slots, all of which share one `slots` record.
|
|
11
|
+
*
|
|
12
|
+
* @since 1.3
|
|
13
|
+
* @internal
|
|
14
|
+
* @stable
|
|
15
|
+
* @example
|
|
16
|
+
* isArraySlotSnapshotKey("x.chart.ts:1:1:array"); // true
|
|
17
|
+
*/
|
|
18
|
+
export function isArraySlotSnapshotKey(key) {
|
|
19
|
+
return key.endsWith(ARRAY_SLOT_SUFFIX);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Serialise the runner's `state.array` slots into JSON-clean snapshot entries
|
|
23
|
+
* keyed by the same `${prefix}${slotId}:array` key the slot store uses. Both
|
|
24
|
+
* rings ride {@link Float64RingBuffer.serialiseSnapshotBuffer}; `capacity` is
|
|
25
|
+
* recorded so restore can detect a script-edited capacity and degrade.
|
|
26
|
+
*
|
|
27
|
+
* @since 1.3
|
|
28
|
+
* @internal
|
|
29
|
+
* @stable
|
|
30
|
+
* @example
|
|
31
|
+
* // const entries = serialiseArraySlots(ctx);
|
|
32
|
+
* const entries = {};
|
|
33
|
+
* void entries;
|
|
34
|
+
*/
|
|
35
|
+
export function serialiseArraySlots(ctx) {
|
|
36
|
+
const out = {};
|
|
37
|
+
for (const [key, slot] of ctx.arraySlots.entries()) {
|
|
38
|
+
out[key] = {
|
|
39
|
+
kind: "state.array",
|
|
40
|
+
capacity: slot.capacity,
|
|
41
|
+
committed: serialiseBuffer(slot.committedRing),
|
|
42
|
+
tentative: serialiseBuffer(slot.tentativeRing),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return Object.freeze(out);
|
|
46
|
+
}
|
|
47
|
+
function restoreArraySlotSnapshot(snapshot) {
|
|
48
|
+
if (!isRecord(snapshot) || snapshot.kind !== "state.array")
|
|
49
|
+
return null;
|
|
50
|
+
if (!isInteger(snapshot.capacity) || snapshot.capacity <= 0)
|
|
51
|
+
return null;
|
|
52
|
+
const { committed, tentative } = snapshot;
|
|
53
|
+
if (!isBufferSnapshot(committed) || !isBufferSnapshot(tentative))
|
|
54
|
+
return null;
|
|
55
|
+
const committedRing = restoreBuffer(committed, snapshot.capacity);
|
|
56
|
+
const tentativeRing = restoreBuffer(tentative, snapshot.capacity);
|
|
57
|
+
if (committedRing === null || tentativeRing === null)
|
|
58
|
+
return null;
|
|
59
|
+
return restoreArrayStateSlot(committedRing, tentativeRing);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Restore `state.array` slots from namespaced snapshot entries into
|
|
63
|
+
* `ctx.arraySlots`, rebuilding each ring at the *persisted* `capacity`. Non-array
|
|
64
|
+
* keys are ignored; a malformed snapshot — or one whose ring shape no longer
|
|
65
|
+
* matches its recorded `capacity` — is skipped so the slot starts fresh (a
|
|
66
|
+
* script-edited `state.array(cap)` literal degrades, it does not throw). The
|
|
67
|
+
* handle identity is recreated on restore (acceptable — same as `state.series`).
|
|
68
|
+
*
|
|
69
|
+
* @since 1.3
|
|
70
|
+
* @internal
|
|
71
|
+
* @stable
|
|
72
|
+
* @example
|
|
73
|
+
* // restoreArraySlots(ctx, snapshot.slots);
|
|
74
|
+
* const restored = true;
|
|
75
|
+
* void restored;
|
|
76
|
+
*/
|
|
77
|
+
export function restoreArraySlots(ctx, slots) {
|
|
78
|
+
ctx.arraySlots.clear();
|
|
79
|
+
for (const [key, value] of Object.entries(slots)) {
|
|
80
|
+
if (!isArraySlotSnapshotKey(key))
|
|
81
|
+
continue;
|
|
82
|
+
const slot = restoreArraySlotSnapshot(value);
|
|
83
|
+
if (slot !== null) {
|
|
84
|
+
ctx.arraySlots.set(key, slot);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=arrayPersistence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayPersistence.js","sourceRoot":"","sources":["../../src/state/arrayPersistence.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EACH,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,eAAe,GAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAEnC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAC9C,OAAO,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAmB;IACnD,MAAM,GAAG,GAA8B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;QACjD,GAAG,CAAC,GAAG,CAAC,GAAG;YACP,IAAI,EAAE,aAAa;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;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,MAAM,IAAI,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAChB,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;AACL,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 { JsonValue } from \"@invinite-org/chartlang-core\";\n\nimport {\n isBufferSnapshot,\n isInteger,\n isRecord,\n restoreBuffer,\n serialiseBuffer,\n} from \"../bufferSnapshot.js\";\nimport type { RuntimeContext } from \"../runtimeContext.js\";\nimport type { ArrayStateSlot } from \"./arrayStateSlot.js\";\nimport { restoreArrayStateSlot } from \"./arrayStateSlot.js\";\n\nconst ARRAY_SLOT_SUFFIX = \":array\";\n\n/**\n * Return whether a snapshot slot key belongs to the `state.array` namespace\n * (a `${slotIdPrefix}${slotId}:array` key). Lets the restore router separate\n * array slots from scalar `state.*` (`:state`), `state.series` (`:series`), and\n * `ta.*` (`ta:`) slots, all of which share one `slots` record.\n *\n * @since 1.3\n * @internal\n * @stable\n * @example\n * isArraySlotSnapshotKey(\"x.chart.ts:1:1:array\"); // true\n */\nexport function isArraySlotSnapshotKey(key: string): boolean {\n return key.endsWith(ARRAY_SLOT_SUFFIX);\n}\n\n/**\n * Serialise the runner's `state.array` slots into JSON-clean snapshot entries\n * keyed by the same `${prefix}${slotId}:array` key the slot store uses. Both\n * rings ride {@link Float64RingBuffer.serialiseSnapshotBuffer}; `capacity` is\n * recorded so restore can detect a script-edited capacity and degrade.\n *\n * @since 1.3\n * @internal\n * @stable\n * @example\n * // const entries = serialiseArraySlots(ctx);\n * const entries = {};\n * void entries;\n */\nexport function serialiseArraySlots(ctx: RuntimeContext): Readonly<Record<string, JsonValue>> {\n const out: Record<string, JsonValue> = {};\n for (const [key, slot] of ctx.arraySlots.entries()) {\n out[key] = {\n kind: \"state.array\",\n capacity: slot.capacity,\n committed: serialiseBuffer(slot.committedRing),\n tentative: serialiseBuffer(slot.tentativeRing),\n };\n }\n return Object.freeze(out);\n}\n\nfunction restoreArraySlotSnapshot(snapshot: unknown): ArrayStateSlot | null {\n if (!isRecord(snapshot) || snapshot.kind !== \"state.array\") return null;\n if (!isInteger(snapshot.capacity) || snapshot.capacity <= 0) return null;\n const { committed, tentative } = snapshot;\n if (!isBufferSnapshot(committed) || !isBufferSnapshot(tentative)) return null;\n const committedRing = restoreBuffer(committed, snapshot.capacity);\n const tentativeRing = restoreBuffer(tentative, snapshot.capacity);\n if (committedRing === null || tentativeRing === null) return null;\n return restoreArrayStateSlot(committedRing, tentativeRing);\n}\n\n/**\n * Restore `state.array` slots from namespaced snapshot entries into\n * `ctx.arraySlots`, rebuilding each ring at the *persisted* `capacity`. Non-array\n * keys are ignored; a malformed snapshot — or one whose ring shape no longer\n * matches its recorded `capacity` — is skipped so the slot starts fresh (a\n * script-edited `state.array(cap)` literal degrades, it does not throw). The\n * handle identity is recreated on restore (acceptable — same as `state.series`).\n *\n * @since 1.3\n * @internal\n * @stable\n * @example\n * // restoreArraySlots(ctx, snapshot.slots);\n * const restored = true;\n * void restored;\n */\nexport function restoreArraySlots(\n ctx: RuntimeContext,\n slots: Readonly<Record<string, unknown>>,\n): void {\n ctx.arraySlots.clear();\n for (const [key, value] of Object.entries(slots)) {\n if (!isArraySlotSnapshotKey(key)) continue;\n const slot = restoreArraySlotSnapshot(value);\n if (slot !== null) {\n ctx.arraySlots.set(key, slot);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { MutableArraySlot } from "@invinite-org/chartlang-core";
|
|
2
|
+
import { Float64RingBuffer } from "../ringBuffer.js";
|
|
3
|
+
/**
|
|
4
|
+
* Runtime slot behind a script-facing `state.array(capacity)` handle. Unlike
|
|
5
|
+
* the scalar `StateSlot` (one committed/tentative *value*) or the `SeriesSlot`
|
|
6
|
+
* (one ring advanced once per bar), this is a **bounded FIFO collection** with
|
|
7
|
+
* two `Float64RingBuffer`s: `tentativeRing` holds the live, author-facing
|
|
8
|
+
* pushes; `committedRing` is the bar-close snapshot a tick rolls back to.
|
|
9
|
+
*
|
|
10
|
+
* The committed/tentative discipline mirrors `StateSlot`: pushes during a tick
|
|
11
|
+
* mutate the tentative ring; a head-bar-replacing tick resets it from committed
|
|
12
|
+
* (in-progress pushes discarded); a bar close commits tentative into committed.
|
|
13
|
+
* The two-ring copy is `O(capacity)` per tick via a typed-array
|
|
14
|
+
* {@link Float64RingBuffer.copyFrom} memcpy — bounded because `capacity` is a
|
|
15
|
+
* required compile-time literal (see `tasks/future/state-array/README.md`
|
|
16
|
+
* Architecture Decisions: "Tick rollback = a two-ring buffer copy").
|
|
17
|
+
*
|
|
18
|
+
* @since 1.3
|
|
19
|
+
* @stable
|
|
20
|
+
* @example
|
|
21
|
+
* const slot = new ArrayStateSlot(4);
|
|
22
|
+
* slot.handle.push(1);
|
|
23
|
+
* slot.onBarClose();
|
|
24
|
+
* slot.handle.get(0); // 1
|
|
25
|
+
*/
|
|
26
|
+
export declare class ArrayStateSlot {
|
|
27
|
+
readonly capacity: number;
|
|
28
|
+
readonly committedRing: Float64RingBuffer;
|
|
29
|
+
readonly tentativeRing: Float64RingBuffer;
|
|
30
|
+
readonly handle: MutableArraySlot<number>;
|
|
31
|
+
constructor(capacity: number);
|
|
32
|
+
/** Commit the tentative ring into the committed ring (bar close). */
|
|
33
|
+
onBarClose(): void;
|
|
34
|
+
/** Roll the tentative ring back to the committed ring (head-replacing tick). */
|
|
35
|
+
onBarTick(): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build the identity-stable {@link MutableArraySlot} handle over an
|
|
39
|
+
* {@link ArrayStateSlot}. All author-facing reads and writes route through the
|
|
40
|
+
* **tentative** ring (mirroring `StateSlot.set`/`StateSlot.get`, which read and
|
|
41
|
+
* write `tentative` for non-tick slots); the committed ring is the rollback
|
|
42
|
+
* source. `get(out-of-range)` returns `NaN` (the ring's `at` contract), never
|
|
43
|
+
* throws. A plain object with getters — no `Proxy` — because the handle has a
|
|
44
|
+
* fixed method set and is deliberately not number-coercible.
|
|
45
|
+
*
|
|
46
|
+
* @since 1.3
|
|
47
|
+
* @stable
|
|
48
|
+
* @example
|
|
49
|
+
* // const handle = buildArrayHandle(new ArrayStateSlot(4));
|
|
50
|
+
* // handle.push(1);
|
|
51
|
+
* // handle.last(); // 1
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildArrayHandle(slot: ArrayStateSlot): MutableArraySlot<number>;
|
|
54
|
+
/**
|
|
55
|
+
* Allocate a fresh {@link ArrayStateSlot} — both rings empty (`size === 0`).
|
|
56
|
+
* Unlike `state.float(init)` there is no seed value: an empty collection starts
|
|
57
|
+
* empty.
|
|
58
|
+
*
|
|
59
|
+
* @since 1.3
|
|
60
|
+
* @stable
|
|
61
|
+
* @example
|
|
62
|
+
* // const slot = createArrayStateSlot(20);
|
|
63
|
+
* // slot.handle.size; // 0
|
|
64
|
+
*/
|
|
65
|
+
export declare function createArrayStateSlot(capacity: number): ArrayStateSlot;
|
|
66
|
+
/**
|
|
67
|
+
* Rebuild an {@link ArrayStateSlot} from already-restored rings (snapshot
|
|
68
|
+
* path). The handle identity is recreated — acceptable, same as
|
|
69
|
+
* `state.series` / `ta.*` restore.
|
|
70
|
+
*
|
|
71
|
+
* @since 1.3
|
|
72
|
+
* @stable
|
|
73
|
+
* @example
|
|
74
|
+
* // const slot = restoreArrayStateSlot(committedRing, tentativeRing);
|
|
75
|
+
* // slot.handle.size;
|
|
76
|
+
*/
|
|
77
|
+
export declare function restoreArrayStateSlot(committedRing: Float64RingBuffer, tentativeRing: Float64RingBuffer): ArrayStateSlot;
|
|
78
|
+
//# sourceMappingURL=arrayStateSlot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayStateSlot.d.ts","sourceRoot":"","sources":["../../src/state/arrayStateSlot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,cAAc;aAKK,QAAQ,EAAE,MAAM;IAJ5C,QAAQ,CAAC,aAAa,EAAE,iBAAiB,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,iBAAiB,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBAEd,QAAQ,EAAE,MAAM;IAM5C,qEAAqE;IACrE,UAAU,IAAI,IAAI;IAIlB,gFAAgF;IAChF,SAAS,IAAI,IAAI;CAGpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAqB/E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAErE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACjC,aAAa,EAAE,iBAAiB,EAChC,aAAa,EAAE,iBAAiB,GACjC,cAAc,CAKhB"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import { Float64RingBuffer } from "../ringBuffer.js";
|
|
4
|
+
/**
|
|
5
|
+
* Runtime slot behind a script-facing `state.array(capacity)` handle. Unlike
|
|
6
|
+
* the scalar `StateSlot` (one committed/tentative *value*) or the `SeriesSlot`
|
|
7
|
+
* (one ring advanced once per bar), this is a **bounded FIFO collection** with
|
|
8
|
+
* two `Float64RingBuffer`s: `tentativeRing` holds the live, author-facing
|
|
9
|
+
* pushes; `committedRing` is the bar-close snapshot a tick rolls back to.
|
|
10
|
+
*
|
|
11
|
+
* The committed/tentative discipline mirrors `StateSlot`: pushes during a tick
|
|
12
|
+
* mutate the tentative ring; a head-bar-replacing tick resets it from committed
|
|
13
|
+
* (in-progress pushes discarded); a bar close commits tentative into committed.
|
|
14
|
+
* The two-ring copy is `O(capacity)` per tick via a typed-array
|
|
15
|
+
* {@link Float64RingBuffer.copyFrom} memcpy — bounded because `capacity` is a
|
|
16
|
+
* required compile-time literal (see `tasks/future/state-array/README.md`
|
|
17
|
+
* Architecture Decisions: "Tick rollback = a two-ring buffer copy").
|
|
18
|
+
*
|
|
19
|
+
* @since 1.3
|
|
20
|
+
* @stable
|
|
21
|
+
* @example
|
|
22
|
+
* const slot = new ArrayStateSlot(4);
|
|
23
|
+
* slot.handle.push(1);
|
|
24
|
+
* slot.onBarClose();
|
|
25
|
+
* slot.handle.get(0); // 1
|
|
26
|
+
*/
|
|
27
|
+
export class ArrayStateSlot {
|
|
28
|
+
capacity;
|
|
29
|
+
committedRing;
|
|
30
|
+
tentativeRing;
|
|
31
|
+
handle;
|
|
32
|
+
constructor(capacity) {
|
|
33
|
+
this.capacity = capacity;
|
|
34
|
+
this.committedRing = new Float64RingBuffer(capacity);
|
|
35
|
+
this.tentativeRing = new Float64RingBuffer(capacity);
|
|
36
|
+
this.handle = buildArrayHandle(this);
|
|
37
|
+
}
|
|
38
|
+
/** Commit the tentative ring into the committed ring (bar close). */
|
|
39
|
+
onBarClose() {
|
|
40
|
+
this.committedRing.copyFrom(this.tentativeRing);
|
|
41
|
+
}
|
|
42
|
+
/** Roll the tentative ring back to the committed ring (head-replacing tick). */
|
|
43
|
+
onBarTick() {
|
|
44
|
+
this.tentativeRing.copyFrom(this.committedRing);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build the identity-stable {@link MutableArraySlot} handle over an
|
|
49
|
+
* {@link ArrayStateSlot}. All author-facing reads and writes route through the
|
|
50
|
+
* **tentative** ring (mirroring `StateSlot.set`/`StateSlot.get`, which read and
|
|
51
|
+
* write `tentative` for non-tick slots); the committed ring is the rollback
|
|
52
|
+
* source. `get(out-of-range)` returns `NaN` (the ring's `at` contract), never
|
|
53
|
+
* throws. A plain object with getters — no `Proxy` — because the handle has a
|
|
54
|
+
* fixed method set and is deliberately not number-coercible.
|
|
55
|
+
*
|
|
56
|
+
* @since 1.3
|
|
57
|
+
* @stable
|
|
58
|
+
* @example
|
|
59
|
+
* // const handle = buildArrayHandle(new ArrayStateSlot(4));
|
|
60
|
+
* // handle.push(1);
|
|
61
|
+
* // handle.last(); // 1
|
|
62
|
+
*/
|
|
63
|
+
export function buildArrayHandle(slot) {
|
|
64
|
+
return {
|
|
65
|
+
push(value) {
|
|
66
|
+
slot.tentativeRing.append(value);
|
|
67
|
+
},
|
|
68
|
+
get(n) {
|
|
69
|
+
return slot.tentativeRing.at(n);
|
|
70
|
+
},
|
|
71
|
+
last() {
|
|
72
|
+
return slot.tentativeRing.at(0);
|
|
73
|
+
},
|
|
74
|
+
clear() {
|
|
75
|
+
slot.tentativeRing.reset();
|
|
76
|
+
},
|
|
77
|
+
get size() {
|
|
78
|
+
return slot.tentativeRing.length;
|
|
79
|
+
},
|
|
80
|
+
get capacity() {
|
|
81
|
+
return slot.capacity;
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Allocate a fresh {@link ArrayStateSlot} — both rings empty (`size === 0`).
|
|
87
|
+
* Unlike `state.float(init)` there is no seed value: an empty collection starts
|
|
88
|
+
* empty.
|
|
89
|
+
*
|
|
90
|
+
* @since 1.3
|
|
91
|
+
* @stable
|
|
92
|
+
* @example
|
|
93
|
+
* // const slot = createArrayStateSlot(20);
|
|
94
|
+
* // slot.handle.size; // 0
|
|
95
|
+
*/
|
|
96
|
+
export function createArrayStateSlot(capacity) {
|
|
97
|
+
return new ArrayStateSlot(capacity);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Rebuild an {@link ArrayStateSlot} from already-restored rings (snapshot
|
|
101
|
+
* path). The handle identity is recreated — acceptable, same as
|
|
102
|
+
* `state.series` / `ta.*` restore.
|
|
103
|
+
*
|
|
104
|
+
* @since 1.3
|
|
105
|
+
* @stable
|
|
106
|
+
* @example
|
|
107
|
+
* // const slot = restoreArrayStateSlot(committedRing, tentativeRing);
|
|
108
|
+
* // slot.handle.size;
|
|
109
|
+
*/
|
|
110
|
+
export function restoreArrayStateSlot(committedRing, tentativeRing) {
|
|
111
|
+
const slot = new ArrayStateSlot(committedRing.capacity);
|
|
112
|
+
slot.committedRing.copyFrom(committedRing);
|
|
113
|
+
slot.tentativeRing.copyFrom(tentativeRing);
|
|
114
|
+
return slot;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=arrayStateSlot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayStateSlot.js","sourceRoot":"","sources":["../../src/state/arrayStateSlot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,cAAc;IAKK;IAJnB,aAAa,CAAoB;IACjC,aAAa,CAAoB;IACjC,MAAM,CAA2B;IAE1C,YAA4B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,qEAAqE;IACrE,UAAU;QACN,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACpD,CAAC;IAED,gFAAgF;IAChF,SAAS;QACL,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACpD,CAAC;CACJ;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAoB;IACjD,OAAO;QACH,IAAI,CAAC,KAAa;YACd,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QACD,GAAG,CAAC,CAAS;YACT,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC;QACD,IAAI;YACA,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC;QACD,KAAK;YACD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC;QACD,IAAI,IAAI;YACJ,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;QACrC,CAAC;QACD,IAAI,QAAQ;YACR,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;KACJ,CAAC;AACN,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACjD,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CACjC,aAAgC,EAChC,aAAgC;IAEhC,MAAM,IAAI,GAAG,IAAI,cAAc,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACxD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC3C,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 { MutableArraySlot } from \"@invinite-org/chartlang-core\";\n\nimport { Float64RingBuffer } from \"../ringBuffer.js\";\n\n/**\n * Runtime slot behind a script-facing `state.array(capacity)` handle. Unlike\n * the scalar `StateSlot` (one committed/tentative *value*) or the `SeriesSlot`\n * (one ring advanced once per bar), this is a **bounded FIFO collection** with\n * two `Float64RingBuffer`s: `tentativeRing` holds the live, author-facing\n * pushes; `committedRing` is the bar-close snapshot a tick rolls back to.\n *\n * The committed/tentative discipline mirrors `StateSlot`: pushes during a tick\n * mutate the tentative ring; a head-bar-replacing tick resets it from committed\n * (in-progress pushes discarded); a bar close commits tentative into committed.\n * The two-ring copy is `O(capacity)` per tick via a typed-array\n * {@link Float64RingBuffer.copyFrom} memcpy — bounded because `capacity` is a\n * required compile-time literal (see `tasks/future/state-array/README.md`\n * Architecture Decisions: \"Tick rollback = a two-ring buffer copy\").\n *\n * @since 1.3\n * @stable\n * @example\n * const slot = new ArrayStateSlot(4);\n * slot.handle.push(1);\n * slot.onBarClose();\n * slot.handle.get(0); // 1\n */\nexport class ArrayStateSlot {\n readonly committedRing: Float64RingBuffer;\n readonly tentativeRing: Float64RingBuffer;\n readonly handle: MutableArraySlot<number>;\n\n constructor(public readonly capacity: number) {\n this.committedRing = new Float64RingBuffer(capacity);\n this.tentativeRing = new Float64RingBuffer(capacity);\n this.handle = buildArrayHandle(this);\n }\n\n /** Commit the tentative ring into the committed ring (bar close). */\n onBarClose(): void {\n this.committedRing.copyFrom(this.tentativeRing);\n }\n\n /** Roll the tentative ring back to the committed ring (head-replacing tick). */\n onBarTick(): void {\n this.tentativeRing.copyFrom(this.committedRing);\n }\n}\n\n/**\n * Build the identity-stable {@link MutableArraySlot} handle over an\n * {@link ArrayStateSlot}. All author-facing reads and writes route through the\n * **tentative** ring (mirroring `StateSlot.set`/`StateSlot.get`, which read and\n * write `tentative` for non-tick slots); the committed ring is the rollback\n * source. `get(out-of-range)` returns `NaN` (the ring's `at` contract), never\n * throws. A plain object with getters — no `Proxy` — because the handle has a\n * fixed method set and is deliberately not number-coercible.\n *\n * @since 1.3\n * @stable\n * @example\n * // const handle = buildArrayHandle(new ArrayStateSlot(4));\n * // handle.push(1);\n * // handle.last(); // 1\n */\nexport function buildArrayHandle(slot: ArrayStateSlot): MutableArraySlot<number> {\n return {\n push(value: number): void {\n slot.tentativeRing.append(value);\n },\n get(n: number): number {\n return slot.tentativeRing.at(n);\n },\n last(): number {\n return slot.tentativeRing.at(0);\n },\n clear(): void {\n slot.tentativeRing.reset();\n },\n get size(): number {\n return slot.tentativeRing.length;\n },\n get capacity(): number {\n return slot.capacity;\n },\n };\n}\n\n/**\n * Allocate a fresh {@link ArrayStateSlot} — both rings empty (`size === 0`).\n * Unlike `state.float(init)` there is no seed value: an empty collection starts\n * empty.\n *\n * @since 1.3\n * @stable\n * @example\n * // const slot = createArrayStateSlot(20);\n * // slot.handle.size; // 0\n */\nexport function createArrayStateSlot(capacity: number): ArrayStateSlot {\n return new ArrayStateSlot(capacity);\n}\n\n/**\n * Rebuild an {@link ArrayStateSlot} from already-restored rings (snapshot\n * path). The handle identity is recreated — acceptable, same as\n * `state.series` / `ta.*` restore.\n *\n * @since 1.3\n * @stable\n * @example\n * // const slot = restoreArrayStateSlot(committedRing, tentativeRing);\n * // slot.handle.size;\n */\nexport function restoreArrayStateSlot(\n committedRing: Float64RingBuffer,\n tentativeRing: Float64RingBuffer,\n): ArrayStateSlot {\n const slot = new ArrayStateSlot(committedRing.capacity);\n slot.committedRing.copyFrom(committedRing);\n slot.tentativeRing.copyFrom(tentativeRing);\n return slot;\n}\n"]}
|
package/dist/state/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { isArraySlotSnapshotKey, restoreArraySlots, serialiseArraySlots, } from "./arrayPersistence.js";
|
|
2
|
+
export { ArrayStateSlot } from "./arrayStateSlot.js";
|
|
3
|
+
export { advanceSeriesSlots, commitArraySlots, commitSeriesSlots, commitStateSlots, flushStateSlots, resetSeriesHeads, resetTentativeArraySlots, restoreStateSlots, resetTentativeStateSlots, serialiseStateSlots, } from "./lifecycle.js";
|
|
2
4
|
export type { StateSlotSnapshot } from "./lifecycle.js";
|
|
3
5
|
export { isSeriesSlotSnapshotKey, restoreSeriesSlots, serialiseSeriesSlots, } from "./seriesPersistence.js";
|
|
4
6
|
export { buildStateNamespace } from "./stateNamespace.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/state/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
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
|
-
export {
|
|
3
|
+
export { isArraySlotSnapshotKey, restoreArraySlots, serialiseArraySlots, } from "./arrayPersistence.js";
|
|
4
|
+
export { ArrayStateSlot } from "./arrayStateSlot.js";
|
|
5
|
+
export { advanceSeriesSlots, commitArraySlots, commitSeriesSlots, commitStateSlots, flushStateSlots, resetSeriesHeads, resetTentativeArraySlots, restoreStateSlots, resetTentativeStateSlots, serialiseStateSlots, } from "./lifecycle.js";
|
|
4
6
|
export { isSeriesSlotSnapshotKey, restoreSeriesSlots, serialiseSeriesSlots, } from "./seriesPersistence.js";
|
|
5
7
|
export { buildStateNamespace } from "./stateNamespace.js";
|
|
6
8
|
export { asMutableSlot, StateSlot } from "./stateSlot.js";
|
package/dist/state/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EACH,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,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 {\n advanceSeriesSlots,\n commitSeriesSlots,\n commitStateSlots,\n flushStateSlots,\n resetSeriesHeads,\n restoreStateSlots,\n resetTentativeStateSlots,\n serialiseStateSlots,\n} from \"./lifecycle.js\";\nexport type { StateSlotSnapshot } from \"./lifecycle.js\";\nexport {\n isSeriesSlotSnapshotKey,\n restoreSeriesSlots,\n serialiseSeriesSlots,\n} from \"./seriesPersistence.js\";\nexport { buildStateNamespace } from \"./stateNamespace.js\";\nexport type { StateSlotSerialisers } from \"./stateSlot.js\";\nexport { asMutableSlot, StateSlot } from \"./stateSlot.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EACH,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,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 {\n isArraySlotSnapshotKey,\n restoreArraySlots,\n serialiseArraySlots,\n} from \"./arrayPersistence.js\";\nexport { ArrayStateSlot } from \"./arrayStateSlot.js\";\nexport {\n advanceSeriesSlots,\n commitArraySlots,\n commitSeriesSlots,\n commitStateSlots,\n flushStateSlots,\n resetSeriesHeads,\n resetTentativeArraySlots,\n restoreStateSlots,\n resetTentativeStateSlots,\n serialiseStateSlots,\n} from \"./lifecycle.js\";\nexport type { StateSlotSnapshot } from \"./lifecycle.js\";\nexport {\n isSeriesSlotSnapshotKey,\n restoreSeriesSlots,\n serialiseSeriesSlots,\n} from \"./seriesPersistence.js\";\nexport { buildStateNamespace } from \"./stateNamespace.js\";\nexport type { StateSlotSerialisers } from \"./stateSlot.js\";\nexport { asMutableSlot, StateSlot } from \"./stateSlot.js\";\n"]}
|
|
@@ -112,4 +112,32 @@ export declare function commitSeriesSlots(ctx: RuntimeContext): void;
|
|
|
112
112
|
* void reset;
|
|
113
113
|
*/
|
|
114
114
|
export declare function resetSeriesHeads(ctx: RuntimeContext): void;
|
|
115
|
+
/**
|
|
116
|
+
* Roll every `state.array` slot's tentative ring back to its committed ring
|
|
117
|
+
* before tick compute, so a head-replacing tick discards in-progress pushes
|
|
118
|
+
* (and a tick without a push reads the committed collection). Runs once per
|
|
119
|
+
* tick, before compute, next to {@link resetSeriesHeads}. There is no advance —
|
|
120
|
+
* the array changes only when the author pushes.
|
|
121
|
+
*
|
|
122
|
+
* @since 1.3
|
|
123
|
+
* @stable
|
|
124
|
+
* @example
|
|
125
|
+
* // resetTentativeArraySlots(ctx);
|
|
126
|
+
* const reset = true;
|
|
127
|
+
* void reset;
|
|
128
|
+
*/
|
|
129
|
+
export declare function resetTentativeArraySlots(ctx: RuntimeContext): void;
|
|
130
|
+
/**
|
|
131
|
+
* Commit every `state.array` slot's tentative ring into its committed ring
|
|
132
|
+
* after close compute, so the next tick can roll back to it. Runs once per
|
|
133
|
+
* close, after compute, next to {@link commitSeriesSlots}.
|
|
134
|
+
*
|
|
135
|
+
* @since 1.3
|
|
136
|
+
* @stable
|
|
137
|
+
* @example
|
|
138
|
+
* // commitArraySlots(ctx);
|
|
139
|
+
* const committed = true;
|
|
140
|
+
* void committed;
|
|
141
|
+
*/
|
|
142
|
+
export declare function commitArraySlots(ctx: RuntimeContext): void;
|
|
115
143
|
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/state/lifecycle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IAC/B,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;CACzB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAIlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAI1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAOzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAS1F;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC7B,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACzC,IAAI,CAKN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAI5D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAI3D;AAED;;;;;;;;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gB,wBAAwB,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAIlE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAI1D"}
|
package/dist/state/lifecycle.js
CHANGED
|
@@ -137,4 +137,40 @@ export function resetSeriesHeads(ctx) {
|
|
|
137
137
|
resetSeriesSlotHead(slot);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Roll every `state.array` slot's tentative ring back to its committed ring
|
|
142
|
+
* before tick compute, so a head-replacing tick discards in-progress pushes
|
|
143
|
+
* (and a tick without a push reads the committed collection). Runs once per
|
|
144
|
+
* tick, before compute, next to {@link resetSeriesHeads}. There is no advance —
|
|
145
|
+
* the array changes only when the author pushes.
|
|
146
|
+
*
|
|
147
|
+
* @since 1.3
|
|
148
|
+
* @stable
|
|
149
|
+
* @example
|
|
150
|
+
* // resetTentativeArraySlots(ctx);
|
|
151
|
+
* const reset = true;
|
|
152
|
+
* void reset;
|
|
153
|
+
*/
|
|
154
|
+
export function resetTentativeArraySlots(ctx) {
|
|
155
|
+
for (const slot of ctx.arraySlots.values()) {
|
|
156
|
+
slot.onBarTick();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Commit every `state.array` slot's tentative ring into its committed ring
|
|
161
|
+
* after close compute, so the next tick can roll back to it. Runs once per
|
|
162
|
+
* close, after compute, next to {@link commitSeriesSlots}.
|
|
163
|
+
*
|
|
164
|
+
* @since 1.3
|
|
165
|
+
* @stable
|
|
166
|
+
* @example
|
|
167
|
+
* // commitArraySlots(ctx);
|
|
168
|
+
* const committed = true;
|
|
169
|
+
* void committed;
|
|
170
|
+
*/
|
|
171
|
+
export function commitArraySlots(ctx) {
|
|
172
|
+
for (const slot of ctx.arraySlots.values()) {
|
|
173
|
+
slot.onBarClose();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
140
176
|
//# sourceMappingURL=lifecycle.js.map
|