vizcraft 0.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.
@@ -0,0 +1,4 @@
1
+
2
+ > vizcraft@0.1.1 build /home/runner/work/vizcraft/vizcraft/packages/core
3
+ > tsc
4
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # vizcraft
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0d9ea7c`](https://github.com/ChipiKaf/vizcraft/commit/0d9ea7c4a59ef8d629b0c126b709f331d0c15e20) Thanks [@ChipiKaf](https://github.com/ChipiKaf)! - update access in config to public
8
+
9
+ ## 0.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`184a4ae`](https://github.com/ChipiKaf/vizcraft/commit/184a4ae8d664aeb96296f73a5975a900a6155ad9) Thanks [@ChipiKaf](https://github.com/ChipiKaf)! - Initial release of Vizcraft, a fluent, type-safe SVG scene builder for composing nodes, edges, animations, and overlays with incremental DOM updates and no framework dependency.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chipili Kafwilo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ import type { VizNode, VizEdge, VizAnimSpec } from './types';
2
+ export interface CoreAnimRendererContext<T = any> {
3
+ spec: VizAnimSpec<T>;
4
+ element: VizNode | VizEdge;
5
+ }
6
+ export interface CoreAnimRenderer<T = any> {
7
+ getClass?: (ctx: CoreAnimRendererContext<T>) => string;
8
+ getStyle?: (ctx: CoreAnimRendererContext<T>) => Record<string, string | number>;
9
+ }
10
+ export declare class CoreAnimationRegistry {
11
+ private nodeAnims;
12
+ private edgeAnims;
13
+ constructor();
14
+ registerNode(id: string, renderer: CoreAnimRenderer): this;
15
+ registerEdge(id: string, renderer: CoreAnimRenderer): this;
16
+ getNodeRenderer(id: string): CoreAnimRenderer | undefined;
17
+ getEdgeRenderer(id: string): CoreAnimRenderer | undefined;
18
+ }
19
+ export declare const coreFlowAnimation: CoreAnimRenderer<{
20
+ duration?: string;
21
+ }>;
22
+ export declare const defaultCoreAnimationRegistry: CoreAnimationRegistry;
@@ -0,0 +1,30 @@
1
+ export class CoreAnimationRegistry {
2
+ nodeAnims = new Map();
3
+ edgeAnims = new Map();
4
+ constructor() { }
5
+ registerNode(id, renderer) {
6
+ this.nodeAnims.set(id, renderer);
7
+ return this;
8
+ }
9
+ registerEdge(id, renderer) {
10
+ this.edgeAnims.set(id, renderer);
11
+ return this;
12
+ }
13
+ getNodeRenderer(id) {
14
+ return this.nodeAnims.get(id);
15
+ }
16
+ getEdgeRenderer(id) {
17
+ return this.edgeAnims.get(id);
18
+ }
19
+ }
20
+ // Default Implementations
21
+ export const coreFlowAnimation = {
22
+ getClass: () => 'viz-anim-flow',
23
+ getStyle: ({ spec }) => {
24
+ const duration = spec.params?.duration ?? '2s';
25
+ return {
26
+ '--viz-anim-duration': duration,
27
+ };
28
+ },
29
+ };
30
+ export const defaultCoreAnimationRegistry = new CoreAnimationRegistry().registerEdge('flow', coreFlowAnimation);
@@ -0,0 +1,55 @@
1
+ import type { VizScene, VizNode, VizEdge, NodeLabel, EdgeLabel, AnimationConfig, VizGridConfig } from './types';
2
+ interface VizBuilder {
3
+ view(w: number, h: number): VizBuilder;
4
+ grid(cols: number, rows: number, padding?: {
5
+ x: number;
6
+ y: number;
7
+ }): VizBuilder;
8
+ overlay<T>(id: string, params: T, key?: string): VizBuilder;
9
+ node(id: string): NodeBuilder;
10
+ edge(from: string, to: string, id?: string): EdgeBuilder;
11
+ build(): VizScene;
12
+ _getGridConfig(): VizGridConfig | null;
13
+ _getViewBox(): {
14
+ w: number;
15
+ h: number;
16
+ };
17
+ svg(): string;
18
+ mount(container: HTMLElement): void;
19
+ }
20
+ interface NodeBuilder {
21
+ at(x: number, y: number): NodeBuilder;
22
+ cell(col: number, row: number, align?: 'center' | 'start' | 'end'): NodeBuilder;
23
+ circle(r: number): NodeBuilder;
24
+ rect(w: number, h: number, rx?: number): NodeBuilder;
25
+ diamond(w: number, h: number): NodeBuilder;
26
+ label(text: string, opts?: Partial<NodeLabel>): NodeBuilder;
27
+ class(name: string): NodeBuilder;
28
+ animate(type: string, config?: AnimationConfig): NodeBuilder;
29
+ data(payload: unknown): NodeBuilder;
30
+ onClick(handler: (id: string, node: VizNode) => void): NodeBuilder;
31
+ done(): VizBuilder;
32
+ node(id: string): NodeBuilder;
33
+ edge(from: string, to: string, id?: string): EdgeBuilder;
34
+ overlay<T>(id: string, params: T, key?: string): VizBuilder;
35
+ build(): VizScene;
36
+ svg(): string;
37
+ }
38
+ interface EdgeBuilder {
39
+ straight(): EdgeBuilder;
40
+ label(text: string, opts?: Partial<EdgeLabel>): EdgeBuilder;
41
+ arrow(enabled?: boolean): EdgeBuilder;
42
+ class(name: string): EdgeBuilder;
43
+ hitArea(px: number): EdgeBuilder;
44
+ animate(type: string, config?: AnimationConfig): EdgeBuilder;
45
+ data(payload: unknown): EdgeBuilder;
46
+ onClick(handler: (id: string, edge: VizEdge) => void): EdgeBuilder;
47
+ done(): VizBuilder;
48
+ node(id: string): NodeBuilder;
49
+ edge(from: string, to: string, id?: string): EdgeBuilder;
50
+ overlay<T>(id: string, params: T, key?: string): VizBuilder;
51
+ build(): VizScene;
52
+ svg(): string;
53
+ }
54
+ export declare function viz(): VizBuilder;
55
+ export {};