@invinite-org/chartlang-host-worker 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,105 @@
1
1
  # @invinite-org/chartlang-host-worker
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 71ea0a5: Inline original TypeScript sources into emitted `.js.map` files (`inlineSources: true`). Published sourcemaps no longer reference missing `../src/*.ts` files, fixing "points to missing source files" warnings in downstream bundlers (e.g. Vite).
8
+ - Updated dependencies [71ea0a5]
9
+ - @invinite-org/chartlang-adapter-kit@1.2.1
10
+ - @invinite-org/chartlang-core@1.1.1
11
+ - @invinite-org/chartlang-runtime@1.1.1
12
+
13
+ ## 1.1.0
14
+
15
+ ### Minor Changes
16
+
17
+ - 2123181: Hosts (`host-worker`, `host-quickjs`) detect the array-shape `__manifest`
18
+ sidecar plus the new `__dependencies` export, mount the compiled
19
+ `CompiledScriptBundle`, and round-trip the six `dep-*` diagnostic codes
20
+ across both the postMessage wire and the QuickJS JSON membrane.
21
+ `host-worker`'s `CompiledModuleExport` type widens to carry the optional
22
+ `__manifest` / `__dependencies` sidecars; `host-quickjs`'s
23
+ `moduleSourceToScript` rewrites every drawn named export onto a
24
+ host-visible `globalThis.__chartlang_compiled_named` map and lowers
25
+ `__dependencies` onto its own global slot. `adapter-kit`'s
26
+ `validateEmission` confirmed (with explicit coverage) to accept every
27
+ new code. canvas2d-adapter integration test renders sibling-prefixed
28
+ plots, drops private-dep plots, and surfaces `dep-error` diagnostics
29
+ through `Adapter.onEmissions`. The compiler now appends
30
+ `export const __dependencies = [...]` to multi-export bundle output so
31
+ the runtime can mount each private dep as a `DepRunner`; single-script
32
+ bundles stay byte-identical (no `__dependencies` line).
33
+ - 2123181: Indicator composition (Phase 7 closeout): one chartlang indicator can
34
+ read another indicator's titled plot output as a typed `Series<number>`.
35
+
36
+ - Compose via local `const` binding plus `<binding>.output("title")` —
37
+ no new public API beyond the chainable `.output` / `.withInputs`
38
+ accessors on `CompiledScriptObject`.
39
+ - A single `.chart.ts` MAY declare a default export plus any number of
40
+ named exports plus any number of private `const` deps. Export form
41
+ determines render policy: drawn exports render with the
42
+ `export:<exportName>/` slot-id prefix; private `const` deps are data
43
+ feeds only and their visuals are dropped.
44
+ - Cross-file `import baseTrend from "./base-trend.chart"` resolves
45
+ recursively; shared producers inline exactly once per consumer.
46
+ - Additive within `apiVersion: 1.x`. The 172-entry
47
+ `STATEFUL_PRIMITIVES` set is unchanged. `DiagnosticCode` widens to 32
48
+ with the new `dep-*` codes (`dep-error`, `dep-cycle`,
49
+ `dep-unknown-output`, `dep-invalid-input-override`, `dep-dynamic`,
50
+ `dep-output-not-titled`).
51
+ - Five conformance scenarios in `@invinite-org/chartlang-conformance`
52
+ pin the runtime contract end-to-end (`dep-private-single-file`,
53
+ `dep-multi-export`, `dep-cross-file`, `dep-diamond`,
54
+ `dep-error-halts-parent`). `Scenario.additionalSources` lets
55
+ cross-file scenarios ship producer + consumer side-by-side.
56
+ - Two new example scripts in `examples/scripts/`:
57
+ `base-trend.chart.ts` (producer) + `trend-confirmation.chart.ts`
58
+ (multi-export consumer). React-demo gains a fifth catalogue entry
59
+ exercising the feature end-to-end in the browser.
60
+ - Docs: `docs/language/indicator-composition.md` narrative guide,
61
+ `docs/spec/manifest.md` + `docs/spec/semantics.md` +
62
+ `docs/spec/versioning.md` updates, five new glossary entries.
63
+
64
+ - 2123181: Light up the end-to-end cross-file dep path for indicator composition. The
65
+ compiler's `rewriteDependencyAccessors` transformer now collapses
66
+ `const <alias> = <root>.withInputs({...})...` chains to the bare root
67
+ identifier so the runtime sentinel never fires at module load; the merged
68
+ effective inputs flow through the `__dependencies[i].inputOverrides` slot
69
+ into the runtime's `DepRunner`. Cross-file producers' `@invinite-org/chartlang-core`
70
+ imports are hoisted above the inlined IIFE so esbuild dedupes them against
71
+ the consumer's imports and pulls in every symbol the producer uses
72
+ (`input.int`, `ta.ema`, …). The `__dependencies` export is now prepended
73
+ pre-bundle so esbuild's tree-shaker keeps each alias binding alive. The
74
+ `dep-cross-file` conformance scenario joins `ALL_SCENARIOS` and the suite
75
+ runs 225 scenarios green.
76
+ - 4d77f4d: Apply host-supplied plot overrides at emit time and add a live `setPlotOverrides` channel. The runtime resolves an initial `plotOverrides` map at mount (`args.plotOverrides ?? args.resolvePlotOverrides?.(...)`), applies the matching `PlotOverride` to every `PlotEmission` by `slotId` via the new pure `applyPlotOverride` helper (visibility / color / line width / line style for line-family kinds; silent no-op otherwise), and exposes `ScriptRunner.setPlotOverrides(next)` for a recompute-free live swap. Both `host-worker` and `host-quickjs` forward an initial `plotOverrides` on the `load` frame (mirroring `inputOverrides`) and relay a new `setPlotOverrides` host→guest frame; `ScriptHost.setPlotOverrides(...)` is added for cross-host parity. Fully additive: with no overrides supplied, every emission is byte-identical to before (the `visible` field is omitted unless a slot is explicitly hidden).
77
+
78
+ ### Patch Changes
79
+
80
+ - 2123181: Structured `StateSnapshot` carrying per-runner slot sections (primary +
81
+ siblings + dependencies) so a `CompiledScriptBundle`'s cold-replay
82
+ emissions match its warm-restart emissions byte-identically. Slot keys
83
+ now carry the active runner's `slotIdPrefix` everywhere they reach a
84
+ `StateStore` (`dep:<localId>/` for deps, `export:<exportName>/` for
85
+ siblings, empty for the primary). Flat-shape snapshots from before this
86
+ release continue to load back-compat as primary-only.
87
+ - Updated dependencies [d6d1a1f]
88
+ - Updated dependencies [f0c8eb8]
89
+ - Updated dependencies [2123181]
90
+ - Updated dependencies [2123181]
91
+ - Updated dependencies [2123181]
92
+ - Updated dependencies [2123181]
93
+ - Updated dependencies [2123181]
94
+ - Updated dependencies [4d77f4d]
95
+ - Updated dependencies [4d77f4d]
96
+ - Updated dependencies [3b4952d]
97
+ - Updated dependencies [0427459]
98
+ - Updated dependencies [0427459]
99
+ - @invinite-org/chartlang-core@1.1.0
100
+ - @invinite-org/chartlang-adapter-kit@1.2.0
101
+ - @invinite-org/chartlang-runtime@1.1.0
102
+
3
103
  ## 1.0.1
4
104
 
