geonodes-web-render 0.1.3 → 0.3.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.
@@ -4,9 +4,14 @@ export type GraphViewEmbedOptions = {
4
4
  /** Called when user requests close (e.g. modal close button). Use to unmount. */
5
5
  onClose?: () => void;
6
6
  };
7
- export declare function GraphView(props: GraphViewEmbedOptions): import("react/jsx-runtime").JSX.Element;
7
+ export declare function GraphView(props: GraphViewEmbedOptions): import("react").JSX.Element;
8
8
  /**
9
- * Mount the graph view into a DOM container. Call unmountGraphView() to remove.
9
+ * Mount the graph view into a DOM container. Returns a function that unmounts
10
+ * this graph; you can also call unmountGraphView(container).
10
11
  */
11
12
  export declare function mountGraphView(container: HTMLElement, options: GraphViewEmbedOptions): () => void;
12
- export declare function unmountGraphView(): void;
13
+ /**
14
+ * Unmount a previously mounted graph. With no argument, unmounts the most
15
+ * recently mounted one (kept for backwards compatibility).
16
+ */
17
+ export declare function unmountGraphView(container?: HTMLElement): void;
@@ -1,2 +1,2 @@
1
1
  import { NodeProps } from '@xyflow/react';
2
- export declare function GenericGNNode(props: NodeProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function GenericGNNode(props: NodeProps): import("react").JSX.Element;
@@ -2,4 +2,6 @@ export declare function GeometryNodesFlow(props: {
2
2
  jsonText: string;
3
3
  /** When false, hide the panel header ("Geometry Nodes Graph" and node count). Default true. */
4
4
  showHeader?: boolean;
5
- }): import("react/jsx-runtime").JSX.Element;
5
+ /** Reports the currently selected node ids (raw Tree Clipper node ids as strings). */
6
+ onSelectionChange?: (nodeIds: string[]) => void;
7
+ }): import("react").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { NodeProps } from '@xyflow/react';
2
- export declare function RerouteNode(props: NodeProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function RerouteNode(props: NodeProps): import("react").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { NodeProps } from '@xyflow/react';
2
- export declare function SimulationZoneFrame(props: NodeProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function SimulationZoneFrame(props: NodeProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Lets group nodes ask the surrounding flow to drill into their nested tree.
3
+ * Null outside a provider, so group nodes degrade to a plain name display.
4
+ */
5
+ export declare const GroupNavContext: import('react').Context<{
6
+ openGroup: (treeId: string) => void;
7
+ } | null>;
8
+ export declare function useGroupNav(): {
9
+ openGroup: (treeId: string) => void;
10
+ } | null;
@@ -0,0 +1,108 @@
1
+ type SpecParam = {
2
+ name: string;
3
+ default: string | null;
4
+ };
5
+ export type SpecSocket = {
6
+ attr: string;
7
+ type: string;
8
+ label: string;
9
+ };
10
+ export type SpecEntry = {
11
+ class: string;
12
+ params: SpecParam[];
13
+ props: SpecParam[];
14
+ inputs: SpecSocket[];
15
+ outputs: SpecSocket[];
16
+ };
17
+ export type SpecDb = Record<string, Record<string, SpecEntry>>;
18
+ export declare function getNodebpySpec(): SpecDb;
19
+ type RawSocket = {
20
+ id: number;
21
+ data: {
22
+ name: string;
23
+ type: string;
24
+ enabled?: boolean;
25
+ hide_value?: boolean;
26
+ default_value?: unknown;
27
+ };
28
+ };
29
+ type RawNodeData = {
30
+ name: string;
31
+ label?: string;
32
+ bl_idname: string;
33
+ inputs?: {
34
+ data: {
35
+ items: RawSocket[];
36
+ };
37
+ };
38
+ outputs?: {
39
+ data: {
40
+ items: RawSocket[];
41
+ };
42
+ };
43
+ node_tree?: number | null;
44
+ single_input?: number;
45
+ single_output?: number;
46
+ is_active_output?: boolean;
47
+ mapping?: unknown;
48
+ } & Record<string, unknown>;
49
+ type RawNode = {
50
+ id: number;
51
+ data: RawNodeData;
52
+ };
53
+ type RawInterfaceItem = {
54
+ id: number;
55
+ data: {
56
+ name: string;
57
+ socket_type?: string;
58
+ in_out?: string;
59
+ item_type?: string;
60
+ default_value?: unknown;
61
+ };
62
+ };
63
+ type RawLink = {
64
+ id: number;
65
+ data: {
66
+ from_socket: number;
67
+ to_socket: number;
68
+ };
69
+ };
70
+ type RawTree = {
71
+ id: number;
72
+ data: {
73
+ name: string;
74
+ bl_idname?: string;
75
+ is_modifier?: boolean;
76
+ interface?: {
77
+ data: {
78
+ items_tree: {
79
+ data: {
80
+ items: RawInterfaceItem[];
81
+ };
82
+ };
83
+ };
84
+ };
85
+ nodes: {
86
+ data: {
87
+ items: RawNode[];
88
+ };
89
+ };
90
+ links: {
91
+ data: {
92
+ items: RawLink[];
93
+ };
94
+ };
95
+ };
96
+ };
97
+ type RawExport = {
98
+ node_trees: RawTree[];
99
+ };
100
+ /**
101
+ * Reduce a Tree Clipper export to a subset of nodes (by raw node id), keeping
102
+ * only links whose two endpoints both survive. Group trees instantiated by a
103
+ * surviving group node are kept complete (transitively); trees left with no
104
+ * nodes are dropped. Returns the input unchanged when nothing matches.
105
+ */
106
+ export declare function filterExportToSelection(raw: RawExport, selected: ReadonlySet<number>): RawExport;
107
+ export declare function exportToNodebpy(raw: RawExport): string;
108
+ export {};
@@ -33,6 +33,7 @@ type BlenderNode = {
33
33
  single_input?: number;
34
34
  single_output?: number;
35
35
  vector?: number[];
36
+ node_tree?: number | null;
36
37
  mode?: string;
37
38
  operation?: string;
38
39
  data_type?: string;
@@ -74,23 +75,25 @@ type BlenderLink = {
74
75
  to_socket: number;
75
76
  };
76
77
  };
77
- export type BlenderTreeExport = {
78
- node_trees: Array<{
79
- id: number;
80
- data: {
81
- name: string;
82
- nodes: {
83
- data: {
84
- items: BlenderNode[];
85
- };
78
+ type BlenderTree = {
79
+ id: number;
80
+ data: {
81
+ name: string;
82
+ is_modifier?: boolean;
83
+ nodes: {
84
+ data: {
85
+ items: BlenderNode[];
86
86
  };
87
- links: {
88
- data: {
89
- items: BlenderLink[];
90
- };
87
+ };
88
+ links: {
89
+ data: {
90
+ items: BlenderLink[];
91
91
  };
92
92
  };
93
- }>;
93
+ };
94
+ };
95
+ export type BlenderTreeExport = {
96
+ node_trees: BlenderTree[];
94
97
  };
95
98
  export type NormalizedSocket = {
96
99
  id: string;
@@ -117,6 +120,9 @@ export type NormalizedNode = {
117
120
  outputs: NormalizedSocket[];
118
121
  floatCurve?: FloatCurveData;
119
122
  properties?: Record<string, string>;
123
+ /** For group nodes: id/name of the referenced node tree (if present in the export). */
124
+ groupTreeId?: string;
125
+ groupTreeName?: string;
120
126
  };
121
127
  export type NormalizedLink = {
122
128
  id: string;
@@ -129,6 +135,13 @@ export type NormalizedGraph = {
129
135
  nodes: NormalizedNode[];
130
136
  links: NormalizedLink[];
131
137
  };
138
+ export type NormalizedExport = {
139
+ /** Id of the top-level tree (the one not referenced by any group node). */
140
+ rootId: string;
141
+ /** All trees in the export, keyed by tree id. */
142
+ trees: Record<string, NormalizedGraph>;
143
+ };
144
+ export declare function normalizeBlenderExport(raw: BlenderTreeExport): NormalizedExport;
132
145
  export declare function normalizeBlenderGraph(raw: BlenderTreeExport): NormalizedGraph;
133
146
  export declare function toGraphIR(normalized: NormalizedGraph): GraphIR;
134
147
  export {};
@@ -47,6 +47,9 @@ export type NodeIR = {
47
47
  floatCurve?: FloatCurveData;
48
48
  /** Node-type-specific enum properties (e.g. operation, data_type for Compare) */
49
49
  properties?: Record<string, string>;
50
+ /** For group nodes: id/name of the referenced node tree within the export */
51
+ groupTreeId?: string;
52
+ groupTreeName?: string;
50
53
  };
51
54
  export type EdgeIR = {
52
55
  id: string;
@@ -10,6 +10,8 @@ export type GNFlowNodeData = {
10
10
  connectedInputIds: string[];
11
11
  floatCurve?: FloatCurveData;
12
12
  properties?: Record<string, string>;
13
+ groupTreeId?: string;
14
+ groupTreeName?: string;
13
15
  };
14
16
  export type GNRerouteNodeData = {
15
17
  color: string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Pretty-print a Tree Clipper export so that each repeated entity (a node tree,
3
+ * an interface socket, a node, a link) lands on its own line, while every
4
+ * structural wrapper around those entity lists stays collapsed inline.
5
+ *
6
+ * Only the entity arrays break across lines; the `{"id": …, "data": {… "items": [`
7
+ * prefix and the trailing `]}}` suffix each stay on a single line. The result:
8
+ * the number of lines in an entity list equals the number of entities, so
9
+ * selecting one more node on the canvas adds exactly one visible line.
10
+ *
11
+ * Entity lines can get very long; the editor scrolls horizontally rather than
12
+ * wrapping them, so they stay one-per-row on screen.
13
+ */
14
+ export declare function formatTreeClipperJson(value: unknown): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonodes-web-render",
3
- "version": "0.1.3",
3
+ "version": "0.3.0",
4
4
  "description": "Browser-based viewer for Blender Geometry Nodes exported via Tree Clipper. Renders node trees as a read-only, Blender-styled graph.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "https://github.com/kolibril13/geonodes-web-render"
18
+ "url": "git+https://github.com/kolibril13/geonodes-web-render.git"
19
19
  },
20
20
  "license": "MIT",
21
21
  "keywords": [
@@ -32,15 +32,17 @@
32
32
  "build:lib": "vite build --config vite.lib.config.ts",
33
33
  "lint": "eslint .",
34
34
  "preview": "vite preview",
35
+ "convert:nodebpy": "rolldown scripts/convertExamples.ts --format esm --file node_modules/.tmp/convertExamples.mjs --external node:fs --external node:path && node node_modules/.tmp/convertExamples.mjs",
35
36
  "prepublishOnly": "npm run build:lib"
36
37
  },
37
38
  "dependencies": {
38
39
  "@codemirror/lang-json": "^6.0.2",
40
+ "@codemirror/lang-python": "^6.2.1",
39
41
  "@codemirror/state": "^6.6.0",
40
42
  "@codemirror/theme-one-dark": "^6.1.3",
41
43
  "@codemirror/view": "^6.40.0",
42
44
  "@uiw/react-codemirror": "^4.25.8",
43
- "@xyflow/react": "^12.10.1",
45
+ "@xyflow/react": "^12.11.0",
44
46
  "react": "^18.0.0 || ^19.0.0",
45
47
  "react-dom": "^18.0.0 || ^19.0.0"
46
48
  },