@unovis/mcp 1.7.0-mcp.1 → 1.7.0-mcp.2
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/README.md +3 -2
- package/dist/cli.js +7 -0
- package/dist/cli.js.map +1 -1
- package/dist/html/document.d.ts +16 -3
- package/dist/html/document.js +50 -20
- package/dist/html/document.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/recipes/area.d.ts +3 -2
- package/dist/recipes/bar.d.ts +3 -2
- package/dist/recipes/boxplot.d.ts +3 -2
- package/dist/recipes/chord.d.ts +1 -0
- package/dist/recipes/choropleth.d.ts +1 -0
- package/dist/recipes/donut.d.ts +1 -0
- package/dist/recipes/graph.d.ts +1 -0
- package/dist/recipes/heatmap.d.ts +1 -0
- package/dist/recipes/index.d.ts +2 -0
- package/dist/recipes/index.js +3 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/recipes/line.d.ts +3 -2
- package/dist/recipes/nested-donut.d.ts +1 -0
- package/dist/recipes/radial-bar.d.ts +1 -0
- package/dist/recipes/sankey.d.ts +1 -0
- package/dist/recipes/scatter.d.ts +3 -2
- package/dist/recipes/shared.d.ts +6 -10
- package/dist/recipes/shared.js +6 -52
- package/dist/recipes/shared.js.map +1 -1
- package/dist/recipes/timeline.d.ts +1 -0
- package/dist/recipes/treemap.d.ts +1 -0
- package/dist/render/materialize.d.ts +9 -3
- package/dist/render/materialize.js +45 -23
- package/dist/render/materialize.js.map +1 -1
- package/dist/render/renderer.d.ts +2 -7
- package/dist/render/renderer.js +1 -1
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/spec-schema.d.ts +1180 -0
- package/dist/render/spec-schema.js +71 -0
- package/dist/render/spec-schema.js.map +1 -0
- package/dist/render/spec.d.ts +10 -7
- package/dist/render/spec.js +4 -8
- package/dist/render/spec.js.map +1 -1
- package/dist/render/time-ticks.d.ts +10 -0
- package/dist/render/time-ticks.js +56 -0
- package/dist/render/time-ticks.js.map +1 -0
- package/dist/tools/register.d.ts +9 -0
- package/dist/tools/register.js +30 -5
- package/dist/tools/register.js.map +1 -1
- package/dist/widget/bundle.js +467 -459
- package/dist/widget/bundle.meta.json +2 -1
- package/dist/widget/bundle.standard.js +802 -0
- package/dist/widget/entry.d.ts +4 -0
- package/dist/widget/entry.js +71 -12
- package/dist/widget/entry.js.map +1 -1
- package/dist/widget/events.d.ts +25 -0
- package/dist/widget/events.js +95 -0
- package/dist/widget/events.js.map +1 -0
- package/dist/widget/interactions.js +22 -12
- package/dist/widget/interactions.js.map +1 -1
- package/dist/widget/unpack.d.ts +1 -0
- package/dist/widget/unpack.js +1 -0
- package/dist/widget/unpack.js.map +1 -0
- package/dist/widget/variants.d.ts +14 -0
- package/dist/widget/variants.js +22 -0
- package/dist/widget/variants.js.map +1 -0
- package/docs/README.md +1 -0
- package/docs/architecture.md +57 -27
- package/docs/chart-spec.md +38 -0
- package/docs/getting-started.md +5 -0
- package/docs/interactive.md +52 -6
- package/docs/output-types.md +1 -0
- package/docs/programmatic.md +24 -0
- package/docs/tools.md +6 -6
- package/docs/troubleshooting.md +8 -7
- package/docs/webview.md +85 -0
- package/package.json +34 -13
- package/schema/chart-spec.v1.baseline.json +309 -0
- package/schema/chart-spec.v1.json +309 -0
- package/dist/env/bbox.d.ts +0 -13
- package/dist/env/bbox.js +0 -335
- package/dist/env/bbox.js.map +0 -1
- package/dist/env/canvas.d.ts +0 -9
- package/dist/env/canvas.js +0 -55
- package/dist/env/canvas.js.map +0 -1
- package/dist/env/computed-style.d.ts +0 -38
- package/dist/env/computed-style.js +0 -186
- package/dist/env/computed-style.js.map +0 -1
- package/dist/env/fonts.d.ts +0 -3
- package/dist/env/fonts.js +0 -103
- package/dist/env/fonts.js.map +0 -1
- package/dist/env/index.d.ts +0 -13
- package/dist/env/index.js +0 -121
- package/dist/env/index.js.map +0 -1
- package/dist/env/raf-queue.d.ts +0 -23
- package/dist/env/raf-queue.js +0 -51
- package/dist/env/raf-queue.js.map +0 -1
- package/dist/env/size.d.ts +0 -9
- package/dist/env/size.js +0 -30
- package/dist/env/size.js.map +0 -1
- package/dist/render/headless.d.ts +0 -62
- package/dist/render/headless.js +0 -158
- package/dist/render/headless.js.map +0 -1
- package/dist/render/mutex.d.ts +0 -9
- package/dist/render/mutex.js +0 -14
- package/dist/render/mutex.js.map +0 -1
- package/dist/render/rasterize.d.ts +0 -10
- package/dist/render/rasterize.js +0 -29
- package/dist/render/rasterize.js.map +0 -1
- package/dist/svg/collect-css.d.ts +0 -14
- package/dist/svg/collect-css.js +0 -53
- package/dist/svg/collect-css.js.map +0 -1
- package/dist/svg/css-vars.d.ts +0 -17
- package/dist/svg/css-vars.js +0 -64
- package/dist/svg/css-vars.js.map +0 -1
- package/dist/svg/header.d.ts +0 -8
- package/dist/svg/header.js +0 -81
- package/dist/svg/header.js.map +0 -1
- package/dist/svg/ids.d.ts +0 -12
- package/dist/svg/ids.js +0 -94
- package/dist/svg/ids.js.map +0 -1
- package/dist/svg/postprocess.d.ts +0 -41
- package/dist/svg/postprocess.js +0 -135
- package/dist/svg/postprocess.js.map +0 -1
- package/fonts/README.md +0 -19
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ Read them on the web at [unovis.dev/docs/mcp](https://unovis.dev/docs/mcp), or i
|
|
|
14
14
|
[chart spec](./docs/chart-spec.md) ·
|
|
15
15
|
[programmatic use](./docs/programmatic.md) ·
|
|
16
16
|
[interactive charts](./docs/interactive.md) ·
|
|
17
|
+
[native WebViews](./docs/webview.md) ·
|
|
17
18
|
[architecture](./docs/architecture.md) ·
|
|
18
19
|
[troubleshooting](./docs/troubleshooting.md)
|
|
19
20
|
|
|
@@ -104,7 +105,7 @@ recipe → ChartSpec ─┬→ headless renderer → SVG / PNG (any clie
|
|
|
104
105
|
└→ widget bundle → ui:// resource (MCP UI clients)
|
|
105
106
|
```
|
|
106
107
|
|
|
107
|
-
The browser widget (~
|
|
108
|
+
The browser widget (everything inlined; documents are ~140kB for XY/radial charts and ~290kB for network/geo ones — the smallest sufficient bundle variant travels as a gzip payload with a self-extracting bootstrap) runs the **same materializer** as the headless renderer, so one code path turns a spec into a chart on both sides. It also works as a plain iframe for any web page — point an iframe at the widget with `#embed` and post it a spec:
|
|
108
109
|
|
|
109
110
|
```js
|
|
110
111
|
iframe.contentWindow.postMessage({ type: 'unovis:render', spec }, '*')
|
|
@@ -121,7 +122,7 @@ Unovis is a browser-first library — it renders SVG into a live DOM using D3. T
|
|
|
121
122
|
2. charts render with `duration: 0` (fully synchronous), the frame queue is drained until quiescent, and `onRenderComplete` confirms the chart is final;
|
|
122
123
|
3. a post-processing pass makes the SVG standalone: emotion styles are inlined as attributes, `var()` references baked to literal values (theme-aware), ids rewritten deterministically, and the title/legend header synthesized.
|
|
123
124
|
|
|
124
|
-
Fonts: on first start the server provisions Inter (Unovis's default font) for text measurement — it downloads the official [Inter release](https://github.com/rsms/inter) once (pinned version, SHA-256 verified, SIL OFL 1.1) into `~/.cache/unovis-
|
|
125
|
+
Fonts: on first start the server provisions Inter (Unovis's default font) for text measurement — it downloads the official [Inter release](https://github.com/rsms/inter) once (pinned version, SHA-256 verified, SIL OFL 1.1) into `~/.cache/unovis-ssr/fonts/` and reuses it from there. Offline or with `UNOVIS_MCP_NO_DOWNLOAD=1` it falls back to system fonts (metrics are close, not exact). To use your own fonts, set `UNOVIS_MCP_FONTS_DIR=/path/to/fonts` or drop font files into `@unovis/ssr`'s `fonts/` directory — both take precedence over the download.
|
|
125
126
|
|
|
126
127
|
## Programmatic use
|
|
127
128
|
|
package/dist/cli.js
CHANGED
|
@@ -27,6 +27,9 @@ Options:
|
|
|
27
27
|
--port <port> HTTP port (default: 3737)
|
|
28
28
|
--endpoint <path> HTTP endpoint path (default: /mcp)
|
|
29
29
|
--tools <a,b,...> Only expose these tools
|
|
30
|
+
--allow-write-dir <dir> Directory outputPath may write into. stdio default:
|
|
31
|
+
anywhere (the user's own machine); http default:
|
|
32
|
+
file writes disabled
|
|
30
33
|
--version Print version
|
|
31
34
|
--help Show this help
|
|
32
35
|
|
|
@@ -37,6 +40,7 @@ async function main() {
|
|
|
37
40
|
const { values } = parseArgs({
|
|
38
41
|
options: {
|
|
39
42
|
transport: { type: 'string', default: 'stdio' },
|
|
43
|
+
'allow-write-dir': { type: 'string' },
|
|
40
44
|
host: { type: 'string', default: '127.0.0.1' },
|
|
41
45
|
port: { type: 'string', default: '3737' },
|
|
42
46
|
endpoint: { type: 'string', default: '/mcp' },
|
|
@@ -56,6 +60,9 @@ async function main() {
|
|
|
56
60
|
const filter = {
|
|
57
61
|
disabledTools: (process.env.DISABLED_TOOLS ?? '').split(',').map(s => s.trim()).filter(Boolean),
|
|
58
62
|
enabledTools: values.tools?.split(',').map(s => s.trim()).filter(Boolean),
|
|
63
|
+
// A local stdio server acts with its user's own authority; an HTTP
|
|
64
|
+
// endpoint must not be a remote file-write primitive
|
|
65
|
+
writeDir: values['allow-write-dir'] ?? (values.transport === 'http' ? false : undefined),
|
|
59
66
|
};
|
|
60
67
|
if (values.transport === 'stdio') {
|
|
61
68
|
const server = buildServer(filter);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAA;AAElG,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAG5D,MAAM,IAAI,GAAG
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AACH,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,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QACxC,OAAO,CAAC,KAAK,CAAC,mCAAmC,MAAM,CAAC,IAAI,IAAI,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC3F,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAA;IACtC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC,CAAC,CAAA"}
|
package/dist/html/document.d.ts
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import type { ChartSpec } from '../render/spec.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { BundleVariant } from '../widget/variants.js';
|
|
3
|
+
/** The compiled widget bundle */
|
|
4
|
+
export declare function widgetBundle(variant?: BundleVariant): string;
|
|
4
5
|
export interface ChartDocumentOptions {
|
|
5
6
|
/** Document <title>; defaults to the spec title */
|
|
6
7
|
documentTitle?: string;
|
|
7
8
|
/** Animation duration in ms. 0 renders immediately (deterministic tests,
|
|
8
9
|
* and useful when the chart is screenshotted right after load) */
|
|
9
10
|
duration?: number;
|
|
11
|
+
/** Inline the widget as a gzip+base64 payload with a self-extracting
|
|
12
|
+
* bootstrap (default true). Set false for a plain-text bundle — e.g. when
|
|
13
|
+
* a host page's CSP forbids injected script elements */
|
|
14
|
+
compress?: boolean;
|
|
10
15
|
}
|
|
11
16
|
/** A standalone page that renders `spec` on load */
|
|
12
17
|
export declare function buildChartDocument(spec: ChartSpec, options?: ChartDocumentOptions): string;
|
|
13
18
|
/** A page that renders whatever spec it is sent over postMessage.
|
|
14
19
|
* Protocol: iframe posts `unovis:ready`, host posts `unovis:render` with a
|
|
15
20
|
* spec, iframe posts `unovis:size` after each render. */
|
|
16
|
-
export
|
|
21
|
+
export interface EmbedDocumentOptions {
|
|
22
|
+
/** See ChartDocumentOptions.compress (default true) */
|
|
23
|
+
compress?: boolean;
|
|
24
|
+
/** Component types this embed will ever render (e.g. ['Line', 'Donut']).
|
|
25
|
+
* Lets the document carry the smaller standard bundle when the set allows;
|
|
26
|
+
* omitted, it carries the full bundle so any spec renders */
|
|
27
|
+
components?: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare function buildEmbedDocument(options?: EmbedDocumentOptions): string;
|
package/dist/html/document.js
CHANGED
|
@@ -9,30 +9,61 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { readFileSync } from 'node:fs';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
import { gzipSync } from 'node:zlib';
|
|
13
|
+
import { bundleVariantFor } from '../widget/variants.js';
|
|
14
|
+
const artifactCache = new Map();
|
|
15
|
+
/** A compiled widget artifact (built by scripts/build-widget.mjs), resolved
|
|
16
|
+
* relative to this module so it works from dist/ and from src/ */
|
|
17
|
+
function widgetArtifact(name) {
|
|
18
|
+
const cached = artifactCache.get(name);
|
|
19
|
+
if (cached)
|
|
20
|
+
return cached;
|
|
18
21
|
const candidates = [
|
|
19
|
-
new URL(
|
|
20
|
-
new URL(
|
|
22
|
+
new URL(`../widget/${name}`, import.meta.url),
|
|
23
|
+
new URL(`../../dist/widget/${name}`, import.meta.url),
|
|
21
24
|
];
|
|
22
25
|
for (const candidate of candidates) {
|
|
23
26
|
try {
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
const content = readFileSync(fileURLToPath(candidate), 'utf8');
|
|
28
|
+
artifactCache.set(name, content);
|
|
29
|
+
return content;
|
|
26
30
|
}
|
|
27
31
|
catch { /* try the next candidate */ }
|
|
28
32
|
}
|
|
29
|
-
throw new Error(
|
|
33
|
+
throw new Error(`Widget artifact ${name} not found — run \`pnpm build:widget\``);
|
|
34
|
+
}
|
|
35
|
+
/** The compiled widget bundle */
|
|
36
|
+
export function widgetBundle(variant = 'full') {
|
|
37
|
+
return widgetArtifact(variant === 'standard' ? 'bundle.standard.js' : 'bundle.js');
|
|
38
|
+
}
|
|
39
|
+
/** The widget, inlined. Compressed by default: a standalone file never gets
|
|
40
|
+
* transport compression, so the bundle ships as a gzip+base64 payload with a
|
|
41
|
+
* ~5kB synchronous bootstrap ahead of it (~3× smaller documents). The spec
|
|
42
|
+
* and styles stay plain text so committed artifacts remain readable and
|
|
43
|
+
* diffable. */
|
|
44
|
+
function inlineWidget(compress, variant) {
|
|
45
|
+
if (!compress)
|
|
46
|
+
return `<script>${widgetBundle(variant)}</script>`;
|
|
47
|
+
const key = `${variant}.gz64`;
|
|
48
|
+
let payload = artifactCache.get(key);
|
|
49
|
+
if (!payload) {
|
|
50
|
+
payload = gzipSync(Buffer.from(widgetBundle(variant)), { level: 9 }).toString('base64');
|
|
51
|
+
artifactCache.set(key, payload);
|
|
52
|
+
}
|
|
53
|
+
return `<script type="application/gzip" id="uv-bundle-gz">${payload}</script>
|
|
54
|
+
<script>${widgetArtifact('unpack.js')}</script>`;
|
|
30
55
|
}
|
|
31
56
|
/** `</script` inside embedded JSON would close the host script element */
|
|
32
57
|
const escapeForScript = (json) => json.replace(/</g, '\\u003c');
|
|
33
58
|
const FONT_STACK = 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif';
|
|
34
59
|
function styles(spec) {
|
|
35
|
-
|
|
60
|
+
// Interpolated into markup — a hand-built spec could smuggle anything in
|
|
61
|
+
// these fields, so only finite numbers survive
|
|
62
|
+
const width = Number(spec?.width);
|
|
63
|
+
const height = Number(spec?.height);
|
|
64
|
+
const aspect = Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0
|
|
65
|
+
? `${width} / ${height}`
|
|
66
|
+
: '16 / 9';
|
|
36
67
|
return `
|
|
37
68
|
:root { --uv-bg: #ffffff; --uv-fg: #1f2937; --uv-muted: #6b7280; --uv-border: #e5e7eb; }
|
|
38
69
|
:root[data-theme="dark"] { --uv-bg: #292b34; --uv-fg: #f2f4f9; --uv-muted: #aab2c0; --uv-border: #3a3d47; }
|
|
@@ -53,8 +84,9 @@ function styles(spec) {
|
|
|
53
84
|
/** A standalone page that renders `spec` on load */
|
|
54
85
|
export function buildChartDocument(spec, options = {}) {
|
|
55
86
|
const title = options.documentTitle ?? spec.title ?? 'Unovis chart';
|
|
87
|
+
const variant = bundleVariantFor(spec.components.map(c => c.type));
|
|
56
88
|
return `<!doctype html>
|
|
57
|
-
<html lang="en"${spec.theme === 'dark' ? ' data-theme="dark"' : ''}>
|
|
89
|
+
<html lang="en" data-uv-bundle="${variant}"${spec.theme === 'dark' ? ' data-theme="dark"' : ''}>
|
|
58
90
|
<head>
|
|
59
91
|
<meta charset="utf-8">
|
|
60
92
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
@@ -65,17 +97,15 @@ export function buildChartDocument(spec, options = {}) {
|
|
|
65
97
|
<div id="uv-root"></div>
|
|
66
98
|
<script type="application/json" id="uv-spec">${escapeForScript(JSON.stringify(spec))}</script>
|
|
67
99
|
<script type="application/json" id="uv-options">${escapeForScript(JSON.stringify({ duration: options.duration ?? 400 }))}</script>
|
|
68
|
-
|
|
100
|
+
${inlineWidget(options.compress !== false, variant)}
|
|
69
101
|
</body>
|
|
70
102
|
</html>
|
|
71
103
|
`;
|
|
72
104
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* spec, iframe posts `unovis:size` after each render. */
|
|
76
|
-
export function buildEmbedDocument() {
|
|
105
|
+
export function buildEmbedDocument(options = {}) {
|
|
106
|
+
const variant = options.components ? bundleVariantFor(options.components) : 'full';
|
|
77
107
|
return `<!doctype html>
|
|
78
|
-
<html lang="en">
|
|
108
|
+
<html lang="en" data-uv-bundle="${variant}">
|
|
79
109
|
<head>
|
|
80
110
|
<meta charset="utf-8">
|
|
81
111
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
@@ -86,7 +116,7 @@ export function buildEmbedDocument() {
|
|
|
86
116
|
</head>
|
|
87
117
|
<body>
|
|
88
118
|
<div id="uv-embed-root"></div>
|
|
89
|
-
|
|
119
|
+
${inlineWidget(options.compress !== false, variant)}
|
|
90
120
|
<script>window.UnovisChart.startEmbed()</script>
|
|
91
121
|
</body>
|
|
92
122
|
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/html/document.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/html/document.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAGxD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAA;AAE/C;kEACkE;AAClE,SAAS,cAAc,CAAE,IAAY;IACnC,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACtC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAA;IACzB,MAAM,UAAU,GAAG;QACjB,IAAI,GAAG,CAAC,aAAa,IAAI,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAC7C,IAAI,GAAG,CAAC,qBAAqB,IAAI,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;KACtD,CAAA;IACD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,YAAY,CAAC,aAAa,CAAC,SA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lD,CAAA;AACD,CAAC;AAcD,MAAM,UAAU,kBAAkB,CAAE,UAAgC,EAAE;IACpE,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IAClF,OAAO;kCACyB,OAAO;;;;;SAKhC,MAAM,EAAE;;;;;;EAMf,YAAY,CAAC,OAAO,CAAC,QAAQ,KAAK,KAAK,EAAE,OAAO,CAAC;;;;CAIlD,CAAA;AACD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,19 +7,20 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { renderChart, ChartInputError } from './render/renderer.js';
|
|
9
9
|
export type { RenderOptions } from './render/renderer.js';
|
|
10
|
-
export { renderToSvg } from '
|
|
11
|
-
export type { HeadlessRenderOptions, BuildContext, RenderedChart, RenderResult } from '
|
|
10
|
+
export { renderToSvg } from '@unovis/ssr';
|
|
11
|
+
export type { HeadlessRenderOptions, BuildContext, RenderedChart, RenderResult } from '@unovis/ssr';
|
|
12
12
|
export { buildChartDocument, buildEmbedDocument } from './html/document.js';
|
|
13
13
|
export type { ChartDocumentOptions } from './html/document.js';
|
|
14
|
-
export { svgToPng, themeBackground } from '
|
|
15
|
-
export type { RasterizeOptions } from '
|
|
14
|
+
export { svgToPng, themeBackground } from '@unovis/ssr';
|
|
15
|
+
export type { RasterizeOptions } from '@unovis/ssr';
|
|
16
|
+
export { SPEC_VERSION } from './render/spec.js';
|
|
16
17
|
export type { ChartSpec, ComponentSpec, AxisSpec, AccessorRef, LegendItemSpec } from './render/spec.js';
|
|
17
18
|
export { recipes, recipeByName } from './recipes/index.js';
|
|
18
19
|
export type { Recipe, AnyRecipe } from './recipes/index.js';
|
|
19
20
|
export { buildServer } from './server.js';
|
|
20
21
|
export { registerTools, activeRecipes } from './tools/register.js';
|
|
21
22
|
export type { ToolFilterOptions } from './tools/register.js';
|
|
22
|
-
export { getRenderEnv } from '
|
|
23
|
-
export type { RenderEnv, UnovisLib } from '
|
|
23
|
+
export { getRenderEnv } from '@unovis/ssr';
|
|
24
|
+
export type { RenderEnv, UnovisLib } from '@unovis/ssr';
|
|
24
25
|
export { generateCode, formatGeneratedFiles, FRAMEWORKS } from './codegen/index.js';
|
|
25
26
|
export type { Framework, GeneratedFile } from './codegen/index.js';
|
package/dist/index.js
CHANGED
|
@@ -7,12 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { renderChart, ChartInputError } from './render/renderer.js';
|
|
9
9
|
// The headless primitive: render any Unovis chart to standalone SVG in Node
|
|
10
|
-
|
|
10
|
+
// Re-exported from @unovis/ssr, where the headless renderer now lives —
|
|
11
|
+
// existing imports from '@unovis/mcp' keep working
|
|
12
|
+
export { renderToSvg } from '@unovis/ssr';
|
|
11
13
|
export { buildChartDocument, buildEmbedDocument } from './html/document.js';
|
|
12
|
-
export { svgToPng, themeBackground } from '
|
|
14
|
+
export { svgToPng, themeBackground } from '@unovis/ssr';
|
|
15
|
+
export { SPEC_VERSION } from './render/spec.js';
|
|
13
16
|
export { recipes, recipeByName } from './recipes/index.js';
|
|
14
17
|
export { buildServer } from './server.js';
|
|
15
18
|
export { registerTools, activeRecipes } from './tools/register.js';
|
|
16
|
-
export { getRenderEnv } from '
|
|
19
|
+
export { getRenderEnv } from '@unovis/ssr';
|
|
17
20
|
export { generateCode, formatGeneratedFiles, FRAMEWORKS } from './codegen/index.js';
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEnE,4EAA4E;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEnE,4EAA4E;AAC5E,wEAAwE;AACxE,mDAAmD;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAE3E,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/recipes/area.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const areaInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -23,18 +24,18 @@ export declare const areaInputShape: {
|
|
|
23
24
|
style: z.ZodDefault<z.ZodEnum<["dashed", "solid", "dotted"]>>;
|
|
24
25
|
}, "strip", z.ZodTypeAny, {
|
|
25
26
|
value: number;
|
|
26
|
-
style: "solid" | "dashed" | "dotted";
|
|
27
27
|
axis: "x" | "y";
|
|
28
28
|
lineWidth: number;
|
|
29
|
+
style: "solid" | "dashed" | "dotted";
|
|
29
30
|
label?: string | undefined;
|
|
30
31
|
color?: string | undefined;
|
|
31
32
|
}, {
|
|
32
33
|
value: number;
|
|
33
34
|
label?: string | undefined;
|
|
34
35
|
color?: string | undefined;
|
|
35
|
-
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
36
36
|
axis?: "x" | "y" | undefined;
|
|
37
37
|
lineWidth?: number | undefined;
|
|
38
|
+
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
38
39
|
}>, "many">>;
|
|
39
40
|
referenceBands: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
41
|
axis: z.ZodDefault<z.ZodEnum<["x", "y"]>>;
|
package/dist/recipes/bar.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const barInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -23,18 +24,18 @@ export declare const barInputShape: {
|
|
|
23
24
|
style: z.ZodDefault<z.ZodEnum<["dashed", "solid", "dotted"]>>;
|
|
24
25
|
}, "strip", z.ZodTypeAny, {
|
|
25
26
|
value: number;
|
|
26
|
-
style: "solid" | "dashed" | "dotted";
|
|
27
27
|
axis: "x" | "y";
|
|
28
28
|
lineWidth: number;
|
|
29
|
+
style: "solid" | "dashed" | "dotted";
|
|
29
30
|
label?: string | undefined;
|
|
30
31
|
color?: string | undefined;
|
|
31
32
|
}, {
|
|
32
33
|
value: number;
|
|
33
34
|
label?: string | undefined;
|
|
34
35
|
color?: string | undefined;
|
|
35
|
-
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
36
36
|
axis?: "x" | "y" | undefined;
|
|
37
37
|
lineWidth?: number | undefined;
|
|
38
|
+
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
38
39
|
}>, "many">>;
|
|
39
40
|
referenceBands: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
41
|
axis: z.ZodDefault<z.ZodEnum<["x", "y"]>>;
|
|
@@ -4,6 +4,7 @@ export declare const boxplotInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -19,18 +20,18 @@ export declare const boxplotInputShape: {
|
|
|
19
20
|
style: z.ZodDefault<z.ZodEnum<["dashed", "solid", "dotted"]>>;
|
|
20
21
|
}, "strip", z.ZodTypeAny, {
|
|
21
22
|
value: number;
|
|
22
|
-
style: "solid" | "dashed" | "dotted";
|
|
23
23
|
axis: "x" | "y";
|
|
24
24
|
lineWidth: number;
|
|
25
|
+
style: "solid" | "dashed" | "dotted";
|
|
25
26
|
label?: string | undefined;
|
|
26
27
|
color?: string | undefined;
|
|
27
28
|
}, {
|
|
28
29
|
value: number;
|
|
29
30
|
label?: string | undefined;
|
|
30
31
|
color?: string | undefined;
|
|
31
|
-
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
32
32
|
axis?: "x" | "y" | undefined;
|
|
33
33
|
lineWidth?: number | undefined;
|
|
34
|
+
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
34
35
|
}>, "many">>;
|
|
35
36
|
referenceBands: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
36
37
|
axis: z.ZodDefault<z.ZodEnum<["x", "y"]>>;
|
package/dist/recipes/chord.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const chordInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -4,6 +4,7 @@ export declare const choroplethInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
package/dist/recipes/donut.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const donutInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
package/dist/recipes/graph.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const graphInputShape: {
|
|
|
4
4
|
height: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
width: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -4,6 +4,7 @@ export declare const heatmapInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
package/dist/recipes/index.d.ts
CHANGED
|
@@ -3,3 +3,5 @@ export type { Recipe, AnyRecipe } from './types.js';
|
|
|
3
3
|
/** All available chart recipes, in display order */
|
|
4
4
|
export declare const recipes: AnyRecipe[];
|
|
5
5
|
export declare const recipeByName: Map<string, AnyRecipe>;
|
|
6
|
+
export { ChartInputError, assertFieldsExist, baseSpec, categoricalX, dateTickValues, field, seriesLegend, timeTickValuesFromData, xyAxes, } from './shared.js';
|
|
7
|
+
export type { DataRecord } from './shared.js';
|
package/dist/recipes/index.js
CHANGED
|
@@ -32,4 +32,7 @@ export const recipes = [
|
|
|
32
32
|
choroplethRecipe,
|
|
33
33
|
];
|
|
34
34
|
export const recipeByName = new Map(recipes.map(r => [r.name, r]));
|
|
35
|
+
// Spec-building helpers, so consumers of `@unovis/mcp/recipes` don't have to
|
|
36
|
+
// hand-roll accessors, axes, legends or time ticks that the recipes already do
|
|
37
|
+
export { ChartInputError, assertFieldsExist, baseSpec, categoricalX, dateTickValues, field, seriesLegend, timeTickValuesFromData, xyAxes, } from './shared.js';
|
|
35
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recipes/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIlD,oDAAoD;AACpD,MAAM,CAAC,MAAM,OAAO,GAAgB;IAClC,UAAU;IAC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S;IACT,aAAa;IACb,WAAW;IACX,cAAc;IACd,aAAa;IACb,YAAY;IACZ,aAAa;IACb,aAAa;IACb,WAAW;IACX,iBAAiB;IACjB,eAAe;IACf,WAAW;IACX,gBAAgB;CACjB,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAElE,6EAA6E;AAC7E,+EAA+E;AAC/E,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,KAAK,EACL,YAAY,EACZ,sBAAsB,EACtB,MAAM,GACP,MAAM,aAAa,CAAA"}
|
package/dist/recipes/line.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const lineInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -23,18 +24,18 @@ export declare const lineInputShape: {
|
|
|
23
24
|
style: z.ZodDefault<z.ZodEnum<["dashed", "solid", "dotted"]>>;
|
|
24
25
|
}, "strip", z.ZodTypeAny, {
|
|
25
26
|
value: number;
|
|
26
|
-
style: "solid" | "dashed" | "dotted";
|
|
27
27
|
axis: "x" | "y";
|
|
28
28
|
lineWidth: number;
|
|
29
|
+
style: "solid" | "dashed" | "dotted";
|
|
29
30
|
label?: string | undefined;
|
|
30
31
|
color?: string | undefined;
|
|
31
32
|
}, {
|
|
32
33
|
value: number;
|
|
33
34
|
label?: string | undefined;
|
|
34
35
|
color?: string | undefined;
|
|
35
|
-
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
36
36
|
axis?: "x" | "y" | undefined;
|
|
37
37
|
lineWidth?: number | undefined;
|
|
38
|
+
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
38
39
|
}>, "many">>;
|
|
39
40
|
referenceBands: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
41
|
axis: z.ZodDefault<z.ZodEnum<["x", "y"]>>;
|
|
@@ -4,6 +4,7 @@ export declare const nestedDonutInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -4,6 +4,7 @@ export declare const radialBarInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
package/dist/recipes/sankey.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const sankeyInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -4,6 +4,7 @@ export declare const scatterInputShape: {
|
|
|
4
4
|
width: z.ZodDefault<z.ZodNumber>;
|
|
5
5
|
height: z.ZodDefault<z.ZodNumber>;
|
|
6
6
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
7
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
7
8
|
title: z.ZodOptional<z.ZodString>;
|
|
8
9
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
10
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -23,18 +24,18 @@ export declare const scatterInputShape: {
|
|
|
23
24
|
style: z.ZodDefault<z.ZodEnum<["dashed", "solid", "dotted"]>>;
|
|
24
25
|
}, "strip", z.ZodTypeAny, {
|
|
25
26
|
value: number;
|
|
26
|
-
style: "solid" | "dashed" | "dotted";
|
|
27
27
|
axis: "x" | "y";
|
|
28
28
|
lineWidth: number;
|
|
29
|
+
style: "solid" | "dashed" | "dotted";
|
|
29
30
|
label?: string | undefined;
|
|
30
31
|
color?: string | undefined;
|
|
31
32
|
}, {
|
|
32
33
|
value: number;
|
|
33
34
|
label?: string | undefined;
|
|
34
35
|
color?: string | undefined;
|
|
35
|
-
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
36
36
|
axis?: "x" | "y" | undefined;
|
|
37
37
|
lineWidth?: number | undefined;
|
|
38
|
+
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
38
39
|
}>, "many">>;
|
|
39
40
|
referenceBands: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
41
|
axis: z.ZodDefault<z.ZodEnum<["x", "y"]>>;
|
package/dist/recipes/shared.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const commonInput: {
|
|
|
17
17
|
width: z.ZodDefault<z.ZodNumber>;
|
|
18
18
|
height: z.ZodDefault<z.ZodNumber>;
|
|
19
19
|
theme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
20
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
20
21
|
title: z.ZodOptional<z.ZodString>;
|
|
21
22
|
colors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
22
23
|
framework: z.ZodDefault<z.ZodEnum<["ts", "react", "svelte", "vue", "angular", "solid"]>>;
|
|
@@ -41,18 +42,18 @@ export declare const xyDecorations: {
|
|
|
41
42
|
style: z.ZodDefault<z.ZodEnum<["dashed", "solid", "dotted"]>>;
|
|
42
43
|
}, "strip", z.ZodTypeAny, {
|
|
43
44
|
value: number;
|
|
44
|
-
style: "solid" | "dashed" | "dotted";
|
|
45
45
|
axis: "x" | "y";
|
|
46
46
|
lineWidth: number;
|
|
47
|
+
style: "solid" | "dashed" | "dotted";
|
|
47
48
|
label?: string | undefined;
|
|
48
49
|
color?: string | undefined;
|
|
49
50
|
}, {
|
|
50
51
|
value: number;
|
|
51
52
|
label?: string | undefined;
|
|
52
53
|
color?: string | undefined;
|
|
53
|
-
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
54
54
|
axis?: "x" | "y" | undefined;
|
|
55
55
|
lineWidth?: number | undefined;
|
|
56
|
+
style?: "solid" | "dashed" | "dotted" | undefined;
|
|
56
57
|
}>, "many">>;
|
|
57
58
|
referenceBands: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
58
59
|
axis: z.ZodDefault<z.ZodEnum<["x", "y"]>>;
|
|
@@ -118,13 +119,7 @@ export declare function categoricalX(data: DataRecord[], fieldName: string, isTi
|
|
|
118
119
|
* Explicit integer tickValues — approximate d3 tick counts can emit
|
|
119
120
|
* fractional ticks that would round into duplicate category labels. */
|
|
120
121
|
export declare function categoryAxis(base: AxisSpec, categories: string[]): AxisSpec;
|
|
121
|
-
|
|
122
|
-
* arbitrary times of day, which the date formatter would render as
|
|
123
|
-
* time-of-day labels ("08:53 AM" on a 3-month chart) — align ticks to
|
|
124
|
-
* month/day/hour/minute boundaries instead. */
|
|
125
|
-
export declare function dateTickValues(min: number, max: number, target?: number): number[] | undefined;
|
|
126
|
-
/** Tick values for a time axis derived from the data extent of a date field */
|
|
127
|
-
export declare function timeTickValuesFromData(data: DataRecord[], fieldName: string): number[] | undefined;
|
|
122
|
+
export { dateTickValues, timeTickValuesFromData } from '../render/time-ticks.js';
|
|
128
123
|
export declare function seriesLegend(labels: string[], enabled: boolean, colors?: string[]): LegendItemSpec[] | undefined;
|
|
129
124
|
/** Common ChartSpec fields from common tool inputs */
|
|
130
125
|
export declare function baseSpec(input: {
|
|
@@ -133,7 +128,8 @@ export declare function baseSpec(input: {
|
|
|
133
128
|
theme: 'light' | 'dark';
|
|
134
129
|
title?: string;
|
|
135
130
|
colors?: string[];
|
|
136
|
-
|
|
131
|
+
locale?: string;
|
|
132
|
+
}): Pick<ChartSpec, 'specVersion' | 'width' | 'height' | 'theme' | 'title' | 'colors' | 'locale'>;
|
|
137
133
|
export declare function xyAxes(input: {
|
|
138
134
|
xAxisLabel?: string;
|
|
139
135
|
yAxisLabel?: string;
|