5
105
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"createWorkerBoot.d.ts","sourceRoot":"","sources":["../src/createWorkerBoot.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGhE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5F,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAAC;CACxC,CAAC;AAiBF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAkF7D"}
1
+ {"version":3,"file":"createWorkerBoot.d.ts","sourceRoot":"","sources":["../src/createWorkerBoot.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGhE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5F,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAAC;CACxC,CAAC;AA2EF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CA6F7D"}
@@ -17,6 +17,58 @@ function isFrame(value) {
17
17
  const k = value.kind;
18
18
  return typeof k === "string";
19
19
  }
20
+ function isCompiledScriptObject(v) {
21
+ if (v === null || typeof v !== "object")
22
+ return false;
23
+ const o = v;
24
+ return typeof o.compute === "function" && typeof o.manifest === "object" && o.manifest !== null;
25
+ }
26
+ /**
27
+ * Bridge a dynamically-imported compiled module into the runtime's
28
+ * single-or-bundle compiled-script shape. Detects the §22.10
29
+ * indicator-composition bundle by either (a) the array form of
30
+ * `__manifest` or (b) a non-empty `__dependencies` export — both are
31
+ * additive over the Phase-1 single-script wire format. Single-script
32
+ * callers see the same `mod.default` `CompiledScriptObject` they did
33
+ * before, byte-identical.
34
+ *
35
+ * Sibling exports are recovered by reading each non-`default` manifest
36
+ * entry's `exportName` off the array sidecar and pulling the matching
37
+ * named export off the module namespace object. Entries the local
38
+ * `isCompiledScriptObject` guard rejects are skipped silently so a
39
+ * malformed bundle still loads its primary script.
40
+ */
41
+ function buildBundleFromModule(mod) {
42
+ const manifest = mod.__manifest;
43
+ const dependencies = mod.__dependencies ?? [];
44
+ const isBundle = Array.isArray(manifest) || dependencies.length > 0;
45
+ if (!isBundle) {
46
+ return mod.default;
47
+ }
48
+ const siblings = [];
49
+ if (Array.isArray(manifest)) {
50
+ for (let i = 1; i < manifest.length; i += 1) {
51
+ const entry = manifest[i];
52
+ const exportName = entry.exportName;
53
+ if (exportName === undefined || exportName === "default")
54
+ continue;
55
+ const compiled = mod[exportName];
56
+ if (!isCompiledScriptObject(compiled))
57
+ continue;
58
+ siblings.push(Object.freeze({ exportName, compiled }));
59
+ }
60
+ }
61
+ const frozenDeps = dependencies.map((d) => Object.freeze({
62
+ localId: d.localId,
63
+ compiled: d.compiled,
64
+ ...(d.inputOverrides === undefined ? {} : { inputOverrides: d.inputOverrides }),
65
+ }));
66
+ return Object.freeze({
67
+ primary: mod.default,
68
+ siblings: Object.freeze(siblings),
69
+ dependencies: Object.freeze(frozenDeps),
70
+ });
71
+ }
20
72
  /**
21
73
  * Wire `scope` to the host-worker postMessage protocol. Lazily imports the
22
74
  * compiled module via a `data:` URL so the same code path runs inside a real
@@ -56,13 +108,17 @@ export function createWorkerBoot(scope) {
56
108
  if (msg.kind === "load") {
57
109
  try {
58
110
  const mod = await importCompiledModule(msg.compiled.moduleSource);
111
+ const compiled = buildBundleFromModule(mod);
59
112
  runner = createScriptRunner({
60
- compiled: mod.default,
113
+ compiled,
61
114
  capabilities: msg.capabilities,
62
115
  ...(msg.symInfo !== undefined ? { symInfo: msg.symInfo } : {}),
63
116
  ...(msg.inputOverrides !== undefined
64
117
  ? { inputOverrides: msg.inputOverrides }
65
118
  : {}),
119
+ ...(msg.plotOverrides !== undefined
120
+ ? { plotOverrides: msg.plotOverrides }
121
+ : {}),
66
122
  });
67
123
  limits = msg.limits;
68
124
  scope.postMessage({ kind: "loaded" });
@@ -88,6 +144,13 @@ export function createWorkerBoot(scope) {
88
144
  }
89
145
  break;
90
146
  }
147
+ case "setPlotOverrides": {
148
+ if (runner === null) {
149
+ throw new Error("setPlotOverrides before load");
150
+ }
151
+ runner.setPlotOverrides(msg.overrides);
152
+ break;
153
+ }
91
154
  case "drain": {
92
155
  if (runner === null) {
93
156
  throw new Error("drain before load");
@@ -1 +1 @@
1
- {"version":3,"file":"createWorkerBoot.js","sourceRoot":"","sources":["../src/createWorkerBoot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAuBxC,KAAK,UAAU,oBAAoB,CAAC,YAAoB;IACpD,sEAAsE;IACtE,oEAAoE;IACpE,oEAAoE;IACpE,gBAAgB;IAChB,MAAM,GAAG,GAAG,sCAAsC,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;IACrF,OAAO,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAyB,CAAC;AAC1E,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC3B,IAAI,KAAK,KAA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AI,CAAC;oBACd,MAAM;gBACV,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACN,MAAM,IAAI,KAAK,CACX,uBAAwB,GAAiC,CAAC,IAAI,EAAE,CACnE,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,KAAK,CAAC,WAAW,CAAC;gBACd,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aAC5D,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { CompiledScriptBundle, CompiledScriptObject } from \"@invinite-org/chartlang-core\";\nimport { createScriptRunner } from \"@invinite-org/chartlang-runtime\";\n\nimport { filterEmissions } from \"./filterEmissions.js\";\nimport { watchStep } from \"./limits.js\";\nimport type { HostToWorker, WorkerToHost } from \"./protocol.js\";\nimport type { CompiledModuleExport, HostLimits, ScriptRunnerHandle } from \"./types.js\";\n\n/**\n * Duck-typed slice of the worker global scope the boot factory needs. Lets\n * tests drive `createWorkerBoot` against a `MessageChannel` port without\n * faking the full `WorkerGlobalScope`.\n *\n * @since 0.1\n * @stable\n * @example\n * const scope: WorkerBootScope = {\n * addEventListener: () => {},\n * postMessage: () => {},\n * };\n * void scope;\n */\nexport type WorkerBootScope = {\n addEventListener(type: \"message\", listener: (ev: MessageEvent<HostToWorker>) => void): void;\n postMessage(msg: WorkerToHost): void;\n};\n\nasync function importCompiledModule(moduleSource: string): Promise<CompiledModuleExport> {\n // `encodeURIComponent` preserves multi-byte UTF-8 across the data URL\n // without the Annex-B `unescape` round-trip. ESM `import(\"data:…\")`\n // accepts percent-encoded text/javascript directly in both browsers\n // and Node 20+.\n const url = `data:text/javascript;charset=utf-8,${encodeURIComponent(moduleSource)}`;\n return (await import(/* @vite-ignore */ url)) as CompiledModuleExport;\n}\n\nfunction isFrame(value: unknown): value is HostToWorker {\n if (value === null || typeof value !== \"object\") return false;\n const k = (value as { readonly kind?: unknown }).kind;\n return typeof k === \"string\";\n}\n\nfunction isCompiledScriptObject(v: unknown): v is CompiledScriptObject {\n if (v === null || typeof v !== \"object\") return false;\n const o = v as { readonly compute?: unknown; readonly manifest?: unknown };\n return typeof o.compute === \"function\" && typeof o.manifest === \"object\" && o.manifest !== null;\n}\n\n/**\n * Bridge a dynamically-imported compiled module into the runtime's\n * single-or-bundle compiled-script shape. Detects the §22.10\n * indicator-composition bundle by either (a) the array form of\n * `__manifest` or (b) a non-empty `__dependencies` export — both are\n * additive over the Phase-1 single-script wire format. Single-script\n * callers see the same `mod.default` `CompiledScriptObject` they did\n * before, byte-identical.\n *\n * Sibling exports are recovered by reading each non-`default` manifest\n * entry's `exportName` off the array sidecar and pulling the matching\n * named export off the module namespace object. Entries the local\n * `isCompiledScriptObject` guard rejects are skipped silently so a\n * malformed bundle still loads its primary script.\n */\nfunction buildBundleFromModule(\n mod: CompiledModuleExport,\n): CompiledScriptObject | CompiledScriptBundle {\n const manifest = mod.__manifest;\n const dependencies = mod.__dependencies ?? [];\n const isBundle = Array.isArray(manifest) || dependencies.length > 0;\n if (!isBundle) {\n return mod.default;\n }\n const siblings: Array<{\n readonly exportName: string;\n readonly compiled: CompiledScriptObject;\n }> = [];\n if (Array.isArray(manifest)) {\n for (let i = 1; i < manifest.length; i += 1) {\n const entry = manifest[i];\n const exportName = entry.exportName;\n if (exportName === undefined || exportName === \"default\") continue;\n const compiled = mod[exportName];\n if (!isCompiledScriptObject(compiled)) continue;\n siblings.push(Object.freeze({ exportName, compiled }));\n }\n }\n const frozenDeps = dependencies.map((d) =>\n Object.freeze({\n localId: d.localId,\n compiled: d.compiled,\n ...(d.inputOverrides === undefined ? {} : { inputOverrides: d.inputOverrides }),\n }),\n );\n return Object.freeze({\n primary: mod.default,\n siblings: Object.freeze(siblings),\n dependencies: Object.freeze(frozenDeps),\n });\n}\n\n/**\n * Wire `scope` to the host-worker postMessage protocol. Lazily imports the\n * compiled module via a `data:` URL so the same code path runs inside a real\n * browser `Worker` and inside Node tests (`MessageChannel`-backed).\n *\n * Lifecycle:\n *\n * - `load` → dynamic import → `createScriptRunner(...)` → cache `limits`.\n * Posts `loaded` on success or `loadError` on failure.\n * - `candleEvent` → wrap dispatch in `watchStep(...)`; post `step-overshoot`\n * when over budget. Errors map to `fatal`.\n * - `drain` → validate every plot / alert emission; sink malformed ones into\n * the diagnostics array; post `emissions` with the original nonce.\n * - `dispose` → release the runner; subsequent messages map to `fatal`.\n *\n * @since 0.1\n * @stable\n * @example\n * // import { createWorkerBoot } from \"@invinite-org/chartlang-host-worker\";\n * // const scope = self;\n * // createWorkerBoot(scope);\n * const fn: typeof createWorkerBoot = createWorkerBoot;\n * void fn;\n */\nexport function createWorkerBoot(scope: WorkerBootScope): void {\n let runner: ScriptRunnerHandle | null = null;\n let limits: HostLimits | null = null;\n\n scope.addEventListener(\"message\", async (ev: MessageEvent<HostToWorker>) => {\n const msg = ev.data;\n if (!isFrame(msg)) {\n scope.postMessage({\n kind: \"fatal\",\n message: \"malformed host frame: not a plain object with a string 'kind'\",\n });\n return;\n }\n if (msg.kind === \"load\") {\n try {\n const mod = await importCompiledModule(msg.compiled.moduleSource);\n const compiled = buildBundleFromModule(mod);\n runner = createScriptRunner({\n compiled,\n capabilities: msg.capabilities,\n ...(msg.symInfo !== undefined ? { symInfo: msg.symInfo } : {}),\n ...(msg.inputOverrides !== undefined\n ? { inputOverrides: msg.inputOverrides }\n : {}),\n ...(msg.plotOverrides !== undefined\n ? { plotOverrides: msg.plotOverrides }\n : {}),\n });\n limits = msg.limits;\n scope.postMessage({ kind: \"loaded\" });\n } catch (err) {\n scope.postMessage({\n kind: \"loadError\",\n message: err instanceof Error ? err.message : String(err),\n });\n }\n return;\n }\n\n try {\n switch (msg.kind) {\n case \"candleEvent\": {\n if (runner === null || limits === null) {\n throw new Error(\"candleEvent before load\");\n }\n const r = runner;\n const { overshoot } = await watchStep(\n () => r.push(msg.event),\n limits.maxCpuMsPerStep,\n );\n if (overshoot > 0) {\n scope.postMessage({ kind: \"step-overshoot\", observedMs: overshoot });\n }\n break;\n }\n case \"setPlotOverrides\": {\n if (runner === null) {\n throw new Error(\"setPlotOverrides before load\");\n }\n runner.setPlotOverrides(msg.overrides);\n break;\n }\n case \"drain\": {\n if (runner === null) {\n throw new Error(\"drain before load\");\n }\n const cleaned = filterEmissions(runner.drain());\n scope.postMessage({\n kind: \"emissions\",\n nonce: msg.nonce,\n emissions: cleaned,\n });\n break;\n }\n case \"dispose\": {\n await runner?.dispose();\n runner = null;\n limits = null;\n break;\n }\n default: {\n throw new Error(\n `unknown frame kind: ${(msg as { readonly kind: string }).kind}`,\n );\n }\n }\n } catch (err) {\n scope.postMessage({\n kind: \"fatal\",\n message: err instanceof Error ? err.message : String(err),\n });\n }\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { AdapterSymInfo, Capabilities } from "@invinite-org/chartlang-adapter-kit";
1
+ import type { AdapterSymInfo, Capabilities, PlotOverride } from "@invinite-org/chartlang-adapter-kit";
2
2
  import type { HostLimits, ScriptHost, WorkerLike } from "./types.js";
3
3
  /**
4
4
  * Constructor options for {@link createWorkerHost}.
@@ -8,6 +8,9 @@ import type { HostLimits, ScriptHost, WorkerLike } from "./types.js";
8
8
  * - `symInfo` — optional adapter-supplied metadata for runtime `syminfo.*`.
9
9
  * - `resolveInputs` — optional adapter callback. The host resolves it during
10
10
  * `load()` and sends the plain override record to the worker.
11
+ * - `resolvePlotOverrides` — optional adapter callback for the initial per-slot
12
+ * presentation overrides. Resolved during `load()`; the plain record is sent
13
+ * to the worker beside `inputOverrides`.
11
14
  * - `workerLike` — injection seam for tests. Production callers omit it; the
12
15
  * host then constructs a real `Worker` via {@link defaultWorkerFactory}.
13
16
  * - `limits` — partial `HostLimits` overrides; missing fields fall through to
@@ -28,6 +31,7 @@ export type CreateWorkerHostOpts = {
28
31
  readonly capabilities: Capabilities;
29
32
  readonly symInfo?: AdapterSymInfo;
30
33
  readonly resolveInputs?: (scriptId: string) => Readonly<Record<string, unknown>>;
34
+ readonly resolvePlotOverrides?: (scriptId: string) => Readonly<Record<string, PlotOverride>>;
31
35
  readonly workerLike?: WorkerLike;
32
36
  readonly limits?: Partial<HostLimits>;
33
37
  readonly onWorkerError?: (message: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"createWorkerHost.d.ts","sourceRoot":"","sources":["../src/createWorkerHost.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,cAAc,EACd,YAAY,EAEf,MAAM,qCAAqC,CAAC;AAK7C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAoB,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjF,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD,CAAC;AAaF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,UAAU,CA+IvE"}
1
+ {"version":3,"file":"createWorkerHost.d.ts","sourceRoot":"","sources":["../src/createWorkerHost.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,cAAc,EACd,YAAY,EACZ,YAAY,EAEf,MAAM,qCAAqC,CAAC;AAK7C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAoB,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjF,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAC7F,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD,CAAC;AAaF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,UAAU,CAsJvE"}
@@ -133,6 +133,9 @@ export function createWorkerHost(opts) {
133
133
  ...(opts.resolveInputs !== undefined
134
134
  ? { inputOverrides: opts.resolveInputs(compiled.manifest.name) }
135
135
  : {}),
136
+ ...(opts.resolvePlotOverrides !== undefined
137
+ ? { plotOverrides: opts.resolvePlotOverrides(compiled.manifest.name) }
138
+ : {}),
136
139
  limits,
137
140
  };
138
141
  worker.postMessage(frame);
@@ -143,6 +146,10 @@ export function createWorkerHost(opts) {
143
146
  worker.postMessage(frame);
144
147
  return Promise.resolve();
145
148
  },
149
+ setPlotOverrides(overrides) {
150
+ const frame = { kind: "setPlotOverrides", overrides };
151
+ worker.postMessage(frame);
152
+ },
146
153
  drain() {
147
154
  const n = nonceCounter;
148
155
  nonceCounter += 1;
@@ -1 +1 @@
1
- {"version":3,"file":"createWorkerHost.js","sourceRoot":"","sources":["../src/createWorkerHost.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAQ/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAqC7C,SAAS,YAAY,CAAC,CAAa;IAC/B,OAAO,OAAO,CAAC,CAAC,SAAS,KAAK,UAAU,CAAC;AAC7C,CAAC;AAED,SAAS,mBAAmB,CAAC,EAAoB;IAC7C,IAAI,OAAO,EAAE,CAAC,OAAO,KAAK,QAAQ,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC,OAAO,CAAC;IAC/E,IAAI,EAAE,CAAC,KAAK,YAAY,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;IACtF,IAAI,OAAO,EAAE,CAAC,KAAK,KAAK,QAAQ,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC,KAAK,CAAC;IACzE,OAAO,sBAAsB,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAA0B;IACvD,MAAM,MAAM,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAChF,0EAA0E;IAC1E,mEAAmE;IACnE,mEAAmE;IACnE,iDAAiD;IACjD,oBAAoB;IACpB,MAAM,MAAM,G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AAW,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;QACP,CAAC;QACD,OAAO;YACH,MAAM,KAAK,GAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;YAChD,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;gBACvB,MAAM,CAAC,SAAS,EAAE,CAAC;YACvB,CAAC;YACD,gBAAgB,EAAE,CAAC;YACnB,aAAa,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM;KACT,CAAC,CAAC;AACP,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type {\n AdapterSymInfo,\n Capabilities,\n PlotOverride,\n RunnerEmissions,\n} from \"@invinite-org/chartlang-adapter-kit\";\n\nimport { defaultWorkerFactory } from \"./defaultWorkerFactory.js\";\nimport { DEFAULT_LIMITS } from \"./limits.js\";\nimport type { HostToWorker, WorkerToHost } from \"./protocol.js\";\nimport type { HostLimits, ScriptHost, WorkerErrorEvent, WorkerLike } from \"./types.js\";\n\n/**\n * Constructor options for {@link createWorkerHost}.\n *\n * - `capabilities` — the adapter's declared capability bag. Bolted onto every\n * `load` postMessage; the worker boot never falls back to a default.\n * - `symInfo` — optional adapter-supplied metadata for runtime `syminfo.*`.\n * - `resolveInputs` — optional adapter callback. The host resolves it during\n * `load()` and sends the plain override record to the worker.\n * - `resolvePlotOverrides` — optional adapter callback for the initial per-slot\n * presentation overrides. Resolved during `load()`; the plain record is sent\n * to the worker beside `inputOverrides`.\n * - `workerLike` — injection seam for tests. Production callers omit it; the\n * host then constructs a real `Worker` via {@link defaultWorkerFactory}.\n * - `limits` — partial `HostLimits` overrides; missing fields fall through to\n * {@link DEFAULT_LIMITS}.\n * - `onWorkerError` — called when the worker posts `step-overshoot` or\n * `fatal`. The host does not synthesize diagnostics into the next\n * `drain()` — Phase 1 keeps overshoot surfacing on the adapter.\n *\n * @since 0.1\n * @stable\n * @example\n * const opts: CreateWorkerHostOpts = {\n * capabilities: {} as Capabilities,\n * };\n * void opts;\n */\nexport type CreateWorkerHostOpts = {\n readonly capabilities: Capabilities;\n readonly symInfo?: AdapterSymInfo;\n readonly resolveInputs?: (scriptId: string) => Readonly<Record<string, unknown>>;\n readonly resolvePlotOverrides?: (scriptId: string) => Readonly<Record<string, PlotOverride>>;\n readonly workerLike?: WorkerLike;\n readonly limits?: Partial<HostLimits>;\n readonly onWorkerError?: (message: string) => void;\n};\n\nfunction hasTerminate(w: WorkerLike): w is WorkerLike & { terminate: () => void } {\n return typeof w.terminate === \"function\";\n}\n\nfunction describeWorkerError(ev: WorkerErrorEvent): string {\n if (typeof ev.message === \"string\" && ev.message.length > 0) return ev.message;\n if (ev.error instanceof Error && ev.error.message.length > 0) return ev.error.message;\n if (typeof ev.error === \"string\" && ev.error.length > 0) return ev.error;\n return \"unknown worker error\";\n}\n\n/**\n * Build a browser-default `ScriptHost` around a Web Worker. The host\n * round-trips `load` / `push` / `drain` / `dispose` calls across the worker\n * boundary via structured-clone-safe postMessage frames defined in\n * {@link HostToWorker} / {@link WorkerToHost}.\n *\n * The host owns the `nonce` counter for `drain` correlation, the in-flight\n * `load` promise, and the in-flight drain registry. `dispose` posts the\n * tear-down message, calls `terminate()` when the underlying `WorkerLike`\n * supports it, and clears the pending-drain map.\n *\n * @since 0.1\n * @stable\n * @example\n * import { createWorkerHost } from \"@invinite-org/chartlang-host-worker\";\n * // const host = createWorkerHost({ capabilities });\n * const fn: typeof createWorkerHost = createWorkerHost;\n * void fn;\n */\nexport function createWorkerHost(opts: CreateWorkerHostOpts): ScriptHost {\n const limits: HostLimits = Object.freeze({ ...DEFAULT_LIMITS, ...opts.limits });\n // The `defaultWorkerFactory` branch is browser-only — tests always inject\n // `workerLike`. Excluded from coverage to keep the production-only\n // `new Worker(...)` path uncounted, consistent with the file-level\n // exclusion of `defaultWorkerFactory.ts` itself.\n /* v8 ignore next */\n const worker: WorkerLike = opts.workerLike ?? defaultWorkerFactory();\n\n let nonceCounter = 0;\n const pendingDrains = new Map<number, (e: RunnerEmissions) => void>();\n let loadedResolve: (() => void) | null = null;\n let loadedReject: ((err: Error) => void) | null = null;\n let loadTimeoutHandle: ReturnType<typeof setTimeout> | null = null;\n // Latches the first worker-level error so a subsequent `load()` call\n // refuses to wait on a dead worker (no `loaded` reply will ever arrive).\n let fatalError: string | null = null;\n\n function clearLoadTimeout(): void {\n if (loadTimeoutHandle !== null) {\n clearTimeout(loadTimeoutHandle);\n loadTimeoutHandle = null;\n }\n }\n\n function failLoad(err: Error): void {\n clearLoadTimeout();\n loadedReject?.(err);\n loadedResolve = null;\n loadedReject = null;\n }\n\n worker.addEventListener(\"message\", (ev: MessageEvent<unknown>) => {\n const msg = ev.data as WorkerToHost;\n switch (msg.kind) {\n case \"loaded\": {\n clearLoadTimeout();\n loadedResolve?.();\n loadedResolve = null;\n loadedReject = null;\n break;\n }\n case \"loadError\": {\n failLoad(new Error(msg.message));\n break;\n }\n case \"emissions\": {\n const resolve = pendingDrains.get(msg.nonce);\n if (resolve !== undefined) {\n pendingDrains.delete(msg.nonce);\n resolve(msg.emissions);\n }\n break;\n }\n case \"step-overshoot\": {\n opts.onWorkerError?.(`step overshoot ${msg.observedMs.toFixed(2)}ms`);\n break;\n }\n case \"fatal\": {\n opts.onWorkerError?.(msg.message);\n break;\n }\n }\n });\n\n // The error channel is fed by browser `Worker`'s `onerror` event.\n // `MessagePort`-backed fakes accept the subscription silently and never\n // fire it, which is the right behaviour: a port doesn't have its own\n // boot/error channel. The cast narrows `addEventListener`'s overload\n // signature to the error variant.\n const addErrorListener = worker.addEventListener as (\n type: \"error\",\n listener: (ev: WorkerErrorEvent) => void,\n ) => void;\n addErrorListener(\"error\", (ev) => {\n const description = describeWorkerError(ev);\n fatalError = description;\n const message = `worker failed to boot: ${description}`;\n failLoad(new Error(message));\n opts.onWorkerError?.(message);\n });\n\n return Object.freeze<ScriptHost>({\n load(compiled) {\n return new Promise<void>((resolve, reject) => {\n if (fatalError !== null) {\n reject(new Error(`worker failed to boot: ${fatalError}`));\n return;\n }\n if (loadedResolve !== null) {\n reject(new Error(\"load() already in flight\"));\n return;\n }\n loadedResolve = resolve;\n loadedReject = reject;\n loadTimeoutHandle = setTimeout(() => {\n failLoad(\n new Error(\n `worker load() timed out after ${limits.maxLoadTimeoutMs}ms — worker never replied with 'loaded'`,\n ),\n );\n }, limits.maxLoadTimeoutMs);\n const frame: HostToWorker = {\n kind: \"load\",\n compiled: {\n moduleSource: compiled.moduleSource,\n manifest: compiled.manifest,\n },\n capabilities: opts.capabilities,\n ...(opts.symInfo !== undefined ? { symInfo: opts.symInfo } : {}),\n ...(opts.resolveInputs !== undefined\n ? { inputOverrides: opts.resolveInputs(compiled.manifest.name) }\n : {}),\n ...(opts.resolvePlotOverrides !== undefined\n ? { plotOverrides: opts.resolvePlotOverrides(compiled.manifest.name) }\n : {}),\n limits,\n };\n worker.postMessage(frame);\n });\n },\n push(event) {\n const frame: HostToWorker = { kind: \"candleEvent\", event };\n worker.postMessage(frame);\n return Promise.resolve();\n },\n setPlotOverrides(overrides) {\n const frame: HostToWorker = { kind: \"setPlotOverrides\", overrides };\n worker.postMessage(frame);\n },\n drain() {\n const n = nonceCounter;\n nonceCounter += 1;\n return new Promise<RunnerEmissions>((resolve) => {\n pendingDrains.set(n, resolve);\n const frame: HostToWorker = { kind: \"drain\", nonce: n };\n worker.postMessage(frame);\n });\n },\n dispose() {\n const frame: HostToWorker = { kind: \"dispose\" };\n worker.postMessage(frame);\n if (hasTerminate(worker)) {\n worker.terminate();\n }\n clearLoadTimeout();\n pendingDrains.clear();\n },\n limits,\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultWorkerFactory.js","sourceRoot":"","sources":["../src/defaultWorkerFactory.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB;IAChC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,OAAO,IAAI,MAAM,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC/C,CAAC"}
1
+ {"version":3,"file":"defaultWorkerFactory.js","sourceRoot":"","sources":["../src/defaultWorkerFactory.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB;IAChC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,OAAO,IAAI,MAAM,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC/C,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 { WorkerLike } from \"./types.js\";\n\n/**\n * Browser-only fallback when `createWorkerHost` is called without an\n * explicit `workerLike`. Constructs a real `Worker` against the bundled\n * `dist/worker-boot.js` sibling. In a real Node test runner `Worker` is not\n * a global so calling this throws a `ReferenceError`; tests always inject a\n * `MessageChannel`-backed `WorkerLike` instead, and the coverage test in\n * `defaultWorkerFactory.test.ts` stubs `globalThis.Worker` to exercise the\n * construction path.\n *\n * @since 0.1\n * @stable\n * @example\n * // const worker = defaultWorkerFactory(); // browser only\n * const fn: typeof defaultWorkerFactory = defaultWorkerFactory;\n * void fn;\n */\nexport function defaultWorkerFactory(): WorkerLike {\n const url = new URL(\"./worker-boot.js\", import.meta.url);\n return new Worker(url, { type: \"module\" });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"filterEmissions.js","sourceRoot":"","sources":["../src/filterEmissions.ts"],"names":[],"mappings":"AAAA,+DAA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,QAAQ,EAAE,SAAS;gBACnB,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,MAAM,EAAE,IAAI;gBACZ,GAAG,EAAE,GAAG,CAAC,GAAG;aACf,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC3B,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO;QACH,KAAK;QACL,QAAQ;QACR,MAAM;QACN,eAAe;QACf,IAAI;QACJ,WAAW;QACX,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,KAAK,EAAE,GAAG,CAAC,KAAK;KACnB,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 {\n type AlertEmission,\n type AlertConditionEmission,\n type DrawingEmission,\n type LogEmission,\n type PlotEmission,\n type RunnerEmissions,\n type RuntimeDiagnostic,\n validateEmission,\n} from \"@invinite-org/chartlang-adapter-kit\";\n\n/**\n * Walk a `RunnerEmissions` snapshot and replace any plot / alert that fails\n * adapter-kit's `validateEmission` with a `malformed-emission` diagnostic.\n * Drawings pass through unchanged in Phase 1 (no `draw.*` primitives ship\n * yet); diagnostics are appended to (never validated against — recursive\n * validation would loop).\n *\n * The boot calls this on every `drain()` before posting `emissions` back to\n * the host; the trust boundary for the postMessage wire format is here.\n *\n * @since 0.1\n * @stable\n * @example\n * // const out = filterEmissions(runner.drain());\n * // postMessage({ kind: \"emissions\", nonce, emissions: out });\n * const fn: typeof filterEmissions = filterEmissions;\n * void fn;\n */\nexport function filterEmissions(raw: RunnerEmissions): RunnerEmissions {\n const plots: Array<PlotEmission> = [];\n const drawings: Array<DrawingEmission> = [];\n const alerts: Array<AlertEmission> = [];\n const alertConditions: Array<AlertConditionEmission> = [];\n const logs: Array<LogEmission> = [];\n const diagnostics: Array<RuntimeDiagnostic> = [...raw.diagnostics];\n\n for (const p of raw.plots) {\n const r = validateEmission(p);\n if (r.ok) {\n plots.push(p);\n } else {\n diagnostics.push({\n kind: \"diagnostic\",\n severity: \"warning\",\n code: r.code,\n message: r.message,\n slotId: p.slotId,\n bar: p.bar,\n });\n }\n }\n for (const a of raw.alerts) {\n const r = validateEmission(a);\n if (r.ok) {\n alerts.push(a);\n } else {\n diagnostics.push({\n kind: \"diagnostic\",\n severity: \"warning\",\n code: r.code,\n message: r.message,\n slotId: a.slotId,\n bar: a.bar,\n });\n }\n }\n for (const condition of raw.alertConditions) {\n const r = validateEmission(condition);\n if (r.ok) {\n alertConditions.push(condition);\n } else {\n diagnostics.push({\n kind: \"diagnostic\",\n severity: \"warning\",\n code: r.code,\n message: r.message,\n slotId: null,\n bar: condition.bar,\n });\n }\n }\n for (const log of raw.logs) {\n const r = validateEmission(log);\n if (r.ok) {\n logs.push(log);\n } else {\n diagnostics.push({\n kind: \"diagnostic\",\n severity: \"warning\",\n code: r.code,\n message: r.message,\n slotId: null,\n bar: log.bar,\n });\n }\n }\n for (const d of raw.drawings) {\n drawings.push(d);\n }\n return {\n plots,\n drawings,\n alerts,\n alertConditions,\n logs,\n diagnostics,\n fromBar: raw.fromBar,\n toBar: raw.toBar,\n };\n}\n"]}
package/dist/idb.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"idb.js","sourceRoot":"","sources":["../src/idb.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"idb.js","sourceRoot":"","sources":["../src/idb.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,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 { idbStateStore } from \"./idbStateStore.js\";\n"]}
@@ -59,7 +59,7 @@ export function idbStateStore(opts) {
59
59
  });
60
60
  }
61
61
  /**
62
- * Stable cache-key serialisation for PLAN.md §6.9 `StateStoreKey`.
62
+ * Stable cache-key serialisation for the `StateStoreKey`.
63
63
  *
64
64
  * @internal
65
65
  */
@@ -1 +1 @@
1
- {"version":3,"file":"idbStateStore.js","sourceRoot":"","sources":["../src/idbStateStore.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAK/D,MAAM,eAAe,GAAG,WAAW,CAAC;AACpC,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3C,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAC1C,MAAM,cAAc,GAAG,SAAS,CAAC;AASjC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAgC,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CACzB,IAIE;IAEF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,eAAe,CAAC;IAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACpD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEzC,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,CAAC,IAAI;YACN,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;YAChC,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;YACpD,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;YACjC,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAChC,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAC9C,CAAC;YACF,MAAM,IAAI,CAAC;YACX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IACjF,IAAI,CAAC,CAAC,eAAe,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,aAAa,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACzF,IAAI,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC7E,IAAI,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,OAAO,CAAC,KAAc,EAAE,QAAgB;IAC7C,IAAI,KAAK,YAAY,YAAY;QAAE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnE,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IACvD,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC/B,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 { StateSnapshot, StateStoreKey } from \"@invinite-org/chartlang-core\";\nimport type { PersistentStateStore } from \"@invinite-org/chartlang-runtime\";\n\nconst DEFAULT_DB_NAME = \"chartlang\";\nconst DEFAULT_CAP_BYTES = 50 * 1024 * 1024;\nconst OBJECT_STORE = \"chartlangSnapshots\";\nconst SAVED_AT_INDEX = \"savedAt\";\n\ntype StoredRecord = Readonly<{\n keyString: string;\n snapshot: StateSnapshot;\n bytesEstimate: number;\n savedAt: number;\n}>;\n\nconst dbPromises = new Map<string, Promise<IDBDatabase>>();\n\n/**\n * IDB-backed {@link PersistentStateStore}. One record per `StateStoreKey`,\n * capped at `capBytes` total with oldest-first eviction by `snapshot.savedAt`.\n * Reads on mount, writes on dispose + 60s cadence; the cadence is enforced by\n * the runtime, not the store. Identity-safe: `load()` returns `null` for any\n * non-matching key, and `clear()` deletes only this key's record.\n *\n * @since 0.5\n * @stable\n * @example\n * // import { idbStateStore } from \"@invinite-org/chartlang-host-worker/idb\";\n * // const store = idbStateStore({ dbName: \"chartlang\", key });\n * // await store.save(snapshot);\n */\nexport function idbStateStore(\n opts: Readonly<{\n key: StateStoreKey;\n dbName?: string;\n capBytes?: number;\n }>,\n): PersistentStateStore {\n const dbName = opts.dbName ?? DEFAULT_DB_NAME;\n const capBytes = opts.capBytes ?? DEFAULT_CAP_BYTES;\n const keyString = stringifyKey(opts.key);\n\n return Object.freeze({\n key: opts.key,\n async load(): Promise<StateSnapshot | null> {\n const db = await openDb(dbName);\n const tx = db.transaction(OBJECT_STORE, \"readonly\");\n const done = transactionDone(tx);\n const value = await requestToPromise<unknown>(\n tx.objectStore(OBJECT_STORE).get(keyString),\n );\n await done;\n return isStoredRecord(value) ? value.snapshot : null;\n },\n async save(snapshot: StateSnapshot): Promise<void> {\n const db = await openDb(dbName);\n const tx = db.transaction(OBJECT_STORE, \"readwrite\");\n const done = transactionDone(tx);\n const store = tx.objectStore(OBJECT_STORE);\n const records = await readAllRecords(store);\n const nextBytes = estimateSnapshotBytes(snapshot);\n await evictUntilUnderCap(store, records, keyString, nextBytes, capBytes);\n await requestToPromise(\n store.put({\n keyString,\n snapshot,\n bytesEstimate: nextBytes,\n savedAt: snapshot.savedAt,\n }),\n );\n await done;\n },\n async clear(): Promise<void> {\n const db = await openDb(dbName);\n const tx = db.transaction(OBJECT_STORE, \"readwrite\");\n const done = transactionDone(tx);\n await requestToPromise(tx.objectStore(OBJECT_STORE).delete(keyString));\n await done;\n },\n });\n}\n\n/**\n * Stable cache-key serialisation for the `StateStoreKey`.\n *\n * @internal\n */\nfunction stringifyKey(key: StateStoreKey): string {\n return JSON.stringify({\n scriptHash: key.scriptHash,\n compilerVersion: key.compilerVersion,\n apiVersion: key.apiVersion,\n capabilitiesHash: key.capabilitiesHash,\n symbol: key.symbol,\n mainInterval: key.mainInterval,\n requestedIntervals: key.requestedIntervals.join(\",\"),\n });\n}\n\n/**\n * Lazy singleton IDB connection per database name.\n *\n * @internal\n */\nfunction openDb(dbName: string): Promise<IDBDatabase> {\n const existing = dbPromises.get(dbName);\n if (existing !== undefined) return existing;\n\n const promise = new Promise<IDBDatabase>((resolve, reject) => {\n if (globalThis.indexedDB === undefined) {\n reject(new Error(\"indexedDB is not available\"));\n return;\n }\n\n let request: IDBOpenDBRequest;\n try {\n request = globalThis.indexedDB.open(dbName, 1);\n } catch (error) {\n reject(toError(error, \"indexedDB.open failed\"));\n return;\n }\n\n request.onupgradeneeded = () => {\n const db = request.result;\n if (!db.objectStoreNames.contains(OBJECT_STORE)) {\n const store = db.createObjectStore(OBJECT_STORE, { keyPath: \"keyString\" });\n store.createIndex(SAVED_AT_INDEX, \"savedAt\");\n }\n };\n request.onerror = () => {\n reject(toError(request.error, \"indexedDB.open failed\"));\n };\n request.onblocked = () => {\n reject(new Error(`indexedDB.open blocked for database \"${dbName}\"`));\n };\n request.onsuccess = () => {\n const db = request.result;\n // Drop the cached promise if the connection is closed or another\n // tab requests a version upgrade, so the next openDb() reopens a\n // valid connection instead of reusing a dead IDBDatabase.\n const evict = (): void => {\n if (dbPromises.get(dbName) === promise) dbPromises.delete(dbName);\n };\n db.onclose = evict;\n db.onversionchange = () => {\n db.close();\n evict();\n };\n resolve(db);\n };\n });\n\n promise.catch(() => {\n if (dbPromises.get(dbName) === promise) dbPromises.delete(dbName);\n });\n dbPromises.set(dbName, promise);\n return promise;\n}\n\n/**\n * Promise wrapper for one IDB request.\n *\n * @internal\n */\nfunction requestToPromise<T>(request: IDBRequest<T>): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n request.onerror = () => {\n reject(toError(request.error, \"IndexedDB request failed\"));\n };\n request.onsuccess = () => {\n resolve(request.result);\n };\n });\n}\n\n/**\n * Resolves only when the whole IDB transaction completes.\n *\n * @internal\n */\nfunction transactionDone(tx: IDBTransaction): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n tx.onabort = () => {\n reject(toError(tx.error, \"IndexedDB transaction aborted\"));\n };\n tx.onerror = () => {\n reject(toError(tx.error, \"IndexedDB transaction failed\"));\n };\n tx.oncomplete = () => {\n resolve();\n };\n });\n}\n\n/**\n * Reads all well-formed snapshot records from the store.\n *\n * @internal\n */\nfunction readAllRecords(store: IDBObjectStore): Promise<ReadonlyArray<StoredRecord>> {\n return new Promise<ReadonlyArray<StoredRecord>>((resolve, reject) => {\n const records: StoredRecord[] = [];\n const request = store.index(SAVED_AT_INDEX).openCursor();\n request.onerror = () => {\n reject(toError(request.error, \"IndexedDB cursor failed\"));\n };\n request.onsuccess = () => {\n const cursor = request.result;\n if (cursor === null) {\n resolve(records);\n return;\n }\n if (isStoredRecord(cursor.value)) records.push(cursor.value);\n cursor.continue();\n };\n });\n}\n\n/**\n * Evicts savedAt-ascending records until the pending write fits the cap.\n *\n * @internal\n */\nasync function evictUntilUnderCap(\n store: IDBObjectStore,\n records: ReadonlyArray<StoredRecord>,\n keyString: string,\n nextBytes: number,\n capBytes: number,\n): Promise<void> {\n let total = 0;\n const candidates: StoredRecord[] = [];\n for (const record of records) {\n if (record.keyString === keyString) continue;\n total += record.bytesEstimate;\n candidates.push(record);\n }\n candidates.sort((a, b) => a.savedAt - b.savedAt);\n\n for (const record of candidates) {\n if (total + nextBytes <= capBytes) return;\n await requestToPromise(store.delete(record.keyString));\n total -= record.bytesEstimate;\n }\n}\n\n/**\n * UTF-16 byte estimate used for best-effort cap accounting.\n *\n * @internal\n */\nfunction estimateSnapshotBytes(snapshot: StateSnapshot): number {\n return JSON.stringify(snapshot).length * 2;\n}\n\n/**\n * Narrows records read from IDB's untyped structured-clone surface.\n *\n * @internal\n */\nfunction isStoredRecord(value: unknown): value is StoredRecord {\n if (typeof value !== \"object\" || value === null) return false;\n if (!(\"keyString\" in value) || typeof value.keyString !== \"string\") return false;\n if (!(\"bytesEstimate\" in value) || typeof value.bytesEstimate !== \"number\") return false;\n if (!(\"savedAt\" in value) || typeof value.savedAt !== \"number\") return false;\n if (!(\"snapshot\" in value)) return false;\n return true;\n}\n\n/**\n * Preserves underlying IDB messages on rejection paths.\n *\n * @internal\n */\nfunction toError(value: unknown, fallback: string): Error {\n if (value instanceof DOMException) return new Error(value.message);\n if (value instanceof Error) return value;\n if (typeof value === \"string\") return new Error(value);\n return new Error(fallback);\n}\n"]}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,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 { createWorkerHost } from \"./createWorkerHost.js\";\nexport type { CreateWorkerHostOpts } from \"./createWorkerHost.js\";\nexport { createWorkerBoot } from \"./createWorkerBoot.js\";\nexport type { WorkerBootScope } from \"./createWorkerBoot.js\";\nexport { DEFAULT_LIMITS } from \"./limits.js\";\nexport type {\n HostCompiledScript,\n HostLimits,\n ScriptHost,\n WorkerLike,\n} from \"./types.js\";\nexport type { HostToWorker, WorkerToHost } from \"./protocol.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"limits.js","sourceRoot":"","sources":["../src/limits.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AW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAChE,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 { HostLimits } from \"./types.js\";\n\n/**\n * Phase-1 default `HostLimits`. `maxCpuMsPerStep` is the only enforced cap;\n * `maxHeapBytes` is advisory (no per-worker heap API exists in browsers\n * today) and `maxRingBufferBars` is forwarded for runtime sizing decisions.\n * `maxLoadTimeoutMs` bounds `host.load()` so a silently-dead worker can't\n * hang a consumer indefinitely; 30s is generous for module fetch + parse\n * on a slow network and still bounded enough to recover.\n * Frozen so consumers cannot mutate the singleton.\n *\n * @since 0.1\n * @stable\n * @example\n * import { DEFAULT_LIMITS } from \"@invinite-org/chartlang-host-worker\";\n * const cpu = DEFAULT_LIMITS.maxCpuMsPerStep; // 50\n * void cpu;\n */\nexport const DEFAULT_LIMITS: HostLimits = Object.freeze({\n maxHeapBytes: 64 * 1024 * 1024,\n maxCpuMsPerStep: 50,\n maxRingBufferBars: 5_000,\n maxLoadTimeoutMs: 30_000,\n});\n\n/**\n * Wall-clock measurement around `fn`. Returns `result` (always — Phase-1\n * enforcement is measurement, not preemption) and `overshoot` (the observed\n * elapsed ms when over budget, `0` otherwise). The worker boot uses this to\n * post `step-overshoot` to the host; Phase 5's QuickJS host swaps this seam\n * for real `setInterruptHandler`-based preemption.\n *\n * Re-throws if `fn` rejects — overshoot detection does not swallow errors.\n *\n * @since 0.1\n * @stable\n * @example\n * // const { result, overshoot } = await watchStep(async () => 42, 100);\n * // result === 42; overshoot === 0;\n * const fn: typeof watchStep = watchStep;\n * void fn;\n */\nexport async function watchStep<T>(\n fn: () => Promise<T>,\n maxMs: number,\n): Promise<{ readonly result: T; readonly overshoot: number }> {\n const start = performance.now();\n const result = await fn();\n const elapsed = performance.now() - start;\n return { result, overshoot: elapsed > maxMs ? elapsed : 0 };\n}\n"]}
@@ -1,14 +1,17 @@
1
- import type { AdapterSymInfo, CandleEvent, Capabilities, RunnerEmissions } from "@invinite-org/chartlang-adapter-kit";
1
+ import type { AdapterSymInfo, CandleEvent, Capabilities, PlotOverride, RunnerEmissions } from "@invinite-org/chartlang-adapter-kit";
2
2
  import type { HostCompiledScript, HostLimits } from "./types.js";
