vizcraft 0.1.2 → 0.1.4

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,17 @@
1
1
  # vizcraft
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`10926fc`](https://github.com/ChipiKaf/vizcraft/commit/10926fcce211d00dfba2697eaac62948ac0ef69d) Thanks [@ChipiKaf](https://github.com/ChipiKaf)! - update readme
8
+
9
+ ## 0.1.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`7bae122`](https://github.com/ChipiKaf/vizcraft/commit/7bae122aa03cd25f55c8932d7c1c624d64ac2271) Thanks [@ChipiKaf](https://github.com/ChipiKaf)! - update readme
14
+
3
15
  ## 0.1.2
4
16
 
5
17
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # VizCraft
2
+
3
+ **A declarative, builder-based library for creating animated SVG network visualizations and algorithm demos.**
4
+
5
+ VizCraft is designed to make creating beautiful, animated node-link diagrams and complex visualizations intuitive and powerful. Whether you are building an educational tool, explaining an algorithm, or just need a great looking graph, VizCraft provides the primitives you need.
6
+
7
+ ## ✨ Features
8
+
9
+ - **Fluent Builder API**: Define your visualization scene using a readable, chainable API.
10
+ - **Grid System**: Built-in 2D grid system for easy, structured layout of nodes.
11
+ - **Declarative Animations**: Animate layout changes, edge flow, and node states with a simple declarative config.
12
+ - **Framework Agnostic**: The core logic is pure TypeScript and can be used with any framework or Vanilla JS.
13
+ - **Custom Overlays**: Create complex, custom UI elements that float on top of your visualization.
14
+
15
+ ## 📦 Installation
16
+
17
+ ```bash
18
+ npm install vizcraft
19
+ # or
20
+ pnpm add vizcraft
21
+ # or
22
+ yarn add vizcraft
23
+ ```
24
+
25
+ ## 🚀 Getting Started
26
+
27
+ You can use the core library directly to generate SVG content or mount to a DOM element.
28
+
29
+ ```typescript
30
+ import { VizBuilderImpl } from 'vizcraft';
31
+
32
+ // Create a builder instance
33
+ const builder = new VizBuilderImpl();
34
+
35
+ // Define your scene
36
+ builder
37
+ .view(500, 500)
38
+ .node('a')
39
+ .at(100, 100)
40
+ .circle(15)
41
+ .label('A')
42
+ .node('b')
43
+ .at(400, 100)
44
+ .circle(15)
45
+ .label('B')
46
+ .edge('a', 'b')
47
+ .arrow();
48
+
49
+ // Build the scene model
50
+ const scene = builder.build();
51
+
52
+ // Mount to a container
53
+ const container = document.getElementById('viz');
54
+ builder.mount(container);
55
+ ```
56
+
57
+ ## 📖 Core Concepts
58
+
59
+ ### The Builder (`VizBuilder`)
60
+
61
+ The heart of VizCraft is the `VizBuilder`. It allows you to construct a `VizScene` which acts as the blueprint for your visualization.
62
+
63
+ ```typescript
64
+ b.view(width, height) // Set the coordinate space
65
+ .grid(cols, rows) // (Optional) Define layout grid
66
+ .node(id) // Start defining a node
67
+ .edge(from, to); // Start defining an edge
68
+ ```
69
+
70
+ ### Nodes
71
+
72
+ Nodes are the primary entities in your graph. They can have shapes, labels, and styles.
73
+
74
+ ```typescript
75
+ b.node('n1')
76
+ .at(x, y) // Absolute position
77
+ // OR
78
+ .cell(col, row) // Grid position
79
+ .circle(radius) // Shape definition
80
+ .label('Text', { dy: 5 }) // Label with offset
81
+ .class('css-class') // Custom CSS class
82
+ .data({ ... }) // Attach custom data
83
+ ```
84
+
85
+ ### Edges
86
+
87
+ Edges connect nodes and can be styled, directed, or animated.
88
+
89
+ ```typescript
90
+ b.edge('n1', 'n2')
91
+ .arrow() // Add an arrowhead
92
+ .straight() // (Default) Straight line
93
+ .label('Connection')
94
+ .animate('flow'); // Add animation
95
+ ```
96
+
97
+ ### Animations
98
+
99
+ VizCraft supports declarative animations. You define _what_ happens, and the renderer handles the interpolation.
100
+
101
+ - **`stream`**: Particles flowing along an edge.
102
+ - **`pulse`**: Rhythmic scaling or opacity changes.
103
+ - **Transition**: Moving a node from one position to another.
104
+
105
+ ## 🎨 Styling
106
+
107
+ VizCraft generates standard SVG elements with predictable classes, making it easy to style with CSS.
108
+
109
+ ```css
110
+ /* Custom node style */
111
+ .viz-node-shape {
112
+ fill: #fff;
113
+ stroke: #333;
114
+ stroke-width: 2px;
115
+ }
116
+
117
+ /* Specific node class */
118
+ .my-node .viz-node-shape {
119
+ fill: #ff6b6b;
120
+ }
121
+
122
+ /* Edge styling */
123
+ .viz-edge {
124
+ stroke: #ccc;
125
+ stroke-width: 2;
126
+ }
127
+ ```
128
+
129
+ ## 🤝 Contributing
130
+
131
+ Contributions are welcome! This is a monorepo managed with Turbo.
132
+
133
+ 1. Clone the repo
134
+ 2. Install dependencies: `pnpm install`
135
+ 3. Run dev server: `pnpm dev`
136
+
137
+ ## 📄 License
138
+
139
+ MIT License © Chipili Kafwilo
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vizcraft",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "A fluent, type-safe SVG scene builder for composing nodes, edges, animations, and overlays with incremental DOM updates and no framework dependency.",
5
5
  "keywords": [
6
6
  "visualization",
@@ -28,6 +28,11 @@
28
28
  "module": "./dist/index.mjs",
29
29
  "types": "./dist/index.d.ts",
30
30
  "license": "MIT",
31
+ "files": [
32
+ "dist",
33
+ "README.md",
34
+ "CHANGELOG.md"
35
+ ],
31
36
  "devDependencies": {
32
37
  "typescript": "^5.9.3"
33
38
  },
@@ -1,4 +0,0 @@
1
-
2
- > vizcraft@0.1.2 build /home/runner/work/vizcraft/vizcraft/packages/core
3
- > tsc
4
-
package/src/animations.ts DELETED
@@ -1,53 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import type { VizNode, VizEdge, VizAnimSpec } from './types';
3
-
4
- export interface CoreAnimRendererContext<T = any> {
5
- spec: VizAnimSpec<T>;
6
- element: VizNode | VizEdge;
7
- }
8
-
9
- export interface CoreAnimRenderer<T = any> {
10
- getClass?: (ctx: CoreAnimRendererContext<T>) => string;
11
- getStyle?: (
12
- ctx: CoreAnimRendererContext<T>
13
- ) => Record<string, string | number>;
14
- }
15
-
16
- export class CoreAnimationRegistry {
17
- private nodeAnims = new Map<string, CoreAnimRenderer>();
18
- private edgeAnims = new Map<string, CoreAnimRenderer>();
19
-
20
- constructor() {}
21
-
22
- registerNode(id: string, renderer: CoreAnimRenderer) {
23
- this.nodeAnims.set(id, renderer);
24
- return this;
25
- }
26
-
27
- registerEdge(id: string, renderer: CoreAnimRenderer) {
28
- this.edgeAnims.set(id, renderer);
29
- return this;
30
- }
31
-
32
- getNodeRenderer(id: string): CoreAnimRenderer | undefined {
33
- return this.nodeAnims.get(id);
34
- }
35
-
36
- getEdgeRenderer(id: string): CoreAnimRenderer | undefined {
37
- return this.edgeAnims.get(id);
38
- }
39
- }
40
-
41
- // Default Implementations
42
- export const coreFlowAnimation: CoreAnimRenderer<{ duration?: string }> = {
43
- getClass: () => 'viz-anim-flow',
44
- getStyle: ({ spec }) => {
45
- const duration = spec.params?.duration ?? '2s';
46
- return {
47
- '--viz-anim-duration': duration,
48
- };
49
- },
50
- };
51
-
52
- export const defaultCoreAnimationRegistry =
53
- new CoreAnimationRegistry().registerEdge('flow', coreFlowAnimation);