vizmatic 0.1.4 → 0.1.5

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/PROMPT.md CHANGED
@@ -2,10 +2,18 @@
2
2
 
3
3
  Use Vizmatic to create polished, theme-aware diagrams, figures, dashboards, presentation frames, and animated GIFs from structured React scene primitives.
4
4
 
5
- ## Install
5
+ ## Install Or Run
6
6
 
7
7
  Use the package manager already present in the project.
8
8
 
9
+ For one-off renders, use the binary without changing `package.json`:
10
+
11
+ ```bash
12
+ pnpm dlx vizmatic ./frame.tsx --out ./dist/frames --theme dark,light
13
+ ```
14
+
15
+ Install when the project needs scripts, editor types, or direct renderer APIs:
16
+
9
17
  ```bash
10
18
  pnpm add vizmatic react
11
19
  ```
@@ -106,7 +114,7 @@ export default frame.default
106
114
  Render it:
107
115
 
108
116
  ```bash
109
- pnpm exec vizmatic render frames --out public/vizmatic --theme dark,light --watermark "Your Product" --watermark-image ./logo.svg --watermark-position top-right
117
+ pnpm exec vizmatic frames --out public/vizmatic --theme dark,light --watermark "Your Product" --watermark-image ./logo.svg --watermark-position top-right
110
118
  ```
111
119
 
112
120
  Frame modules can also export a watermark element when code-owned branding is clearer than CLI flags:
package/README.md CHANGED
@@ -31,6 +31,16 @@
31
31
 
32
32
  ## Quick Start
33
33
 
34
+ Use Vizmatic as a one-off binary without touching `package.json`:
35
+
36
+ ```bash
37
+ pnpm dlx vizmatic ./frame.tsx --out ./dist/frames --theme dark,light
38
+ ```
39
+
40
+ Frame files can import `react` and `vizmatic`; the CLI resolves those from its own package runtime in `dlx`/`npx` mode.
41
+
42
+ Install it when you want project scripts, editor types, or direct renderer APIs:
43
+
34
44
  ```bash
35
45
  pnpm add vizmatic react
36
46
  ```
@@ -70,7 +80,7 @@ export default frame.default
70
80
  Render it:
71
81
 
72
82
  ```bash
73
- vizmatic render ./frame.tsx --out ./dist/frames --theme dark,light --watermark "Acme" --watermark-image ./logo.svg
83
+ vizmatic ./frame.tsx --out ./dist/frames --theme dark,light --watermark "Acme" --watermark-image ./logo.svg
74
84
  ```
75
85
 
76
86
  Render an animation:
@@ -378,7 +388,7 @@ git diff --exit-code
378
388
 
379
389
  ## Supply Chain Posture
380
390
 
381
- Vizmatic keeps runtime dependencies narrow: `satori` for JSX layout, `@resvg/resvg-js` for rasterization, `gifenc` for animated GIF output, and `tsx` so the CLI can load TSX scene files directly.
391
+ Vizmatic keeps runtime dependencies narrow: `react` for JSX frames, `satori` for JSX layout, `@resvg/resvg-js` for rasterization, `gifenc` for animated GIF output, and `tsx` so the CLI can load TSX scene files directly.
382
392
 
383
393
  Package resolution is intentionally conservative:
384
394
 
@@ -564,7 +574,7 @@ src/
564
574
  render.ts Satori -> SVG -> resvg -> PNG
565
575
  animate.ts ordered scene states -> GIF
566
576
  autocrop.ts content bounds and overflow checks
567
- cli.ts vizmatic render / vizmatic gif
577
+ cli.ts vizmatic file.tsx / vizmatic render / vizmatic gif
568
578
  examples/
569
579
  *.tsx generated gallery frames
570
580
  docs/
package/dist/cli.js CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
+ import { existsSync as existsSync2 } from "fs";
4
5
  import { mkdir as mkdir3, readFile as readFile2, readdir, writeFile as writeFile3 } from "fs/promises";
5
- import { basename, extname, join as join2, relative, resolve } from "path";
6
- import { pathToFileURL } from "url";
6
+ import { createRequire, Module } from "module";
7
+ import { basename, dirname as dirname3, extname, join as join2, relative, resolve } from "path";
8
+ import { fileURLToPath, pathToFileURL } from "url";
7
9
  import { isValidElement } from "react";
8
10
 