3
3
  /**
4
4
  * Messages the main thread posts into the worker. JSON-clean by construction
5
5
  * — every payload survives `structuredClone` without bespoke transferables.
6
6
  *
7
7
  * - `load` carries the compiled bundle, the adapter's `Capabilities`, and the
8
- * host's `HostLimits`. Optional `inputOverrides` is already resolved on the
9
- * host side because callbacks cannot cross the worker boundary.
8
+ * host's `HostLimits`. Optional `inputOverrides` / `plotOverrides` are
9
+ * already resolved on the host side because callbacks cannot cross the
10
+ * worker boundary.
10
11
  * - `candleEvent` is fire-and-forget — the worker only replies on overshoot
11
12
  * or fatal.
13
+ * - `setPlotOverrides` swaps the live presentation-override map; fire-and-forget
14
+ * like `candleEvent` — the next `drain` reflects it without a recompute.
12
15
  * - `drain` carries a host-issued `nonce`; the matching reply echoes it.
13
16
  * - `dispose` has no reply.
14
17
  *
@@ -24,10 +27,14 @@ export type HostToWorker = {
24
27
  readonly capabilities: Capabilities;
25
28
  readonly symInfo?: AdapterSymInfo;
26
29
  readonly inputOverrides?: Readonly<Record<string, unknown>>;
30
+ readonly plotOverrides?: Readonly<Record<string, PlotOverride>>;
27
31
  readonly limits: HostLimits;
28
32
  } | {
29
33
  readonly kind: "candleEvent";
30
34
  readonly event: CandleEvent;
35
+ } | {
36
+ readonly kind: "setPlotOverrides";
37
+ readonly overrides: Readonly<Record<string, PlotOverride>>;
31
38
  } | {
32
39
  readonly kind: "drain";
33
40
  readonly nonce: number;
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mapp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D;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAEnC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,YAAY,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxD;IACI,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;CACvC,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAChE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D"}
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D","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 AdapterSymInfo,\n CandleEvent,\n Capabilities,\n PlotOverride,\n RunnerEmissions,\n} from \"@invinite-org/chartlang-adapter-kit\";\n\nimport type { HostCompiledScript, HostLimits } from \"./types.js\";\n\n/**\n * Messages the main thread posts into the worker. JSON-clean by construction\n * — every payload survives `structuredClone` without bespoke transferables.\n *\n * - `load` carries the compiled bundle, the adapter's `Capabilities`, and the\n * host's `HostLimits`. Optional `inputOverrides` / `plotOverrides` are\n * already resolved on the host side because callbacks cannot cross the\n * worker boundary.\n * - `candleEvent` is fire-and-forget — the worker only replies on overshoot\n * or fatal.\n * - `setPlotOverrides` swaps the live presentation-override map; fire-and-forget\n * like `candleEvent` — the next `drain` reflects it without a recompute.\n * - `drain` carries a host-issued `nonce`; the matching reply echoes it.\n * - `dispose` has no reply.\n *\n * @since 0.1\n * @stable\n * @example\n * const m: HostToWorker = { kind: \"dispose\" };\n * void m;\n */\nexport type HostToWorker =\n | {\n readonly kind: \"load\";\n readonly compiled: HostCompiledScript;\n readonly capabilities: Capabilities;\n readonly symInfo?: AdapterSymInfo;\n readonly inputOverrides?: Readonly<Record<string, unknown>>;\n readonly plotOverrides?: Readonly<Record<string, PlotOverride>>;\n readonly limits: HostLimits;\n }\n | { readonly kind: \"candleEvent\"; readonly event: CandleEvent }\n | {\n readonly kind: \"setPlotOverrides\";\n readonly overrides: Readonly<Record<string, PlotOverride>>;\n }\n | { readonly kind: \"drain\"; readonly nonce: number }\n | { readonly kind: \"dispose\" };\n\n/**\n * Messages the worker posts back to the main thread.\n *\n * - `loaded` / `loadError` close the `load` round-trip.\n * - `emissions` carries the matching `nonce` from the `drain` request.\n * - `step-overshoot` is fire-and-forget — Phase-1 enforcement is\n * measurement, not preemption. The host surfaces overshoots via\n * `onWorkerError`; Phase 5's QuickJS host adds real interrupt-based\n * preemption.\n * - `fatal` reports any uncaught error inside the boot's message handler.\n *\n * @since 0.1\n * @stable\n * @example\n * const m: WorkerToHost = { kind: \"loaded\" };\n * void m;\n */\nexport type WorkerToHost =\n | { readonly kind: \"loaded\" }\n | { readonly kind: \"loadError\"; readonly message: string }\n | {\n readonly kind: \"emissions\";\n readonly nonce: number;\n readonly emissions: RunnerEmissions;\n }\n | { readonly kind: \"step-overshoot\"; readonly observedMs: number }\n | { readonly kind: \"fatal\"; readonly message: string };\n"]}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import type { CandleEvent, PlotOverride, RunnerEmissions } from "@invinite-org/chartlang-adapter-kit";
1
2
  import type { Bar, CompiledScriptObject, ScriptManifest } from "@invinite-org/chartlang-core";
