@invinite-org/chartlang-host-worker 1.0.1 → 1.1.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 +90 -0
- package/dist/createWorkerBoot.d.ts.map +1 -1
- package/dist/createWorkerBoot.js +64 -1
- package/dist/createWorkerBoot.js.map +1 -1
- package/dist/createWorkerHost.d.ts +5 -1
- package/dist/createWorkerHost.d.ts.map +1 -1
- package/dist/createWorkerHost.js +7 -0
- package/dist/createWorkerHost.js.map +1 -1
- package/dist/protocol.d.ts +10 -3
- package/dist/protocol.d.ts.map +1 -1
- package/dist/types.d.ts +56 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/worker-boot.js +2998 -2399
- package/dist/worker-boot.js.map +4 -4
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,95 @@
|
|
|
1
1
|
# @invinite-org/chartlang-host-worker
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2123181: Hosts (`host-worker`, `host-quickjs`) detect the array-shape `__manifest`
|
|
8
|
+
sidecar plus the new `__dependencies` export, mount the compiled
|
|
9
|
+
`CompiledScriptBundle`, and round-trip the six `dep-*` diagnostic codes
|
|
10
|
+
across both the postMessage wire and the QuickJS JSON membrane.
|
|
11
|
+
`host-worker`'s `CompiledModuleExport` type widens to carry the optional
|
|
12
|
+
`__manifest` / `__dependencies` sidecars; `host-quickjs`'s
|
|
13
|
+
`moduleSourceToScript` rewrites every drawn named export onto a
|
|
14
|
+
host-visible `globalThis.__chartlang_compiled_named` map and lowers
|
|
15
|
+
`__dependencies` onto its own global slot. `adapter-kit`'s
|
|
16
|
+
`validateEmission` confirmed (with explicit coverage) to accept every
|
|
17
|
+
new code. canvas2d-adapter integration test renders sibling-prefixed
|
|
18
|
+
plots, drops private-dep plots, and surfaces `dep-error` diagnostics
|
|
19
|
+
through `Adapter.onEmissions`. The compiler now appends
|
|
20
|
+
`export const __dependencies = [...]` to multi-export bundle output so
|
|
21
|
+
the runtime can mount each private dep as a `DepRunner`; single-script
|
|
22
|
+
bundles stay byte-identical (no `__dependencies` line).
|
|
23
|
+
- 2123181: Indicator composition (Phase 7 closeout): one chartlang indicator can
|
|
24
|
+
read another indicator's titled plot output as a typed `Series<number>`.
|
|
25
|
+
|
|
26
|
+
- Compose via local `const` binding plus `<binding>.output("title")` —
|
|
27
|
+
no new public API beyond the chainable `.output` / `.withInputs`
|
|
28
|
+
accessors on `CompiledScriptObject`.
|
|
29
|
+
- A single `.chart.ts` MAY declare a default export plus any number of
|
|
30
|
+
named exports plus any number of private `const` deps. Export form
|
|
31
|
+
determines render policy: drawn exports render with the
|
|
32
|
+
`export:<exportName>/` slot-id prefix; private `const` deps are data
|
|
33
|
+
feeds only and their visuals are dropped.
|
|
34
|
+
- Cross-file `import baseTrend from "./base-trend.chart"` resolves
|
|
35
|
+
recursively; shared producers inline exactly once per consumer.
|
|
36
|
+
- Additive within `apiVersion: 1.x`. The 172-entry
|
|
37
|
+
`STATEFUL_PRIMITIVES` set is unchanged. `DiagnosticCode` widens to 32
|
|
38
|
+
with the new `dep-*` codes (`dep-error`, `dep-cycle`,
|
|
39
|
+
`dep-unknown-output`, `dep-invalid-input-override`, `dep-dynamic`,
|
|
40
|
+
`dep-output-not-titled`).
|
|
41
|
+
- Five conformance scenarios in `@invinite-org/chartlang-conformance`
|
|
42
|
+
pin the runtime contract end-to-end (`dep-private-single-file`,
|
|
43
|
+
`dep-multi-export`, `dep-cross-file`, `dep-diamond`,
|
|
44
|
+
`dep-error-halts-parent`). `Scenario.additionalSources` lets
|
|
45
|
+
cross-file scenarios ship producer + consumer side-by-side.
|
|
46
|
+
- Two new example scripts in `examples/scripts/`:
|
|
47
|
+
`base-trend.chart.ts` (producer) + `trend-confirmation.chart.ts`
|
|
48
|
+
(multi-export consumer). React-demo gains a fifth catalogue entry
|
|
49
|
+
exercising the feature end-to-end in the browser.
|
|
50
|
+
- Docs: `docs/language/indicator-composition.md` narrative guide,
|
|
51
|
+
`docs/spec/manifest.md` + `docs/spec/semantics.md` +
|
|
52
|
+
`docs/spec/versioning.md` updates, five new glossary entries.
|
|
53
|
+
|
|
54
|
+
- 2123181: Light up the end-to-end cross-file dep path for indicator composition. The
|
|
55
|
+
compiler's `rewriteDependencyAccessors` transformer now collapses
|
|
56
|
+
`const <alias> = <root>.withInputs({...})...` chains to the bare root
|
|
57
|
+
identifier so the runtime sentinel never fires at module load; the merged
|
|
58
|
+
effective inputs flow through the `__dependencies[i].inputOverrides` slot
|
|
59
|
+
into the runtime's `DepRunner`. Cross-file producers' `@invinite-org/chartlang-core`
|
|
60
|
+
imports are hoisted above the inlined IIFE so esbuild dedupes them against
|
|
61
|
+
the consumer's imports and pulls in every symbol the producer uses
|
|
62
|
+
(`input.int`, `ta.ema`, …). The `__dependencies` export is now prepended
|
|
63
|
+
pre-bundle so esbuild's tree-shaker keeps each alias binding alive. The
|
|
64
|
+
`dep-cross-file` conformance scenario joins `ALL_SCENARIOS` and the suite
|
|
65
|
+
runs 225 scenarios green.
|
|
66
|
+
- 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).
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- 2123181: Structured `StateSnapshot` carrying per-runner slot sections (primary +
|
|
71
|
+
siblings + dependencies) so a `CompiledScriptBundle`'s cold-replay
|
|
72
|
+
emissions match its warm-restart emissions byte-identically. Slot keys
|
|
73
|
+
now carry the active runner's `slotIdPrefix` everywhere they reach a
|
|
74
|
+
`StateStore` (`dep:<localId>/` for deps, `export:<exportName>/` for
|
|
75
|
+
siblings, empty for the primary). Flat-shape snapshots from before this
|
|
76
|
+
release continue to load back-compat as primary-only.
|
|
77
|
+
- Updated dependencies [d6d1a1f]
|
|
78
|
+
- Updated dependencies [f0c8eb8]
|
|
79
|
+
- Updated dependencies [2123181]
|
|
80
|
+
- Updated dependencies [2123181]
|
|
81
|
+
- Updated dependencies [2123181]
|
|
82
|
+
- Updated dependencies [2123181]
|
|
83
|
+
- Updated dependencies [2123181]
|
|
84
|
+
- Updated dependencies [4d77f4d]
|
|
85
|
+
- Updated dependencies [4d77f4d]
|
|
86
|
+
- Updated dependencies [3b4952d]
|
|
87
|
+
- Updated dependencies [0427459]
|
|
88
|
+
- Updated dependencies [0427459]
|
|
89
|
+
- @invinite-org/chartlang-core@1.1.0
|
|
90
|
+
- @invinite-org/chartlang-adapter-kit@1.2.0
|
|
91
|
+
- @invinite-org/chartlang-runtime@1.1.0
|
|
92
|
+
|
|
3
93
|
## 1.0.1
|
|
4
94
|
|
|
5
95
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWorkerBoot.d.ts","sourceRoot":"","sources":["../src/createWorkerBoot.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/createWorkerBoot.js
CHANGED
|
@@ -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
|
|
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;
|
|
1
|
+
{"version":3,"file":"createWorkerBoot.js","sourceRoot":"","sources":["../src/createWorkerBoot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/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,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,CAAC,GAAI,K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,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"}
|
|
@@ -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
|
|
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"}
|
package/dist/createWorkerHost.js
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"createWorkerHost.js","sourceRoot":"","sources":["../src/createWorkerHost.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAS/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAyC7C,SAAS,YAAY,CAAC,CAAa;IAC/B,OAAO,OAAO,CAAC,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YAAY,IAAI,CAAC,CAAC;YAClB,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,EAAE;gBAC5C,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;gBAC9B,MAAM,KAAK,GAAiB,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;gBACxD,MAAM,CAAC,WAAW,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"}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -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`
|
|
9
|
-
* host side because callbacks cannot cross the
|
|
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;
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,cAAc,EACd,WAAW,EACX,YAAY,EACZ,eAAe,EAClB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjE
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,eAAe,EAClB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE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AAK,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"}
|
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
|
|
158
|
+
* bundled output:
|
|
152
159
|
*
|
|
153
|
-
*
|
|
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
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,WAAW,EACX,YAAY,EACZ,eAAe,EAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,UAAU,GAAG;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAC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