9
11
  // src/animate.ts
@@ -583,12 +585,17 @@ async function renderAnimatedGif(scenes, options) {
583
585
 
584
586
  // src/cli.ts
585
587
  var RENDER_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".jsx", ".mjs", ".ts", ".tsx"]);
588
+ var cliRequire = createRequire(import.meta.url);
589
+ var frameDependencyAliasesInstalled = false;
586
590
  function usageText() {
587
591
  return `Usage:
588
- vizmatic render <file-or-directory...> --out <dir> [--theme dark,light] [--watermark Label] [--watermark-image path-or-url] [--watermark-position top-right] [--no-crop] [--force]
589
- vizmatic gif <file-or-directory...> --out <dir> [--theme dark] [--watermark Label] [--watermark-image path-or-url] [--watermark-position top-right] [--scale 1]
592
+ vizmatic <file-or-directory...> [--out <dir>] [--theme dark,light] [--watermark Label] [--watermark-image path-or-url] [--watermark-position top-right] [--no-crop] [--force]
593
+ vizmatic render <file-or-directory...> [--out <dir>] [--theme dark,light] [--watermark Label] [--watermark-image path-or-url] [--watermark-position top-right] [--no-crop] [--force]
594
+ vizmatic gif <file-or-directory...> [--out <dir>] [--theme dark] [--watermark Label] [--watermark-image path-or-url] [--watermark-position top-right] [--scale 1]
590
595
 
591
596
  Examples:
597
+ vizmatic examples/attention-head.tsx --out dist/frames --theme dark,light
598
+ pnpm dlx vizmatic ./frame.tsx --out ./dist/frames --theme dark
592
599
  vizmatic render examples --out docs/assets/examples --theme dark --watermark Vizmatic
593
600
  vizmatic render frames/attention.tsx --out dist/frames --theme dark,light
594
601
  vizmatic gif examples/animated-pipeline.tsx --out docs/assets/examples --theme dark --watermark Vizmatic`;
@@ -638,6 +645,36 @@ async function resolveWatermarkAssets(watermark) {
638
645
  }
639
646
  };
640
647
  }