2
- import type { CandleEvent, RunnerEmissions } from "@invinite-org/chartlang-adapter-kit";
3
3
  /**
4
4
  * Resource caps a `ScriptHost` reports to its consumer. Phase-1 `host-worker`
5
5
  * enforces `maxCpuMsPerStep` via measurement-only watchdog inside the worker
@@ -78,6 +78,12 @@ export type HostCompiledScript = {
78
78
  export type ScriptHost = {
79
79
  load(compiled: HostCompiledScript): Promise<void>;
80
80
  push(event: CandleEvent): Promise<void>;
81
+ /**
82
+ * Live-swap the per-slot presentation overrides keyed by
83
+ * `PlotEmission.slotId`. Presentation-only — no recompute; the next
84
+ * `drain` reflects the new map. @since 0.8
85
+ */
86
+ setPlotOverrides(overrides: Readonly<Record<string, PlotOverride>>): void;
81
87
  drain(): Promise<RunnerEmissions>;
82
88
  dispose(): void;
83
89
  readonly limits: HostLimits;
@@ -143,14 +149,28 @@ export type ScriptRunnerHandle = {
143
149
  onBarTick(bar: Bar): Promise<void>;
144
150
  push(event: CandleEvent): Promise<void>;
145
151
  drain(): RunnerEmissions;
152
+ setPlotOverrides(overrides: Readonly<Record<string, PlotOverride>>): void;
146
153
  dispose(): Promise<void>;
147
154
  };
148
155
  /**
149
156
  * The default ESM-export shape the worker boot expects from a dynamically
150
157
  * imported compiled module. Matches `@invinite-org/chartlang-compiler`'s
151
- * bundled output (`export default defineIndicator(...)`).
158
+ * bundled output:
152
159
  *
153
- * @since 0.1
160
+ * - **Single-script** files export `default` + `__manifest:
161
+ * ScriptManifest` (and may omit `__manifest`).
162
+ * - **Multi-export / composition** files (§22.10) additionally export
163
+ * one named const per drawn sibling (`mod[exportName]`), an array
164
+ * `__manifest: ReadonlyArray<ScriptManifest>`, and (when the default
165
+ * manifest carries `dependencies`) `__dependencies` carrying every
166
+ * private-dep compiled object.
167
+ *
168
+ * The `[exportName: string]: unknown` index signature keeps sibling
169
+ * reads narrow without forcing every host caller to assert types — the
170
+ * host walks `mod[exportName]` with the local
171
+ * `isCompiledScriptObject` guard before forwarding.
172
+ *
173
+ * @since 0.1 — widened in 0.7 for indicator-composition bundles.
154
174
  * @stable
155
175
  * @example
156
176
  * const m: CompiledModuleExport = {
@@ -160,5 +180,38 @@ export type ScriptRunnerHandle = {
160
180
  */