648
+ function resolveSelfEntry() {
649
+ const moduleDir = dirname3(fileURLToPath(import.meta.url));
650
+ const bundledEntry = join2(moduleDir, "index.cjs");
651
+ if (existsSync2(bundledEntry)) return bundledEntry;
652
+ const sourceEntry = join2(moduleDir, "index.ts");
653
+ if (existsSync2(sourceEntry)) return sourceEntry;
654
+ try {
655
+ return cliRequire.resolve("vizmatic");
656
+ } catch {
657
+ return void 0;
658
+ }
659
+ }
660
+ function resolveFrameDependency(request) {
661
+ try {
662
+ if (request === "vizmatic") return resolveSelfEntry();
663
+ if (request === "react" || request.startsWith("react/")) return cliRequire.resolve(request);
664
+ } catch {
665
+ return void 0;
666
+ }
667
+ return void 0;
668
+ }
669
+ function installFrameDependencyAliases() {
670
+ if (frameDependencyAliasesInstalled) return;
671
+ frameDependencyAliasesInstalled = true;
672
+ const moduleWithResolver = Module;
673
+ const resolveFilename = moduleWithResolver._resolveFilename;
674
+ moduleWithResolver._resolveFilename = function resolveFrameDependencyAlias(request, parent, isMain, options) {
675
+ return resolveFrameDependency(request) ?? resolveFilename.call(this, request, parent, isMain, options);
676
+ };
677
+ }
641
678
  function parseRenderArgs(argv) {
642
679
  const inputs = [];
643
680
  let outDir = "dist/frames";
@@ -766,11 +803,12 @@ async function findFrameFiles(inputs) {
766
803
  return files.sort();
767
804
  }
768
805
  async function importFrame(filePath) {
806
+ installFrameDependencyAliases();
769
807
  const url = pathToFileURL(filePath).href;
770
808
  try {
771
809
  return await import(url);
772
810
  } catch (error) {
773
- if (!/\.[tj]sx?$/.test(filePath)) throw error;
811
+ if (!RENDER_EXTENSIONS.has(extname(filePath))) throw error;
774
812
  const { tsImport } = await import("tsx/esm/api");
775
813
  return await tsImport(url, import.meta.url);
776
814
  }
@@ -869,13 +907,16 @@ async function gifCommand(argv) {
869
907
  `);
870
908
  }
871
909
  async function main() {
872
- const [command, ...rest] = process.argv.slice(2);
910
+ const args = process.argv.slice(2);
911
+ const [command, ...rest] = args;
873
912
  if (command === "render") {
874
913
  await renderCommand(rest);
875
914
  } else if (command === "gif") {
876
915
  await gifCommand(rest);
877
916
  } else if (!command || command === "help" || command === "--help" || command === "-h") {
878
917
  help();
918
+ } else if (!command.startsWith("-")) {
919
+ await renderCommand(args);
879
920
  } else {
880
921
  usage();
881
922
  }
package/docs/PROMPT.md CHANGED
@@ -2,10 +2,18 @@
2
2
 
3
3
  Use Vizmatic to create polished, theme-aware diagrams, figures, dashboards, presentation frames, and animated GIFs from structured React scene primitives.
4
4
 
5
- ## Install
5
+ ## Install Or Run
6
6
 
7
7
  Use the package manager already present in the project.
8
8
 
9
+ For one-off renders, use the binary without changing `package.json`:
10
+
11
+ ```bash
12
+ pnpm dlx vizmatic ./frame.tsx --out ./dist/frames --theme dark,light
13
+ ```
14
+
15
+ Install when the project needs scripts, editor types, or direct renderer APIs:
16
+
9
17
  ```bash
10
18
  pnpm add vizmatic react
11
19
  ```
@@ -106,7 +114,7 @@ export default frame.default
106
114
  Render it:
107
115
 
108
116
  ```bash
109
- pnpm exec vizmatic render frames --out public/vizmatic --theme dark,light --watermark "Your Product" --watermark-image ./logo.svg --watermark-position top-right
117
+ pnpm exec vizmatic frames --out public/vizmatic --theme dark,light --watermark "Your Product" --watermark-image ./logo.svg --watermark-position top-right
110
118
  ```
111
119
 
112
120
  Frame modules can also export a watermark element when code-owned branding is clearer than CLI flags:
@@ -71,7 +71,7 @@
71
71
  },
72
72
  {
73
73
  "name": "rag-graph",
74
- "title": "Rag Graph",
74
+ "title": "RAG Graph",
75
75
  "source": "examples/rag-graph.tsx",
76
76
  "code": "import React from 'react'\nimport { defineIllustration, GraphDiagram, Scene } from 'vizmatic'\n\nexport const width = 1040\nexport const height = 560\n\nconst frame = defineIllustration((c) =>\n <Scene c={c} title=\"RAG control graph\" subtitle=\"retrieval is a graph, not a linear prompt append\" align=\"center\">\n <GraphDiagram\n c={c}\n width={820}\n height={390}\n nodeWidth={150}\n nodes={[\n { id: 'query', label: 'Query', detail: 'user intent', x: 0.08, y: 0.52, tone: 'blue' },\n { id: 'rewrite', label: 'Rewrite', detail: 'search form', x: 0.30, y: 0.25, tone: 'purple' },\n { id: 'retrieve', label: 'Retrieve', detail: 'top-k docs', x: 0.52, y: 0.25, tone: 'cyan' },\n { id: 'rerank', label: 'Rerank', detail: 'cross-encoder', x: 0.74, y: 0.25, tone: 'warm' },\n { id: 'answer', label: 'Answer', detail: 'grounded draft', x: 0.92, y: 0.52, tone: 'green' },\n { id: 'verify', label: 'Verify', detail: 'citations', x: 0.52, y: 0.78, tone: 'critical' },\n ]}\n edges={[\n { from: 'query', to: 'rewrite', label: 'normalize', tone: 'blue' },\n { from: 'rewrite', to: 'retrieve', label: 'search', tone: 'purple' },\n { from: 'retrieve', to: 'rerank', label: 'rank', tone: 'cyan' },\n { from: 'rerank', to: 'answer', label: 'context', tone: 'green' },\n { from: 'answer', to: 'verify', label: 'claims', tone: 'critical' },\n { from: 'verify', to: 'retrieve', label: 'retry', dashed: true, tone: 'warm' },\n { from: 'query', to: 'answer', label: 'direct?', muted: true },\n ]}\n />\n </Scene>\n)\n\nexport const create = frame.create\nexport default frame.default\n",
77
77
  "html": {
@@ -0,0 +1,21 @@
1
+ # Vizmatic Examples
2
+
3
+ Generated by `pnpm render:examples`. Edit the `.tsx` sources, then rerun render command to refresh previews.
4
+
5
+ Rendered assets live in [`../docs/assets/examples`](../docs/assets/examples).
6
+
7
+ | Example | Dark | Light |
8
+ |---|---|---|
9
+ | [Agent Pipeline](agent-pipeline.tsx) | <img src="../docs/assets/examples/agent-pipeline_dark.png" alt="Agent Pipeline dark render" width="360" /> | <img src="../docs/assets/examples/agent-pipeline_light.png" alt="Agent Pipeline light render" width="360" /> |
10
+ | [Animated Pipeline](animated-pipeline.tsx) | <img src="../docs/assets/examples/animated-pipeline_dark.gif" alt="Animated Pipeline dark render" width="360" /> | <img src="../docs/assets/examples/animated-pipeline_light.gif" alt="Animated Pipeline light render" width="360" /> |
11
+ | [Attention Head](attention-head.tsx) | <img src="../docs/assets/examples/attention-head_dark.png" alt="Attention Head dark render" width="360" /> | <img src="../docs/assets/examples/attention-head_light.png" alt="Attention Head light render" width="360" /> |
12
+ | [Embedding Map](embedding-map.tsx) | <img src="../docs/assets/examples/embedding-map_dark.png" alt="Embedding Map dark render" width="360" /> | <img src="../docs/assets/examples/embedding-map_light.png" alt="Embedding Map light render" width="360" /> |
13
+ | [Eval Dashboard](eval-dashboard.tsx) | <img src="../docs/assets/examples/eval-dashboard_dark.png" alt="Eval Dashboard dark render" width="360" /> | <img src="../docs/assets/examples/eval-dashboard_light.png" alt="Eval Dashboard light render" width="360" /> |
14
+ | [Model Router](model-router.tsx) | <img src="../docs/assets/examples/model-router_dark.png" alt="Model Router dark render" width="360" /> | <img src="../docs/assets/examples/model-router_light.png" alt="Model Router light render" width="360" /> |
15
+ | [Presentation Frame](presentation-frame.tsx) | <img src="../docs/assets/examples/presentation-frame_dark.png" alt="Presentation Frame dark render" width="360" /> | <img src="../docs/assets/examples/presentation-frame_light.png" alt="Presentation Frame light render" width="360" /> |
16
+ | [RAG Graph](rag-graph.tsx) | <img src="../docs/assets/examples/rag-graph_dark.png" alt="RAG Graph dark render" width="360" /> | <img src="../docs/assets/examples/rag-graph_light.png" alt="RAG Graph light render" width="360" /> |
17
+ | [Release Card](release-card.tsx) | <img src="../docs/assets/examples/release-card_dark.png" alt="Release Card dark render" width="360" /> | <img src="../docs/assets/examples/release-card_light.png" alt="Release Card light render" width="360" /> |
18
+ | [Research Landscape](research-landscape.tsx) | <img src="../docs/assets/examples/research-landscape_dark.png" alt="Research Landscape dark render" width="360" /> | <img src="../docs/assets/examples/research-landscape_light.png" alt="Research Landscape light render" width="360" /> |
19
+ | [Spec Anatomy](spec-anatomy.tsx) | <img src="../docs/assets/examples/spec-anatomy_dark.png" alt="Spec Anatomy dark render" width="360" /> | <img src="../docs/assets/examples/spec-anatomy_light.png" alt="Spec Anatomy light render" width="360" /> |
20
+ | [Theme System](theme-system.tsx) | <img src="../docs/assets/examples/theme-system_dark.png" alt="Theme System dark render" width="360" /> | <img src="../docs/assets/examples/theme-system_light.png" alt="Theme System light render" width="360" /> |
21
+ | [Token Matrix](token-matrix.tsx) | <img src="../docs/assets/examples/token-matrix_dark.png" alt="Token Matrix dark render" width="360" /> | <img src="../docs/assets/examples/token-matrix_light.png" alt="Token Matrix light render" width="360" /> |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vizmatic",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Theme-aware visual primitives and render pipeline for AI-generated diagrams, figures, and presentation frames.",
5
5
  "type": "module",
6
6
  "license": "MIT",