161
181
  export type CompiledModuleExport = {
162
182
  readonly default: CompiledScriptObject;
183
+ /**
184
+ * Sidecar manifest. Single object for back-compat single-script
185
+ * bundles; array of `ScriptManifest` (default first) for
186
+ * multi-export composition bundles.
187
+ *
188
+ * @since 0.7
189
+ */
190
+ readonly __manifest?: ScriptManifest | ReadonlyArray<ScriptManifest>;
191
+ /**
192
+ * Inlined private deps a multi-export bundle exposes for host
193
+ * mounting. Each entry's `compiled` is the `defineIndicator(...)`
194
+ * return value bound to a module-local `const <localId>` in the
195
+ * consumer's source.
196
+ *
197
+ * @since 0.7
198
+ */
199
+ readonly __dependencies?: ReadonlyArray<{
200
+ readonly localId: string;
201
+ readonly compiled: CompiledScriptObject;
202
+ /**
203
+ * Merged `.withInputs({...})` overrides the consumer applied
204
+ * to its alias binding. Forwarded to the runtime so the
205
+ * `DepRunner` evaluates the producer's `compute` with the
206
+ * consumer-supplied inputs instead of the producer's
207
+ * manifest defaults. Omitted for direct
208
+ * `defineIndicator(...)` private deps that don't apply
209
+ * overrides.
210
+ *
211
+ * @since 0.7
212
+ */
213
+ readonly inputOverrides?: Readonly<Record<string, unknown>>;
214
+ }>;
215
+ readonly [exportName: string]: unknown;
163
216
  };
164
217
  //# sourceMappingURL=types.d.ts.map