vibrante-node 2.5.1__py3-none-any.whl
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.
- src/core/__init__.py +0 -0
- src/core/engine.py +484 -0
- src/core/events.py +32 -0
- src/core/graph.py +74 -0
- src/core/integrity.py +925 -0
- src/core/loader.py +56 -0
- src/core/manifest.py +910 -0
- src/core/models.py +59 -0
- src/core/persistence.py +27 -0
- src/core/python_to_workflow.py +182 -0
- src/core/registry.py +314 -0
- src/core/workflow_to_python.py +801 -0
- src/main.py +188 -0
- src/models/__init__.py +0 -0
- src/nodes/__init__.py +0 -0
- src/nodes/ai/__init__.py +1 -0
- src/nodes/base.py +174 -0
- src/nodes/builtins/__init__.py +0 -0
- src/nodes/builtins/group_node.py +210 -0
- src/nodes/builtins/nodes.py +452 -0
- src/nodes/print.py +19 -0
- src/nodes/test.py +19 -0
- src/ui/__init__.py +0 -0
- src/ui/canvas/__init__.py +0 -0
- src/ui/canvas/backdrop.py +223 -0
- src/ui/canvas/canvas_search_bar.py +222 -0
- src/ui/canvas/edge.py +98 -0
- src/ui/canvas/mini_map.py +138 -0
- src/ui/canvas/node_search_popup.py +270 -0
- src/ui/canvas/scene.py +1149 -0
- src/ui/canvas/sticky_note.py +123 -0
- src/ui/canvas/view.py +285 -0
- src/ui/code_editor.py +435 -0
- src/ui/export_python_dialog.py +490 -0
- src/ui/gemini_api_dialog.py +41 -0
- src/ui/gemini_chat.py +370 -0
- src/ui/import_python_dialog.py +122 -0
- src/ui/library_panel.py +246 -0
- src/ui/log_panel.py +315 -0
- src/ui/node_builder.py +841 -0
- src/ui/node_widget.py +1009 -0
- src/ui/port_widget.py +116 -0
- src/ui/script_editor.py +53 -0
- src/ui/scripting_console.py +270 -0
- src/ui/settings_window.py +575 -0
- src/ui/window.py +2012 -0
- src/utils/color_manager.py +50 -0
- src/utils/config_manager.py +71 -0
- src/utils/env_manager.py +232 -0
- src/utils/highlighter.py +110 -0
- src/utils/paths.py +30 -0
- src/utils/prism_config.py +300 -0
- src/utils/prism_core.py +80 -0
- src/utils/qt_compat.py +159 -0
- src/utils/runtime.py +80 -0
- vibrante_node/CLA.md +96 -0
- vibrante_node/COMMERCIAL_LICENSE.md +170 -0
- vibrante_node/LICENSE +178 -0
- vibrante_node/LICENSES/AGPL-3.0.txt +661 -0
- vibrante_node/LICENSES/CC-BY-4.0-SCOPE.md +53 -0
- vibrante_node/LICENSES/CC-BY-4.0.txt +396 -0
- vibrante_node/LICENSES/GPL-3.0.txt +674 -0
- vibrante_node/LICENSES/LGPL-3.0.txt +165 -0
- vibrante_node/LICENSES/README.md +65 -0
- vibrante_node/THIRD_PARTY_NOTICES.txt +3277 -0
- vibrante_node/__init__.py +2 -0
- vibrante_node/app.py +60 -0
- vibrante_node/docs/AUTOMATION_API.html +785 -0
- vibrante_node/docs/DEVELOPER.html +891 -0
- vibrante_node/docs/DOCUMENTATION.html +2761 -0
- vibrante_node/docs/LICENSE.txt +35 -0
- vibrante_node/docs/NODE_BUILDER_API.html +1155 -0
- vibrante_node/docs/RELEASE_v1.0.5.html +140 -0
- vibrante_node/docs/RELEASE_v1.1.0.html +163 -0
- vibrante_node/docs/RELEASE_v1.1.5.html +286 -0
- vibrante_node/docs/RELEASE_v1.2.0.html +175 -0
- vibrante_node/docs/RELEASE_v1.3.0.html +168 -0
- vibrante_node/docs/RELEASE_v1.4.0.html +160 -0
- vibrante_node/docs/RELEASE_v1.5.0.html +432 -0
- vibrante_node/docs/RELEASE_v1.6.0.html +293 -0
- vibrante_node/docs/RELEASE_v1.6.1.html +171 -0
- vibrante_node/docs/RELEASE_v1.7.0.html +270 -0
- vibrante_node/docs/RELEASE_v1.8.0.html +201 -0
- vibrante_node/docs/RELEASE_v1.8.1.html +124 -0
- vibrante_node/docs/RELEASE_v1.8.2.html +119 -0
- vibrante_node/docs/RELEASE_v1.8.3.html +125 -0
- vibrante_node/docs/RELEASE_v1.8.4.html +210 -0
- vibrante_node/docs/RELEASE_v1.8.5.html +223 -0
- vibrante_node/docs/RELEASE_v2.0.0.html +284 -0
- vibrante_node/docs/RELEASE_v2.1.0.html +259 -0
- vibrante_node/docs/RELEASE_v2.1.1.html +156 -0
- vibrante_node/docs/RELEASE_v2.2.0.html +369 -0
- vibrante_node/docs/RELEASE_v2.2.1.html +168 -0
- vibrante_node/docs/RELEASE_v2.3.0.html +185 -0
- vibrante_node/docs/RELEASE_v2.4.0.html +446 -0
- vibrante_node/docs/RELEASE_v2.5.0.html +478 -0
- vibrante_node/docs/RELEASE_v2.5.1.html +190 -0
- vibrante_node/docs/USER_GUIDE.html +1407 -0
- vibrante_node/docs/index.html +103 -0
- vibrante_node/docs/portal/01_introduction.html +1177 -0
- vibrante_node/docs/portal/02_getting_started.html +1267 -0
- vibrante_node/docs/portal/03_user_guide.html +1736 -0
- vibrante_node/docs/portal/04_workflow_tutorials.html +1473 -0
- vibrante_node/docs/portal/05_node_development.html +1562 -0
- vibrante_node/docs/portal/06_backend_architecture.html +1373 -0
- vibrante_node/docs/portal/07_frontend_architecture.html +1588 -0
- vibrante_node/docs/portal/08_api_reference.html +2336 -0
- vibrante_node/docs/portal/09_advanced_topics.html +1664 -0
- vibrante_node/docs/portal/10_contribution_guide.html +1263 -0
- vibrante_node/docs/portal/11_troubleshooting.html +1108 -0
- vibrante_node/docs/portal/12_examples_library.html +1498 -0
- vibrante_node/docs/portal/13_general_purpose_automation.html +1472 -0
- vibrante_node/docs/portal/14_custom_nodes_api.html +1960 -0
- vibrante_node/docs/portal/index.html +605 -0
- vibrante_node/docs/portal/integrations_blender.html +605 -0
- vibrante_node/docs/portal/integrations_deadline.html +536 -0
- vibrante_node/docs/portal/integrations_houdini.html +787 -0
- vibrante_node/docs/portal/integrations_maya.html +675 -0
- vibrante_node/docs/portal/integrations_prism.html +628 -0
- vibrante_node/docs/portal/search.json +1 -0
- vibrante_node/docs/validation.json +333 -0
- vibrante_node/examples/arnold_lighting/orchestration_notes.md +45 -0
- vibrante_node/examples/arnold_lighting/prompt.md +47 -0
- vibrante_node/examples/automation/01_linear_chain.py +10 -0
- vibrante_node/examples/automation/02_batch_update_prefix.py +8 -0
- vibrante_node/examples/automation/03_reset_scene.py +5 -0
- vibrante_node/examples/automation/04_batch_execution.py +9 -0
- vibrante_node/examples/automation/05_git_backup.py +6 -0
- vibrante_node/examples/automation/06_reset_math_nodes.py +12 -0
- vibrante_node/examples/automation/07_stress_test_grid.py +8 -0
- vibrante_node/examples/automation/08_scene_summary.py +8 -0
- vibrante_node/examples/automation/09_toggle_bools.py +8 -0
- vibrante_node/examples/automation/10_session_report.py +7 -0
- vibrante_node/examples/automation/11_simple_math_node.py +7 -0
- vibrante_node/examples/cinematic_camera/orchestration_notes.md +56 -0
- vibrante_node/examples/cinematic_camera/prompt.md +50 -0
- vibrante_node/examples/cinematic_explosion/orchestration_notes.md +76 -0
- vibrante_node/examples/cinematic_explosion/prompt.md +47 -0
- vibrante_node/examples/cinematic_explosion/review.md +75 -0
- vibrante_node/examples/dust_wave/orchestration_notes.md +43 -0
- vibrante_node/examples/dust_wave/prompt.md +40 -0
- vibrante_node/examples/nodes/async_delay.py +21 -0
- vibrante_node/examples/nodes/connection_logger.py +25 -0
- vibrante_node/examples/nodes/data_filter.py +19 -0
- vibrante_node/examples/nodes/dict_merge.py +20 -0
- vibrante_node/examples/nodes/dict_summary.py +21 -0
- vibrante_node/examples/nodes/dropdown_selector.py +29 -0
- vibrante_node/examples/nodes/env_reader.py +18 -0
- vibrante_node/examples/nodes/list_item_picker.py +85 -0
- vibrante_node/examples/nodes/list_stats.py +27 -0
- vibrante_node/examples/nodes/logic_threshold.py +23 -0
- vibrante_node/examples/nodes/math_square.py +30 -0
- vibrante_node/examples/nodes/random_list.py +18 -0
- vibrante_node/examples/nodes/reactive_config.py +24 -0
- vibrante_node/examples/nodes/safety_reset.py +31 -0
- vibrante_node/examples/nodes/string_reverse.py +16 -0
- vibrante_node/icons/210429_DeadlineFreeOn10RenderMachines.jpg +0 -0
- vibrante_node/icons/README.md +39 -0
- vibrante_node/icons/blender_icon.png +0 -0
- vibrante_node/icons/braces.png +0 -0
- vibrante_node/icons/braces.svg +1 -0
- vibrante_node/icons/builder.png +0 -0
- vibrante_node/icons/check.png +0 -0
- vibrante_node/icons/check.svg +1 -0
- vibrante_node/icons/chevron-right.svg +3 -0
- vibrante_node/icons/code.png +0 -0
- vibrante_node/icons/code.svg +4 -0
- vibrante_node/icons/computer-window.png +0 -0
- vibrante_node/icons/data.png +0 -0
- vibrante_node/icons/data.svg +5 -0
- vibrante_node/icons/database-search.png +0 -0
- vibrante_node/icons/database-search.svg +5 -0
- vibrante_node/icons/database-zap.png +0 -0
- vibrante_node/icons/database-zap.svg +5 -0
- vibrante_node/icons/database.png +0 -0
- vibrante_node/icons/database.svg +5 -0
- vibrante_node/icons/dice.png +0 -0
- vibrante_node/icons/dice.svg +1 -0
- vibrante_node/icons/divide.svg +5 -0
- vibrante_node/icons/file-input.svg +6 -0
- vibrante_node/icons/file-plus.png +0 -0
- vibrante_node/icons/file-plus.svg +6 -0
- vibrante_node/icons/file-text.png +0 -0
- vibrante_node/icons/file-text.svg +7 -0
- vibrante_node/icons/folder-plus.png +0 -0
- vibrante_node/icons/folder-plus.svg +5 -0
- vibrante_node/icons/folder.png +0 -0
- vibrante_node/icons/folder.svg +3 -0
- vibrante_node/icons/gear.png +0 -0
- vibrante_node/icons/gear.svg +1 -0
- vibrante_node/icons/git-branch.svg +6 -0
- vibrante_node/icons/hash.png +0 -0
- vibrante_node/icons/hash.svg +1 -0
- vibrante_node/icons/houdini.svg +4 -0
- vibrante_node/icons/houdini_icon.png +0 -0
- vibrante_node/icons/http.png +0 -0
- vibrante_node/icons/list-check.png +0 -0
- vibrante_node/icons/list-check.svg +7 -0
- vibrante_node/icons/list-plus.svg +10 -0
- vibrante_node/icons/list.png +0 -0
- vibrante_node/icons/list.svg +8 -0
- vibrante_node/icons/logic.png +0 -0
- vibrante_node/icons/logic.svg +7 -0
- vibrante_node/icons/math.png +0 -0
- vibrante_node/icons/math.svg +4 -0
- vibrante_node/icons/maya_icon.jpg +0 -0
- vibrante_node/icons/message.png +0 -0
- vibrante_node/icons/message.svg +3 -0
- vibrante_node/icons/minus.svg +3 -0
- vibrante_node/icons/multiply.png +0 -0
- vibrante_node/icons/multiply.svg +1 -0
- vibrante_node/icons/online-library.png +0 -0
- vibrante_node/icons/percentage.svg +5 -0
- vibrante_node/icons/plus.png +0 -0
- vibrante_node/icons/plus.svg +1 -0
- vibrante_node/icons/print.png +0 -0
- vibrante_node/icons/print.svg +5 -0
- vibrante_node/icons/prism_icon.png +0 -0
- vibrante_node/icons/refresh.svg +6 -0
- vibrante_node/icons/repeat.svg +6 -0
- vibrante_node/icons/scales.png +0 -0
- vibrante_node/icons/scales.svg +1 -0
- vibrante_node/icons/shuffle.svg +7 -0
- vibrante_node/icons/string.png +0 -0
- vibrante_node/icons/string.svg +5 -0
- vibrante_node/icons/terminal.png +0 -0
- vibrante_node/icons/terminal.svg +1 -0
- vibrante_node/icons/timer.png +0 -0
- vibrante_node/icons/timer.svg +4 -0
- vibrante_node/icons/toggle-switch.svg +5 -0
- vibrante_node/icons/uppercase.png +0 -0
- vibrante_node/icons/uppercase.svg +1 -0
- vibrante_node/icons/variable-get.svg +4 -0
- vibrante_node/icons/variable-set.svg +6 -0
- vibrante_node/icons/variable.png +0 -0
- vibrante_node/icons/variable.svg +5 -0
- vibrante_node/icons/vibrante-node-icon.png +0 -0
- vibrante_node/icons/vibrante-node-logo.png +0 -0
- vibrante_node/icons/vibrante-node-main_logo.png +0 -0
- vibrante_node/icons/vibrante-node-resize_main_logo.png +0 -0
- vibrante_node/logo.png +0 -0
- vibrante_node/mcp_cli.py +36 -0
- vibrante_node/node_examples/Split_String.json +35 -0
- vibrante_node/node_examples/async_delay.json +32 -0
- vibrante_node/node_examples/delay_timer.json +29 -0
- vibrante_node/node_examples/file_reader.json +29 -0
- vibrante_node/node_examples/fruit_selector.json +37 -0
- vibrante_node/node_examples/json_parser.json +29 -0
- vibrante_node/node_examples/line_counter.json +29 -0
- vibrante_node/node_examples/list_append.json +32 -0
- vibrante_node/node_examples/list_images_recursive.json +55 -0
- vibrante_node/node_examples/logic_and.json +34 -0
- vibrante_node/node_examples/logic_compare.json +36 -0
- vibrante_node/node_examples/math_abs.json +29 -0
- vibrante_node/node_examples/math_add.json +32 -0
- vibrante_node/node_examples/reactive_config.json +28 -0
- vibrante_node/node_examples/string_uppercase.json +29 -0
- vibrante_node/nodes/Dropdown_Selector.json +27 -0
- vibrante_node/nodes/add_integers.json +34 -0
- vibrante_node/nodes/blender_action_bake_animation.json +23 -0
- vibrante_node/nodes/blender_action_custom.json +21 -0
- vibrante_node/nodes/blender_action_export_alembic.json +22 -0
- vibrante_node/nodes/blender_action_export_fbx.json +23 -0
- vibrante_node/nodes/blender_action_export_gltf.json +21 -0
- vibrante_node/nodes/blender_action_export_obj.json +19 -0
- vibrante_node/nodes/blender_action_export_usd.json +23 -0
- vibrante_node/nodes/blender_action_import_alembic.json +18 -0
- vibrante_node/nodes/blender_action_import_fbx.json +18 -0
- vibrante_node/nodes/blender_action_import_gltf.json +18 -0
- vibrante_node/nodes/blender_action_import_obj.json +18 -0
- vibrante_node/nodes/blender_action_new_blend.json +18 -0
- vibrante_node/nodes/blender_action_open_blend.json +18 -0
- vibrante_node/nodes/blender_action_render.json +23 -0
- vibrante_node/nodes/blender_action_save_blend.json +18 -0
- vibrante_node/nodes/blender_action_scene_info.json +17 -0
- vibrante_node/nodes/blender_action_set_frame_range.json +20 -0
- vibrante_node/nodes/blender_action_set_render_settings.json +27 -0
- vibrante_node/nodes/blender_get_action_result.json +22 -0
- vibrante_node/nodes/blender_headless.json +86 -0
- vibrante_node/nodes/compare.json +48 -0
- vibrante_node/nodes/console_print.json +29 -0
- vibrante_node/nodes/create_dictionary.json +18 -0
- vibrante_node/nodes/create_folder.json +17 -0
- vibrante_node/nodes/create_list.json +18 -0
- vibrante_node/nodes/deadline_blender_submit.json +38 -0
- vibrante_node/nodes/deadline_houdini_submit.json +38 -0
- vibrante_node/nodes/deadline_job_status.json +28 -0
- vibrante_node/nodes/deadline_maya_submit.json +40 -0
- vibrante_node/nodes/delay_timer.json +26 -0
- vibrante_node/nodes/example_random_float.json +35 -0
- vibrante_node/nodes/file_append.json +18 -0
- vibrante_node/nodes/file_write.json +18 -0
- vibrante_node/nodes/for_loop.json +46 -0
- vibrante_node/nodes/get_dict_value.json +19 -0
- vibrante_node/nodes/get_list_item.json +19 -0
- vibrante_node/nodes/houdini_action_bake_animation.json +20 -0
- vibrante_node/nodes/houdini_action_custom.json +20 -0
- vibrante_node/nodes/houdini_action_export_alembic.json +20 -0
- vibrante_node/nodes/houdini_action_export_camera_alembic.json +20 -0
- vibrante_node/nodes/houdini_action_export_fbx.json +18 -0
- vibrante_node/nodes/houdini_action_import_alembic.json +18 -0
- vibrante_node/nodes/houdini_action_import_camera.json +17 -0
- vibrante_node/nodes/houdini_action_import_fbx.json +18 -0
- vibrante_node/nodes/houdini_action_import_obj.json +18 -0
- vibrante_node/nodes/houdini_action_new_hip.json +16 -0
- vibrante_node/nodes/houdini_action_open_hip.json +17 -0
- vibrante_node/nodes/houdini_action_save_hip.json +17 -0
- vibrante_node/nodes/houdini_action_scene_info.json +16 -0
- vibrante_node/nodes/houdini_action_set_frame_range.json +18 -0
- vibrante_node/nodes/houdini_get_action_result.json +21 -0
- vibrante_node/nodes/houdini_headless.json +85 -0
- vibrante_node/nodes/houdini_scene_snapshot.json +41 -0
- vibrante_node/nodes/http_request.json +76 -0
- vibrante_node/nodes/if_condition.json +45 -0
- vibrante_node/nodes/list_directory.json +17 -0
- vibrante_node/nodes/list_images_recursive.json +41 -0
- vibrante_node/nodes/list_item_picker.json +41 -0
- vibrante_node/nodes/list_length.json +17 -0
- vibrante_node/nodes/logical_gate.json +45 -0
- vibrante_node/nodes/loop_body.json +62 -0
- vibrante_node/nodes/math_add.json +17 -0
- vibrante_node/nodes/math_divide.json +17 -0
- vibrante_node/nodes/math_modulo.json +17 -0
- vibrante_node/nodes/math_multiply.json +36 -0
- vibrante_node/nodes/math_subtract.json +17 -0
- vibrante_node/nodes/maya_action_assign_material.json +18 -0
- vibrante_node/nodes/maya_action_bake_animation.json +21 -0
- vibrante_node/nodes/maya_action_create_render_layer.json +19 -0
- vibrante_node/nodes/maya_action_custom.json +20 -0
- vibrante_node/nodes/maya_action_export_alembic.json +22 -0
- vibrante_node/nodes/maya_action_export_camera_alembic.json +20 -0
- vibrante_node/nodes/maya_action_export_fbx.json +18 -0
- vibrante_node/nodes/maya_action_import_alembic.json +17 -0
- vibrante_node/nodes/maya_action_import_camera.json +17 -0
- vibrante_node/nodes/maya_action_import_fbx.json +17 -0
- vibrante_node/nodes/maya_action_import_obj.json +17 -0
- vibrante_node/nodes/maya_action_list_references.json +16 -0
- vibrante_node/nodes/maya_action_new_scene.json +16 -0
- vibrante_node/nodes/maya_action_open_scene.json +18 -0
- vibrante_node/nodes/maya_action_playblast.json +22 -0
- vibrante_node/nodes/maya_action_reference_alembic.json +18 -0
- vibrante_node/nodes/maya_action_reference_scene.json +18 -0
- vibrante_node/nodes/maya_action_save_scene.json +18 -0
- vibrante_node/nodes/maya_action_scene_info.json +16 -0
- vibrante_node/nodes/maya_action_set_aovs.json +18 -0
- vibrante_node/nodes/maya_action_set_frame_range.json +18 -0
- vibrante_node/nodes/maya_action_set_render_settings.json +23 -0
- vibrante_node/nodes/maya_get_action_result.json +21 -0
- vibrante_node/nodes/maya_headless.json +27 -0
- vibrante_node/nodes/mcp_call_tool.json +19 -0
- vibrante_node/nodes/mcp_list_tools.json +18 -0
- vibrante_node/nodes/mcp_server_init.json +23 -0
- vibrante_node/nodes/message_node.json +32 -0
- vibrante_node/nodes/prism_add_integration.json +49 -0
- vibrante_node/nodes/prism_build_entity.json +45 -0
- vibrante_node/nodes/prism_change_project.json +37 -0
- vibrante_node/nodes/prism_core_info.json +37 -0
- vibrante_node/nodes/prism_core_init.json +46 -0
- vibrante_node/nodes/prism_create_category.json +44 -0
- vibrante_node/nodes/prism_create_entity.json +60 -0
- vibrante_node/nodes/prism_create_playblast.json +56 -0
- vibrante_node/nodes/prism_create_product_version.json +64 -0
- vibrante_node/nodes/prism_create_project.json +50 -0
- vibrante_node/nodes/prism_create_scene_from_preset.json +59 -0
- vibrante_node/nodes/prism_eval.json +42 -0
- vibrante_node/nodes/prism_get_aovs.json +29 -0
- vibrante_node/nodes/prism_get_asset_by_name.json +69 -0
- vibrante_node/nodes/prism_get_asset_type_by_name.json +62 -0
- vibrante_node/nodes/prism_get_asset_types_by_project.json +55 -0
- vibrante_node/nodes/prism_get_assets_by_project.json +41 -0
- vibrante_node/nodes/prism_get_assets_by_type.json +69 -0
- vibrante_node/nodes/prism_get_config.json +48 -0
- vibrante_node/nodes/prism_get_current_scene.json +37 -0
- vibrante_node/nodes/prism_get_departments.json +37 -0
- vibrante_node/nodes/prism_get_entity_info.json +69 -0
- vibrante_node/nodes/prism_get_entity_path.json +69 -0
- vibrante_node/nodes/prism_get_export_path.json +26 -0
- vibrante_node/nodes/prism_get_latest_product_path.json +34 -0
- vibrante_node/nodes/prism_get_media.json +29 -0
- vibrante_node/nodes/prism_get_media_versions.json +33 -0
- vibrante_node/nodes/prism_get_plugin.json +35 -0
- vibrante_node/nodes/prism_get_preset_scenes.json +35 -0
- vibrante_node/nodes/prism_get_product_versions.json +33 -0
- vibrante_node/nodes/prism_get_products.json +29 -0
- vibrante_node/nodes/prism_get_project_by_name.json +55 -0
- vibrante_node/nodes/prism_get_project_config_path.json +26 -0
- vibrante_node/nodes/prism_get_scene_files.json +45 -0
- vibrante_node/nodes/prism_get_scene_path.json +23 -0
- vibrante_node/nodes/prism_get_sequence_by_project.json +48 -0
- vibrante_node/nodes/prism_get_sequences_by_project.json +41 -0
- vibrante_node/nodes/prism_get_shot_by_name.json +62 -0
- vibrante_node/nodes/prism_get_shot_by_sequence.json +55 -0
- vibrante_node/nodes/prism_get_shot_info.json +69 -0
- vibrante_node/nodes/prism_get_shots.json +29 -0
- vibrante_node/nodes/prism_get_shots_by_project_sequence.json +48 -0
- vibrante_node/nodes/prism_get_shots_by_sequence.json +48 -0
- vibrante_node/nodes/prism_get_tasks.json +39 -0
- vibrante_node/nodes/prism_import_product.json +37 -0
- vibrante_node/nodes/prism_list_plugins.json +25 -0
- vibrante_node/nodes/prism_list_projects.json +25 -0
- vibrante_node/nodes/prism_login_token.json +33 -0
- vibrante_node/nodes/prism_monkey_patch.json +46 -0
- vibrante_node/nodes/prism_open_scene.json +33 -0
- vibrante_node/nodes/prism_popup.json +40 -0
- vibrante_node/nodes/prism_register_callback.json +58 -0
- vibrante_node/nodes/prism_save_scene_version.json +90 -0
- vibrante_node/nodes/prism_send_cmd.json +54 -0
- vibrante_node/nodes/prism_set_config.json +55 -0
- vibrante_node/nodes/prism_studio_assign_project.json +43 -0
- vibrante_node/nodes/prism_trigger_callback.json +42 -0
- vibrante_node/nodes/prism_usd_department_layer_path.json +35 -0
- vibrante_node/nodes/prism_usd_entity_path.json +29 -0
- vibrante_node/nodes/prism_usd_sublayer_path.json +41 -0
- vibrante_node/nodes/prism_usd_update_department_layer.json +33 -0
- vibrante_node/nodes/prism_usd_update_sublayer.json +33 -0
- vibrante_node/nodes/python_script.json +17 -0
- vibrante_node/nodes/scene_intent_extractor.json +25 -0
- vibrante_node/nodes/set_dict_value.json +20 -0
- vibrante_node/nodes/string_concat.json +47 -0
- vibrante_node/nodes/string_length.json +16 -0
- vibrante_node/nodes/string_lowercase.json +16 -0
- vibrante_node/nodes/string_replace.json +18 -0
- vibrante_node/nodes/string_split.json +17 -0
- vibrante_node/nodes/string_uppercase.json +16 -0
- vibrante_node/nodes/variable_node.json +42 -0
- vibrante_node/nodes/while_loop.json +18 -0
- vibrante_node/splash.png +0 -0
- vibrante_node/vfx_workflows/01_prism_project_overview.json +492 -0
- vibrante_node/vfx_workflows/02_maya_asset_publish.json +776 -0
- vibrante_node/vfx_workflows/03_multi_shot_alembic_export.json +856 -0
- vibrante_node/vfx_workflows/04_deadline_render_pipeline.json +994 -0
- vibrante_node/vfx_workflows/05_houdini_fx_pipeline.json +1056 -0
- vibrante_node/vfx_workflows/06_blender_multi_format_export.json +1206 -0
- vibrante_node/website_examples/database_query.json +69 -0
- vibrante_node/website_examples/email_notification.json +104 -0
- vibrante_node/website_examples/file_batch_processor.json +62 -0
- vibrante_node/website_examples/folder_monitor.json +55 -0
- vibrante_node/website_examples/hou_sop_chain.json +69 -0
- vibrante_node/website_examples/http_request.json +90 -0
- vibrante_node/website_examples/image_resizer.json +90 -0
- vibrante_node/website_examples/llm_text_generation.json +90 -0
- vibrante_node/website_examples/prism_multi_asset_publisher.json +76 -0
- vibrante_node/website_examples/regex_replace.json +69 -0
- vibrante_node/workflows/If_condition.json +134 -0
- vibrante_node/workflows/Maya_WorkFlow.json +464 -0
- vibrante_node/workflows/asset_intelligence_pipeline.json +259 -0
- vibrante_node/workflows/concat_string_with_loop.json +262 -0
- vibrante_node/workflows/delay_time.json +74 -0
- vibrante_node/workflows/example_workflow_maya_prism_demo.json +503 -0
- vibrante_node/workflows/example_workflow_prism_demo.json +276 -0
- vibrante_node/workflows/example_workflow_prism_demo_02.json +221 -0
- vibrante_node/workflows/extract_FPS_from_maya_scene.json +265 -0
- vibrante_node/workflows/for_each.json +260 -0
- vibrante_node/workflows/get_list_item.json +151 -0
- vibrante_node/workflows/hou_mcp_scene_context_demo.json +67 -0
- vibrante_node/workflows/list_recursive_images.json +103 -0
- vibrante_node/workflows/logic_if_example.json +262 -0
- vibrante_node/workflows/logic_if_with_variables.json +210 -0
- vibrante_node/workflows/loop_break_example.json +197 -0
- vibrante_node/workflows/loop_operation_example.json +382 -0
- vibrante_node/workflows/mcp_list_tools_demo.json +90 -0
- vibrante_node/workflows/prism_assets_workflow.json +131 -0
- vibrante_node/workflows/python_script_node.json +89 -0
- vibrante_node/workflows/run_in_sequence.json +158 -0
- vibrante_node/workflows/scene_intent_pipeline.json +134 -0
- vibrante_node/workflows/scene_planning_pipeline.json +258 -0
- vibrante_node/workflows/semantic_scene_intent.json +96 -0
- vibrante_node/workflows/setup_maya_scene.json +352 -0
- vibrante_node/workflows/tutorial_maya_headless_prism_pipeline.json +593 -0
- vibrante_node/workflows/two_way_switch.json +341 -0
- vibrante_node/workflows/while_loop_class_example.json +192 -0
- vibrante_node/workflows/while_loop_example.json +184 -0
- vibrante_node/workflows/while_loop_retry_example.json +276 -0
- vibrante_node-2.5.1.dist-info/METADATA +715 -0
- vibrante_node-2.5.1.dist-info/RECORD +487 -0
- vibrante_node-2.5.1.dist-info/WHEEL +5 -0
- vibrante_node-2.5.1.dist-info/entry_points.txt +3 -0
- vibrante_node-2.5.1.dist-info/licenses/CLA.md +96 -0
- vibrante_node-2.5.1.dist-info/licenses/COMMERCIAL_LICENSE.md +170 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSE +178 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/AGPL-3.0.txt +661 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0-SCOPE.md +53 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0.txt +396 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/GPL-3.0.txt +674 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/LGPL-3.0.txt +165 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/README.md +65 -0
- vibrante_node-2.5.1.dist-info/top_level.txt +2 -0
src/ui/node_builder.py
ADDED
|
@@ -0,0 +1,841 @@
|
|
|
1
|
+
from src.utils.qt_compat import QtWidgets, QtCore, QtGui
|
|
2
|
+
|
|
3
|
+
QDialog = QtWidgets.QDialog
|
|
4
|
+
QVBoxLayout = QtWidgets.QVBoxLayout
|
|
5
|
+
QHBoxLayout = QtWidgets.QHBoxLayout
|
|
6
|
+
QLineEdit = QtWidgets.QLineEdit
|
|
7
|
+
QTextEdit = QtWidgets.QTextEdit
|
|
8
|
+
QTableWidget = QtWidgets.QTableWidget
|
|
9
|
+
QTableWidgetItem = QtWidgets.QTableWidgetItem
|
|
10
|
+
QPlainTextEdit = QtWidgets.QPlainTextEdit
|
|
11
|
+
QPushButton = QtWidgets.QPushButton
|
|
12
|
+
QLabel = QtWidgets.QLabel
|
|
13
|
+
QSplitter = QtWidgets.QSplitter
|
|
14
|
+
QWidget = QtWidgets.QWidget
|
|
15
|
+
QMessageBox = QtWidgets.QMessageBox
|
|
16
|
+
QFileDialog = QtWidgets.QFileDialog
|
|
17
|
+
QComboBox = QtWidgets.QComboBox
|
|
18
|
+
|
|
19
|
+
QCheckBox = QtWidgets.QCheckBox
|
|
20
|
+
QScrollArea = QtWidgets.QScrollArea
|
|
21
|
+
|
|
22
|
+
Qt = QtCore.Qt
|
|
23
|
+
QTimer = QtCore.QTimer
|
|
24
|
+
import os
|
|
25
|
+
import re
|
|
26
|
+
import ast
|
|
27
|
+
from src.core.loader import ScriptLoader
|
|
28
|
+
from src.core.registry import NodeRegistry
|
|
29
|
+
from src.core.models import NodeDefinitionJSON, PortModel
|
|
30
|
+
from src.ui.code_editor import CodeEditor
|
|
31
|
+
from src.ui.gemini_chat import GeminiChatWidget
|
|
32
|
+
from src.utils.hou_bridge import get_bridge, is_available
|
|
33
|
+
from src.utils.paths import app_dir
|
|
34
|
+
|
|
35
|
+
AVAILABLE_WIDGETS = ["", "text", "text_area", "int", "float", "bool", "dropdown", "slider", "file"]
|
|
36
|
+
AVAILABLE_TYPES = ["any", "int", "float", "string", "bool", "list", "dict"]
|
|
37
|
+
|
|
38
|
+
class NodeBuilderDialog(QDialog):
|
|
39
|
+
def __init__(self, parent=None, editing_node_id=None):
|
|
40
|
+
super().__init__(parent)
|
|
41
|
+
self.editing_node_id = editing_node_id
|
|
42
|
+
self.setWindowTitle("Node Builder")
|
|
43
|
+
self.setWindowFlags(
|
|
44
|
+
Qt.Window |
|
|
45
|
+
Qt.WindowCloseButtonHint |
|
|
46
|
+
Qt.WindowMinimizeButtonHint |
|
|
47
|
+
Qt.WindowMaximizeButtonHint
|
|
48
|
+
)
|
|
49
|
+
self.resize(1400, 900)
|
|
50
|
+
|
|
51
|
+
self._is_syncing = False
|
|
52
|
+
|
|
53
|
+
self._init_ui()
|
|
54
|
+
|
|
55
|
+
# Debounce timer for code parsing
|
|
56
|
+
self.sync_timer = QTimer()
|
|
57
|
+
self.sync_timer.setSingleShot(True)
|
|
58
|
+
self.sync_timer.timeout.connect(self._sync_code_to_ui)
|
|
59
|
+
|
|
60
|
+
self.code_edit.textChanged.connect(self._on_code_changed)
|
|
61
|
+
self.inputs_table.itemChanged.connect(self._on_table_changed)
|
|
62
|
+
self.outputs_table.itemChanged.connect(self._on_table_changed)
|
|
63
|
+
self.name_edit.textChanged.connect(self._on_metadata_changed)
|
|
64
|
+
self.icon_edit.textChanged.connect(self._sync_icon_to_code)
|
|
65
|
+
self.category_combo.currentTextChanged.connect(self._on_category_changed)
|
|
66
|
+
self.exec_in_check.stateChanged.connect(self._on_exec_changed)
|
|
67
|
+
self.exec_out_check.stateChanged.connect(self._on_exec_changed)
|
|
68
|
+
self.init_first_check.stateChanged.connect(self._on_init_first_changed)
|
|
69
|
+
|
|
70
|
+
if self.editing_node_id:
|
|
71
|
+
self._load_existing_node()
|
|
72
|
+
|
|
73
|
+
def _init_ui(self):
|
|
74
|
+
layout = QVBoxLayout(self)
|
|
75
|
+
splitter = QSplitter(Qt.Horizontal)
|
|
76
|
+
|
|
77
|
+
# Left Panel: Configuration (scrollable so it stays usable when narrow)
|
|
78
|
+
config_inner = QWidget()
|
|
79
|
+
config_layout = QVBoxLayout(config_inner)
|
|
80
|
+
config_scroll = QScrollArea()
|
|
81
|
+
config_scroll.setWidget(config_inner)
|
|
82
|
+
config_scroll.setWidgetResizable(True)
|
|
83
|
+
config_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
|
84
|
+
config_scroll.setMinimumWidth(400)
|
|
85
|
+
|
|
86
|
+
config_layout.addWidget(QLabel("Node ID (slug — used for file & class name):"))
|
|
87
|
+
self.name_edit = QLineEdit()
|
|
88
|
+
config_layout.addWidget(self.name_edit)
|
|
89
|
+
|
|
90
|
+
config_layout.addWidget(QLabel("Display Name (shown on canvas — allows spaces, colons, etc.):"))
|
|
91
|
+
self.display_name_edit = QLineEdit()
|
|
92
|
+
self.display_name_edit.setPlaceholderText("Leave blank to use Node ID")
|
|
93
|
+
config_layout.addWidget(self.display_name_edit)
|
|
94
|
+
|
|
95
|
+
config_layout.addWidget(QLabel("Description:"))
|
|
96
|
+
self.desc_edit = QTextEdit()
|
|
97
|
+
self.desc_edit.setMaximumHeight(60)
|
|
98
|
+
config_layout.addWidget(self.desc_edit)
|
|
99
|
+
|
|
100
|
+
config_layout.addWidget(QLabel("Category:"))
|
|
101
|
+
from src.utils.color_manager import ColorManager
|
|
102
|
+
QPixmap = QtGui.QPixmap
|
|
103
|
+
QIcon = QtGui.QIcon
|
|
104
|
+
self.category_combo = QComboBox()
|
|
105
|
+
self.category_combo.setEditable(True)
|
|
106
|
+
|
|
107
|
+
# Populate with existing categories and their colors
|
|
108
|
+
categories = ColorManager.get_all_categories(NodeRegistry._definitions)
|
|
109
|
+
for cat in categories:
|
|
110
|
+
color = ColorManager.get_category_color(cat)
|
|
111
|
+
pixmap = QPixmap(16, 16)
|
|
112
|
+
pixmap.fill(color)
|
|
113
|
+
self.category_combo.addItem(QIcon(pixmap), cat)
|
|
114
|
+
|
|
115
|
+
config_layout.addWidget(self.category_combo)
|
|
116
|
+
|
|
117
|
+
config_layout.addWidget(QLabel("Icon Path:"))
|
|
118
|
+
icon_layout = QHBoxLayout()
|
|
119
|
+
self.icon_edit = QLineEdit()
|
|
120
|
+
self.icon_btn = QPushButton("...")
|
|
121
|
+
self.icon_btn.setFixedWidth(30)
|
|
122
|
+
self.icon_btn.clicked.connect(self._select_icon)
|
|
123
|
+
icon_layout.addWidget(self.icon_edit)
|
|
124
|
+
icon_layout.addWidget(self.icon_btn)
|
|
125
|
+
config_layout.addLayout(icon_layout)
|
|
126
|
+
|
|
127
|
+
# Execution ports
|
|
128
|
+
exec_layout = QHBoxLayout()
|
|
129
|
+
self.exec_in_check = QCheckBox("Exec Input (exec_in)")
|
|
130
|
+
self.exec_in_check.setChecked(True)
|
|
131
|
+
self.exec_out_check = QCheckBox("Exec Output (exec_out)")
|
|
132
|
+
self.exec_out_check.setChecked(True)
|
|
133
|
+
exec_layout.addWidget(self.exec_in_check)
|
|
134
|
+
exec_layout.addWidget(self.exec_out_check)
|
|
135
|
+
config_layout.addLayout(exec_layout)
|
|
136
|
+
|
|
137
|
+
# Init First option — instances of this node will run before the rest
|
|
138
|
+
# of the workflow (login, auth, data-init nodes).
|
|
139
|
+
init_layout = QHBoxLayout()
|
|
140
|
+
self.init_first_check = QCheckBox("Init First (run before main workflow)")
|
|
141
|
+
self.init_first_check.setToolTip(
|
|
142
|
+
"When checked, every instance of this node runs before the main\n"
|
|
143
|
+
"graph executes — useful for login, authentication, or data\n"
|
|
144
|
+
"initialization nodes."
|
|
145
|
+
)
|
|
146
|
+
init_layout.addWidget(self.init_first_check)
|
|
147
|
+
config_layout.addLayout(init_layout)
|
|
148
|
+
|
|
149
|
+
# Inputs Table
|
|
150
|
+
config_layout.addWidget(QLabel("Inputs:"))
|
|
151
|
+
self.inputs_table = QTableWidget(0, 5)
|
|
152
|
+
self.inputs_table.setHorizontalHeaderLabels(["Name", "Type", "Widget", "Options (csv)", "Default"])
|
|
153
|
+
config_layout.addWidget(self.inputs_table)
|
|
154
|
+
|
|
155
|
+
in_btn_layout = QHBoxLayout()
|
|
156
|
+
add_in_btn = QPushButton("+ Add Input")
|
|
157
|
+
add_in_btn.clicked.connect(lambda: self._add_row(self.inputs_table))
|
|
158
|
+
remove_in_btn = QPushButton("- Remove Input")
|
|
159
|
+
remove_in_btn.clicked.connect(lambda: self._remove_row(self.inputs_table))
|
|
160
|
+
in_btn_layout.addWidget(add_in_btn)
|
|
161
|
+
in_btn_layout.addWidget(remove_in_btn)
|
|
162
|
+
config_layout.addLayout(in_btn_layout)
|
|
163
|
+
|
|
164
|
+
# Outputs Table
|
|
165
|
+
config_layout.addWidget(QLabel("Outputs:"))
|
|
166
|
+
self.outputs_table = QTableWidget(0, 5)
|
|
167
|
+
self.outputs_table.setHorizontalHeaderLabels(["Name", "Type", "Widget", "Options (csv)", "Default"])
|
|
168
|
+
config_layout.addWidget(self.outputs_table)
|
|
169
|
+
|
|
170
|
+
out_btn_layout = QHBoxLayout()
|
|
171
|
+
add_out_btn = QPushButton("+ Add Output")
|
|
172
|
+
add_out_btn.clicked.connect(lambda: self._add_row(self.outputs_table))
|
|
173
|
+
remove_out_btn = QPushButton("- Remove Output")
|
|
174
|
+
remove_out_btn.clicked.connect(lambda: self._remove_row(self.outputs_table))
|
|
175
|
+
out_btn_layout.addWidget(add_out_btn)
|
|
176
|
+
out_btn_layout.addWidget(remove_out_btn)
|
|
177
|
+
config_layout.addLayout(out_btn_layout)
|
|
178
|
+
|
|
179
|
+
# Right Panel: Code Editor
|
|
180
|
+
editor_widget = QWidget()
|
|
181
|
+
editor_layout = QVBoxLayout(editor_widget)
|
|
182
|
+
editor_layout.addWidget(QLabel("Python Algorithm:"))
|
|
183
|
+
self.code_edit = CodeEditor()
|
|
184
|
+
self.code_edit.setPlainText(self._get_template("MyNode"))
|
|
185
|
+
editor_layout.addWidget(self.code_edit)
|
|
186
|
+
|
|
187
|
+
# Gemini Panel
|
|
188
|
+
self.gemini_chat = GeminiChatWidget()
|
|
189
|
+
self.gemini_chat.get_context_callback = self.get_node_definition
|
|
190
|
+
self.gemini_chat.node_generated.connect(self._on_gemini_node_generated)
|
|
191
|
+
|
|
192
|
+
splitter.addWidget(config_scroll)
|
|
193
|
+
splitter.addWidget(editor_widget)
|
|
194
|
+
splitter.addWidget(self.gemini_chat)
|
|
195
|
+
|
|
196
|
+
# Code editor is the hero — side panels stay compact, center stretches.
|
|
197
|
+
splitter.setStretchFactor(0, 0)
|
|
198
|
+
splitter.setStretchFactor(1, 1)
|
|
199
|
+
splitter.setStretchFactor(2, 0)
|
|
200
|
+
splitter.setSizes([280, 840, 280])
|
|
201
|
+
|
|
202
|
+
layout.addWidget(splitter)
|
|
203
|
+
|
|
204
|
+
# Bottom Buttons
|
|
205
|
+
button_layout = QHBoxLayout()
|
|
206
|
+
self.test_btn = QPushButton("Test Node")
|
|
207
|
+
self.test_btn.clicked.connect(self.test_node)
|
|
208
|
+
self.save_btn = QPushButton("Save & Register")
|
|
209
|
+
self.save_btn.clicked.connect(self.save_node)
|
|
210
|
+
self.cancel_btn = QPushButton("Cancel")
|
|
211
|
+
self.cancel_btn.clicked.connect(self.reject)
|
|
212
|
+
|
|
213
|
+
button_layout.addWidget(self.test_btn)
|
|
214
|
+
button_layout.addStretch()
|
|
215
|
+
button_layout.addWidget(self.save_btn)
|
|
216
|
+
button_layout.addWidget(self.cancel_btn)
|
|
217
|
+
layout.addLayout(button_layout)
|
|
218
|
+
|
|
219
|
+
def _on_category_changed(self, category):
|
|
220
|
+
if category == "Houdini":
|
|
221
|
+
self._fetch_houdini_completions()
|
|
222
|
+
|
|
223
|
+
def _fetch_houdini_completions(self):
|
|
224
|
+
if is_available():
|
|
225
|
+
try:
|
|
226
|
+
bridge = get_bridge()
|
|
227
|
+
completions = bridge.get_completions()
|
|
228
|
+
# Also get common sub-modules
|
|
229
|
+
completions += ["hipFile", "node", "ui", "playbar", "fps", "frame", "setFrame"]
|
|
230
|
+
self.code_edit.append_completer_list(completions)
|
|
231
|
+
except Exception:
|
|
232
|
+
pass
|
|
233
|
+
|
|
234
|
+
def _select_icon(self):
|
|
235
|
+
path, _ = QFileDialog.getOpenFileName(self, "Select Icon", "", "Images (*.png *.jpg *.svg)")
|
|
236
|
+
if path:
|
|
237
|
+
self.icon_edit.setText(path)
|
|
238
|
+
|
|
239
|
+
def _get_template(self, name):
|
|
240
|
+
return f"""from src.nodes.base import BaseNode
|
|
241
|
+
|
|
242
|
+
class {name}(BaseNode):
|
|
243
|
+
name = "{name}"
|
|
244
|
+
init_first = False # When True, instances of this node run before the main workflow
|
|
245
|
+
|
|
246
|
+
def __init__(self):
|
|
247
|
+
\"\"\"Initialize node ports and resources.\"\"\"
|
|
248
|
+
super().__init__(use_exec=True)
|
|
249
|
+
self.icon_path = None
|
|
250
|
+
self.add_exec_input("exec_in")
|
|
251
|
+
self.add_exec_output("exec_out")
|
|
252
|
+
# [AUTO-GENERATED-PORTS-START]
|
|
253
|
+
# [AUTO-GENERATED-PORTS-END]
|
|
254
|
+
try:
|
|
255
|
+
pass
|
|
256
|
+
except Exception as e:
|
|
257
|
+
pass
|
|
258
|
+
|
|
259
|
+
def on_plug_sync(self, port_name, is_input, other_node, other_port_name):
|
|
260
|
+
# Access the other node's port data using the specific other_port_name
|
|
261
|
+
data = other_node.get_parameter(other_port_name)
|
|
262
|
+
self.log_info(f"Connected to {{other_node.name}} port '{{other_port_name}}'. Data: {{data}}")
|
|
263
|
+
|
|
264
|
+
def on_unplug_sync(self, port_name, is_input):
|
|
265
|
+
self.log_info(f"Disconnected {{port_name}}")
|
|
266
|
+
|
|
267
|
+
async def on_plug(self, port_name, is_input, other_node, other_port_name):
|
|
268
|
+
pass
|
|
269
|
+
|
|
270
|
+
async def on_unplug(self, port_name, is_input):
|
|
271
|
+
pass
|
|
272
|
+
|
|
273
|
+
async def on_parameter_changed(self, name, value):
|
|
274
|
+
\"\"\"Called whenever a widget parameter changes (before execute).
|
|
275
|
+
|
|
276
|
+
Example:
|
|
277
|
+
if name == "my_input":
|
|
278
|
+
await self.set_output("my_output", value)
|
|
279
|
+
\"\"\"
|
|
280
|
+
pass
|
|
281
|
+
|
|
282
|
+
async def execute(self, inputs):
|
|
283
|
+
\"\"\"
|
|
284
|
+
Main execution logic for the node.
|
|
285
|
+
|
|
286
|
+
:param inputs: A dictionary containing data from connected input ports and widgets.
|
|
287
|
+
Key: Port Name (string), Value: Port Data (any).
|
|
288
|
+
:return: A dictionary containing data to be sent to output ports.
|
|
289
|
+
Key: Port Name (string), Value: Port Data (any).
|
|
290
|
+
\"\"\"
|
|
291
|
+
# [SET-OUTPUT-START]
|
|
292
|
+
# [SET-OUTPUT-END]
|
|
293
|
+
# [EXEC-OUT-START]
|
|
294
|
+
await self.set_output("exec_out", True)
|
|
295
|
+
return {{"exec_out": True}}
|
|
296
|
+
# [EXEC-OUT-END]
|
|
297
|
+
|
|
298
|
+
def register_node():
|
|
299
|
+
return {name}
|
|
300
|
+
"""
|
|
301
|
+
|
|
302
|
+
def _on_code_changed(self):
|
|
303
|
+
if not self._is_syncing:
|
|
304
|
+
self.sync_timer.start(1000) # 1 second debounce
|
|
305
|
+
|
|
306
|
+
def _on_exec_changed(self):
|
|
307
|
+
if not self._is_syncing:
|
|
308
|
+
# Only update the [EXEC-OUT] block — never regenerate [SET-OUTPUT]
|
|
309
|
+
# which would wipe any code the user wrote in the execute method.
|
|
310
|
+
self._sync_ui_to_code(update_set_output_hints=False, update_exec_out_hint=True)
|
|
311
|
+
|
|
312
|
+
def _on_init_first_changed(self):
|
|
313
|
+
if not self._is_syncing:
|
|
314
|
+
self._sync_ui_to_code(update_set_output_hints=False, update_exec_out_hint=False)
|
|
315
|
+
|
|
316
|
+
def _sync_icon_to_code(self):
|
|
317
|
+
"""Update only the self.icon_path assignment line — no other regeneration."""
|
|
318
|
+
if self._is_syncing:
|
|
319
|
+
return
|
|
320
|
+
self._is_syncing = True
|
|
321
|
+
try:
|
|
322
|
+
code = self.code_edit.toPlainText()
|
|
323
|
+
icon_val = self.icon_edit.text().strip()
|
|
324
|
+
icon_replacement = f'self.icon_path = "{icon_val}"' if icon_val else 'self.icon_path = None'
|
|
325
|
+
new_code = re.sub(r'self\.icon_path\s*=\s*(?:"[^"]*"|None)', icon_replacement, code)
|
|
326
|
+
if new_code != code:
|
|
327
|
+
self.code_edit.setPlainText(new_code)
|
|
328
|
+
finally:
|
|
329
|
+
self._is_syncing = False
|
|
330
|
+
|
|
331
|
+
def _on_table_changed(self):
|
|
332
|
+
if not self._is_syncing:
|
|
333
|
+
self._sync_ui_to_code(update_set_output_hints=True, update_exec_out_hint=False)
|
|
334
|
+
|
|
335
|
+
def _on_metadata_changed(self):
|
|
336
|
+
if not self._is_syncing:
|
|
337
|
+
# Sanitize name: remove any non-alphanumeric/underscore and replace spaces
|
|
338
|
+
raw_name = self.name_edit.text()
|
|
339
|
+
sanitized = "".join(c if c.isalnum() else "_" for c in raw_name)
|
|
340
|
+
|
|
341
|
+
# Prevent recursive loop
|
|
342
|
+
if sanitized != raw_name:
|
|
343
|
+
pos = self.name_edit.cursorPosition()
|
|
344
|
+
self.name_edit.setText(sanitized)
|
|
345
|
+
self.name_edit.setCursorPosition(pos)
|
|
346
|
+
|
|
347
|
+
self._sync_ui_to_code(update_exec_hints=False)
|
|
348
|
+
|
|
349
|
+
def _sync_code_to_ui(self):
|
|
350
|
+
"""
|
|
351
|
+
Parses the code using AST and updates the UI tables.
|
|
352
|
+
"""
|
|
353
|
+
if self._is_syncing:
|
|
354
|
+
return
|
|
355
|
+
|
|
356
|
+
self._is_syncing = True
|
|
357
|
+
try:
|
|
358
|
+
code = self.code_edit.toPlainText()
|
|
359
|
+
tree = ast.parse(code)
|
|
360
|
+
|
|
361
|
+
inputs = {} # name -> (type, widget_type)
|
|
362
|
+
outputs = {} # name -> (type, widget_type)
|
|
363
|
+
|
|
364
|
+
class PortVisitor(ast.NodeVisitor):
|
|
365
|
+
def visit_Call(self, node):
|
|
366
|
+
if isinstance(node.func, ast.Attribute) and node.func.attr in ["add_input", "add_output"]:
|
|
367
|
+
if len(node.args) >= 1 and isinstance(node.args[0], ast.Constant):
|
|
368
|
+
port_name = node.args[0].value
|
|
369
|
+
port_type = "any"
|
|
370
|
+
if len(node.args) >= 2 and isinstance(node.args[1], ast.Constant):
|
|
371
|
+
port_type = node.args[1].value
|
|
372
|
+
|
|
373
|
+
# Extract widget_type keyword argument
|
|
374
|
+
widget_type = ""
|
|
375
|
+
for kw in node.keywords:
|
|
376
|
+
if kw.arg == "widget_type" and isinstance(kw.value, ast.Constant):
|
|
377
|
+
widget_type = kw.value.value or ""
|
|
378
|
+
break
|
|
379
|
+
|
|
380
|
+
if node.func.attr == "add_input":
|
|
381
|
+
inputs[port_name] = (port_type, widget_type)
|
|
382
|
+
else:
|
|
383
|
+
outputs[port_name] = (port_type, widget_type)
|
|
384
|
+
self.generic_visit(node)
|
|
385
|
+
|
|
386
|
+
PortVisitor().visit(tree)
|
|
387
|
+
|
|
388
|
+
# Convert to list for comparison and update — exec ports are managed
|
|
389
|
+
# by the checkboxes, never by the table; filter them here so a
|
|
390
|
+
# hand-written JSON that lists exec_in/exec_out in its arrays does
|
|
391
|
+
# not leak into the port table and get re-emitted as add_input calls.
|
|
392
|
+
_exec_names = {"exec_in", "exec_out"}
|
|
393
|
+
input_list = [(k, v[0], v[1]) for k, v in inputs.items() if k not in _exec_names]
|
|
394
|
+
output_list = [(k, v[0], v[1]) for k, v in outputs.items() if k not in _exec_names]
|
|
395
|
+
|
|
396
|
+
# Check if actual changes happened before updating table to avoid signal storm
|
|
397
|
+
if self._table_needs_update(self.inputs_table, input_list):
|
|
398
|
+
self._update_table(self.inputs_table, input_list)
|
|
399
|
+
if self._table_needs_update(self.outputs_table, output_list):
|
|
400
|
+
self._update_table(self.outputs_table, output_list)
|
|
401
|
+
|
|
402
|
+
# Detect exec ports from explicit add_exec_input / add_exec_output lines
|
|
403
|
+
has_exec_in = bool(re.search(r'self\.add_exec_input', code))
|
|
404
|
+
has_exec_out = bool(re.search(r'self\.add_exec_output', code))
|
|
405
|
+
self.exec_in_check.blockSignals(True)
|
|
406
|
+
self.exec_out_check.blockSignals(True)
|
|
407
|
+
self.exec_in_check.setChecked(has_exec_in)
|
|
408
|
+
self.exec_out_check.setChecked(has_exec_out)
|
|
409
|
+
self.exec_in_check.blockSignals(False)
|
|
410
|
+
self.exec_out_check.blockSignals(False)
|
|
411
|
+
|
|
412
|
+
# Sync init_first checkbox from class attribute
|
|
413
|
+
init_first_match = re.search(r'^\s*init_first\s*=\s*(True|False)', code, flags=re.MULTILINE)
|
|
414
|
+
self.init_first_check.blockSignals(True)
|
|
415
|
+
self.init_first_check.setChecked(bool(init_first_match) and init_first_match.group(1) == "True")
|
|
416
|
+
self.init_first_check.blockSignals(False)
|
|
417
|
+
|
|
418
|
+
except Exception as e:
|
|
419
|
+
# Code might be invalid while typing, ignore
|
|
420
|
+
pass
|
|
421
|
+
finally:
|
|
422
|
+
self._is_syncing = False
|
|
423
|
+
|
|
424
|
+
def _table_needs_update(self, table, new_ports):
|
|
425
|
+
if table.rowCount() != len(new_ports):
|
|
426
|
+
return True
|
|
427
|
+
for i, port in enumerate(new_ports):
|
|
428
|
+
name = port[0] if not hasattr(port, 'name') else port.name
|
|
429
|
+
p_type = port[1] if not hasattr(port, 'type') else port.type
|
|
430
|
+
p_widget = (port[2] if len(port) > 2 else "") if not hasattr(port, 'widget_type') else (port.widget_type or "")
|
|
431
|
+
name_item = table.item(i, 0)
|
|
432
|
+
type_combo = table.cellWidget(i, 1)
|
|
433
|
+
widget_combo = table.cellWidget(i, 2)
|
|
434
|
+
if not name_item or not type_combo: return True
|
|
435
|
+
if name_item.text() != name or type_combo.currentText() != p_type:
|
|
436
|
+
return True
|
|
437
|
+
if widget_combo and widget_combo.currentText() != (p_widget or ""):
|
|
438
|
+
return True
|
|
439
|
+
return False
|
|
440
|
+
|
|
441
|
+
def _update_table(self, table, ports):
|
|
442
|
+
table.blockSignals(True)
|
|
443
|
+
table.setRowCount(0)
|
|
444
|
+
for p in ports:
|
|
445
|
+
# p can be (name, type) or PortModel
|
|
446
|
+
name = p.name if hasattr(p, 'name') else p[0]
|
|
447
|
+
p_type = p.type if hasattr(p, 'type') else p[1]
|
|
448
|
+
p_widget = p.widget_type if hasattr(p, 'widget_type') else (p[2] if len(p) > 2 else "")
|
|
449
|
+
p_options = ",".join(p.options) if hasattr(p, 'options') and p.options else ""
|
|
450
|
+
p_default_val = p.default if hasattr(p, 'default') else None
|
|
451
|
+
p_default = str(p_default_val) if p_default_val is not None else ""
|
|
452
|
+
|
|
453
|
+
row = table.rowCount()
|
|
454
|
+
table.insertRow(row)
|
|
455
|
+
table.setItem(row, 0, QTableWidgetItem(name))
|
|
456
|
+
|
|
457
|
+
# Use Dropdown for type column
|
|
458
|
+
type_combo = QComboBox()
|
|
459
|
+
type_combo.addItems(AVAILABLE_TYPES)
|
|
460
|
+
type_combo.setCurrentText(p_type or "any")
|
|
461
|
+
type_combo.currentTextChanged.connect(self._sync_ui_to_code)
|
|
462
|
+
table.setCellWidget(row, 1, type_combo)
|
|
463
|
+
|
|
464
|
+
# Use Dropdown for widget column
|
|
465
|
+
widget_combo = QComboBox()
|
|
466
|
+
widget_combo.addItems(AVAILABLE_WIDGETS)
|
|
467
|
+
widget_combo.setCurrentText(p_widget or "")
|
|
468
|
+
widget_combo.currentTextChanged.connect(self._sync_ui_to_code)
|
|
469
|
+
table.setCellWidget(row, 2, widget_combo)
|
|
470
|
+
|
|
471
|
+
table.setItem(row, 3, QTableWidgetItem(p_options))
|
|
472
|
+
table.setItem(row, 4, QTableWidgetItem(p_default))
|
|
473
|
+
table.blockSignals(False)
|
|
474
|
+
|
|
475
|
+
def _sync_ui_to_code(self, update_exec_hints=True, update_set_output_hints=None, update_exec_out_hint=None):
|
|
476
|
+
"""
|
|
477
|
+
Updates the auto-generated ports section in the code.
|
|
478
|
+
update_exec_hints: if False, skips regenerating [SET-OUTPUT] and [EXEC-OUT] blocks
|
|
479
|
+
so user-written execute code is not overwritten by port/metadata edits.
|
|
480
|
+
"""
|
|
481
|
+
if self._is_syncing:
|
|
482
|
+
return
|
|
483
|
+
|
|
484
|
+
self._is_syncing = True
|
|
485
|
+
try:
|
|
486
|
+
name = self.name_edit.text().strip() or "MyNode"
|
|
487
|
+
code = self.code_edit.toPlainText()
|
|
488
|
+
|
|
489
|
+
# Prepare injection string
|
|
490
|
+
injection = " # [AUTO-GENERATED-PORTS-START]\n"
|
|
491
|
+
seen_inputs = set()
|
|
492
|
+
for row in range(self.inputs_table.rowCount()):
|
|
493
|
+
item_name = self.inputs_table.item(row, 0)
|
|
494
|
+
if not item_name: continue
|
|
495
|
+
|
|
496
|
+
port_name = item_name.text().strip()
|
|
497
|
+
if not port_name or port_name in seen_inputs: continue
|
|
498
|
+
seen_inputs.add(port_name)
|
|
499
|
+
|
|
500
|
+
type_combo = self.inputs_table.cellWidget(row, 1)
|
|
501
|
+
item_widget_combo = self.inputs_table.cellWidget(row, 2)
|
|
502
|
+
item_options = self.inputs_table.item(row, 3)
|
|
503
|
+
|
|
504
|
+
type_str = type_combo.currentText() if type_combo else "any"
|
|
505
|
+
w_type = item_widget_combo.currentText() if item_widget_combo else ""
|
|
506
|
+
w_str = f', widget_type="{w_type}"' if w_type else ""
|
|
507
|
+
|
|
508
|
+
# Options injection if dropdown
|
|
509
|
+
if w_type == "dropdown" and item_options and item_options.text():
|
|
510
|
+
opts = [o.strip() for o in item_options.text().split(",")]
|
|
511
|
+
w_str += f', options={opts}'
|
|
512
|
+
injection += f' self.add_input("{port_name}", "{type_str}"{w_str})\n'
|
|
513
|
+
|
|
514
|
+
seen_outputs = set()
|
|
515
|
+
for row in range(self.outputs_table.rowCount()):
|
|
516
|
+
item_name = self.outputs_table.item(row, 0)
|
|
517
|
+
if not item_name: continue
|
|
518
|
+
|
|
519
|
+
port_name = item_name.text().strip()
|
|
520
|
+
if not port_name or port_name in seen_outputs: continue
|
|
521
|
+
seen_outputs.add(port_name)
|
|
522
|
+
|
|
523
|
+
type_combo = self.outputs_table.cellWidget(row, 1)
|
|
524
|
+
type_str = type_combo.currentText() if type_combo else "any"
|
|
525
|
+
injection += f' self.add_output("{port_name}", "{type_str}")\n'
|
|
526
|
+
|
|
527
|
+
injection += " # [AUTO-GENERATED-PORTS-END]"
|
|
528
|
+
|
|
529
|
+
# use_exec=True when any exec port is active, False only when both are off.
|
|
530
|
+
wants_in = self.exec_in_check.isChecked()
|
|
531
|
+
wants_out = self.exec_out_check.isChecked()
|
|
532
|
+
use_exec_value = "True" if (wants_in or wants_out) else "False"
|
|
533
|
+
|
|
534
|
+
code = re.sub(r'super\(\)\.__init__\(\s*\)', f'super().__init__(use_exec={use_exec_value})', code)
|
|
535
|
+
code = re.sub(r'super\(\)\.__init__\(use_exec\s*=\s*(?:True|False)\)',
|
|
536
|
+
f'super().__init__(use_exec={use_exec_value})', code)
|
|
537
|
+
|
|
538
|
+
# Strip all existing exec lines, then re-inject only the checked ones
|
|
539
|
+
code = re.sub(r'\n[ \t]*self\.add_exec_input\([^)]*\)', '', code)
|
|
540
|
+
code = re.sub(r'\n[ \t]*self\.add_exec_output\([^)]*\)', '', code)
|
|
541
|
+
exec_block = ""
|
|
542
|
+
if wants_in:
|
|
543
|
+
exec_block += '\n self.add_exec_input("exec_in")'
|
|
544
|
+
if wants_out:
|
|
545
|
+
exec_block += '\n self.add_exec_output("exec_out")'
|
|
546
|
+
if exec_block:
|
|
547
|
+
code = re.sub(r'(super\(\)\.__init__\([^)]*\))', r'\1' + exec_block, code)
|
|
548
|
+
|
|
549
|
+
# Sync init_first class attribute with the checkbox
|
|
550
|
+
init_first_value = "True" if self.init_first_check.isChecked() else "False"
|
|
551
|
+
if re.search(r'^\s*init_first\s*=\s*(?:True|False)', code, flags=re.MULTILINE):
|
|
552
|
+
code = re.sub(r'^(\s*)init_first\s*=\s*(?:True|False).*$',
|
|
553
|
+
rf'\1init_first = {init_first_value}',
|
|
554
|
+
code, count=1, flags=re.MULTILINE)
|
|
555
|
+
else:
|
|
556
|
+
# Insert directly after `name = "..."`
|
|
557
|
+
code = re.sub(r'(^ name\s*=\s*"[^"]*")',
|
|
558
|
+
rf'\1\n init_first = {init_first_value}',
|
|
559
|
+
code, count=1, flags=re.MULTILINE)
|
|
560
|
+
|
|
561
|
+
# Resolve legacy boolean flag — callers using the old keyword still work.
|
|
562
|
+
if update_set_output_hints is None:
|
|
563
|
+
update_set_output_hints = update_exec_hints
|
|
564
|
+
if update_exec_out_hint is None:
|
|
565
|
+
update_exec_out_hint = update_exec_hints
|
|
566
|
+
|
|
567
|
+
if update_set_output_hints:
|
|
568
|
+
# Regenerate commented set_output hints inside [SET-OUTPUT-START/END].
|
|
569
|
+
set_output_pattern = r"[ \t]*# \[SET-OUTPUT-START\].*?# \[SET-OUTPUT-END\]"
|
|
570
|
+
if re.search(set_output_pattern, code, re.DOTALL):
|
|
571
|
+
set_output_lines = " # [SET-OUTPUT-START]\n"
|
|
572
|
+
for row in range(self.outputs_table.rowCount()):
|
|
573
|
+
item_name = self.outputs_table.item(row, 0)
|
|
574
|
+
if not item_name: continue
|
|
575
|
+
port_name = item_name.text().strip()
|
|
576
|
+
if not port_name or port_name == "exec_out": continue
|
|
577
|
+
set_output_lines += f' #await self.set_output("{port_name}", <{port_name}_data>)\n'
|
|
578
|
+
set_output_lines += " # [SET-OUTPUT-END]"
|
|
579
|
+
code = re.sub(set_output_pattern, set_output_lines, code, flags=re.DOTALL)
|
|
580
|
+
|
|
581
|
+
if update_exec_out_hint:
|
|
582
|
+
# Update the return statement inside [EXEC-OUT-START/END] only.
|
|
583
|
+
exec_out_pattern = r"[ \t]*# \[EXEC-OUT-START\].*?# \[EXEC-OUT-END\]"
|
|
584
|
+
if re.search(exec_out_pattern, code, re.DOTALL):
|
|
585
|
+
if self.exec_out_check.isChecked():
|
|
586
|
+
exec_out_block = (
|
|
587
|
+
' # [EXEC-OUT-START]\n'
|
|
588
|
+
' await self.set_output("exec_out", True)\n'
|
|
589
|
+
' return {"exec_out": True}\n'
|
|
590
|
+
' # [EXEC-OUT-END]'
|
|
591
|
+
)
|
|
592
|
+
else:
|
|
593
|
+
exec_out_block = (
|
|
594
|
+
' # [EXEC-OUT-START]\n'
|
|
595
|
+
' return {}\n'
|
|
596
|
+
' # [EXEC-OUT-END]'
|
|
597
|
+
)
|
|
598
|
+
code = re.sub(exec_out_pattern, exec_out_block, code, flags=re.DOTALL)
|
|
599
|
+
|
|
600
|
+
# Replace section using markers
|
|
601
|
+
pattern = r"(\s*)# \[AUTO-GENERATED-PORTS-START\].*?# \[AUTO-GENERATED-PORTS-END\]"
|
|
602
|
+
if re.search(pattern, code, re.DOTALL):
|
|
603
|
+
code = re.sub(pattern, injection, code, flags=re.DOTALL)
|
|
604
|
+
else:
|
|
605
|
+
# If markers are missing, try to inject after __init__
|
|
606
|
+
init_pattern = r"(def __init__\(self.*?\):.*?super\(\)\.__init__\(.*?\))"
|
|
607
|
+
if re.search(init_pattern, code, re.DOTALL):
|
|
608
|
+
code = re.sub(init_pattern, r"\1\n" + injection, code, flags=re.DOTALL)
|
|
609
|
+
|
|
610
|
+
# ALSO UPDATE CLASS NAME AND NAME ATTRIBUTE
|
|
611
|
+
# Sanitize slug for class/file — safe_name is the Python class identifier
|
|
612
|
+
safe_name = "".join(x for x in name.title() if not x.isspace())
|
|
613
|
+
if safe_name and not safe_name.endswith("Node"): safe_name += "Node"
|
|
614
|
+
if not safe_name: safe_name = "MyNode"
|
|
615
|
+
|
|
616
|
+
# Display name is what shows on the canvas node — may contain spaces/colons
|
|
617
|
+
display_name = self.display_name_edit.text().strip() or name
|
|
618
|
+
|
|
619
|
+
# Update class definition (uses slug-based safe_name)
|
|
620
|
+
code = re.sub(r"class \w+\(BaseNode\):", f"class {safe_name}(BaseNode):", code)
|
|
621
|
+
# Update name attribute to display name (shown on canvas)
|
|
622
|
+
code = re.sub(r'^( name\s*=\s*")[^"]*(")', rf'\g<1>{display_name}\2', code, flags=re.MULTILINE)
|
|
623
|
+
# Update register_node return (only inside register_node function)
|
|
624
|
+
code = re.sub(r"(def register_node\(\)[^:]*:.*?return\s+)\w+", rf"\g<1>{safe_name}", code, flags=re.DOTALL)
|
|
625
|
+
|
|
626
|
+
# Sync icon_path into __init__ so the instance attribute matches the chosen file
|
|
627
|
+
icon_val = self.icon_edit.text().strip()
|
|
628
|
+
icon_replacement = f'self.icon_path = "{icon_val}"' if icon_val else 'self.icon_path = None'
|
|
629
|
+
code = re.sub(r'self\.icon_path\s*=\s*(?:"[^"]*"|None)', icon_replacement, code)
|
|
630
|
+
|
|
631
|
+
if code != self.code_edit.toPlainText():
|
|
632
|
+
self.code_edit.setPlainText(code)
|
|
633
|
+
finally:
|
|
634
|
+
self._is_syncing = False
|
|
635
|
+
|
|
636
|
+
def _on_gemini_node_generated(self, node_def):
|
|
637
|
+
self._is_syncing = True
|
|
638
|
+
try:
|
|
639
|
+
self.name_edit.setText(node_def.get("node_id", ""))
|
|
640
|
+
self.desc_edit.setPlainText(node_def.get("description", ""))
|
|
641
|
+
self.category_combo.setCurrentText(node_def.get("category", "General"))
|
|
642
|
+
self.icon_edit.setText(node_def.get("icon_path", ""))
|
|
643
|
+
|
|
644
|
+
# Map inputs and outputs to PortModel-like objects for _update_table
|
|
645
|
+
inputs = [PortModel(**p) if isinstance(p, dict) else p for p in node_def.get("inputs", [])]
|
|
646
|
+
outputs = [PortModel(**p) if isinstance(p, dict) else p for p in node_def.get("outputs", [])]
|
|
647
|
+
|
|
648
|
+
self._update_table(self.inputs_table, inputs)
|
|
649
|
+
self._update_table(self.outputs_table, outputs)
|
|
650
|
+
self.code_edit.setPlainText(node_def.get("python_code", ""))
|
|
651
|
+
finally:
|
|
652
|
+
self._is_syncing = False
|
|
653
|
+
|
|
654
|
+
def _add_row(self, table):
|
|
655
|
+
table.blockSignals(True)
|
|
656
|
+
row = table.rowCount()
|
|
657
|
+
table.insertRow(row)
|
|
658
|
+
table.setItem(row, 0, QTableWidgetItem(f"port_{row}"))
|
|
659
|
+
|
|
660
|
+
# Add type combo
|
|
661
|
+
type_combo = QComboBox()
|
|
662
|
+
type_combo.addItems(AVAILABLE_TYPES)
|
|
663
|
+
type_combo.currentTextChanged.connect(self._sync_ui_to_code)
|
|
664
|
+
table.setCellWidget(row, 1, type_combo)
|
|
665
|
+
|
|
666
|
+
# Add widget combo
|
|
667
|
+
widget_combo = QComboBox()
|
|
668
|
+
widget_combo.addItems(AVAILABLE_WIDGETS)
|
|
669
|
+
widget_combo.currentTextChanged.connect(self._sync_ui_to_code)
|
|
670
|
+
table.setCellWidget(row, 2, widget_combo)
|
|
671
|
+
|
|
672
|
+
table.setItem(row, 3, QTableWidgetItem("")) # Options column
|
|
673
|
+
table.setItem(row, 4, QTableWidgetItem("")) # Default column
|
|
674
|
+
table.blockSignals(False)
|
|
675
|
+
self._sync_ui_to_code()
|
|
676
|
+
|
|
677
|
+
def _remove_row(self, table):
|
|
678
|
+
row = table.currentRow()
|
|
679
|
+
if row >= 0:
|
|
680
|
+
table.blockSignals(True)
|
|
681
|
+
table.removeRow(row)
|
|
682
|
+
table.blockSignals(False)
|
|
683
|
+
self._sync_ui_to_code()
|
|
684
|
+
|
|
685
|
+
def test_node(self):
|
|
686
|
+
code = self.code_edit.toPlainText()
|
|
687
|
+
try:
|
|
688
|
+
ast.parse(code)
|
|
689
|
+
# Future: Sandbox execution test
|
|
690
|
+
QMessageBox.information(self, "Validation", "Code syntax is valid.")
|
|
691
|
+
except Exception as e:
|
|
692
|
+
QMessageBox.critical(self, "Syntax Error", str(e))
|
|
693
|
+
|
|
694
|
+
def save_node(self):
|
|
695
|
+
# Cancel any pending debounce timer and sync code → tables first,
|
|
696
|
+
# so the JSON ports reflect the latest hand-edited code.
|
|
697
|
+
self.sync_timer.stop()
|
|
698
|
+
self._sync_code_to_ui()
|
|
699
|
+
|
|
700
|
+
node_id = self.name_edit.text().strip()
|
|
701
|
+
if not node_id:
|
|
702
|
+
QMessageBox.warning(self, "Error", "Node ID/Name is required.")
|
|
703
|
+
return
|
|
704
|
+
|
|
705
|
+
inputs = []
|
|
706
|
+
seen_inputs = set()
|
|
707
|
+
for r in range(self.inputs_table.rowCount()):
|
|
708
|
+
name_item = self.inputs_table.item(r, 0)
|
|
709
|
+
if not name_item: continue
|
|
710
|
+
name = name_item.text().strip()
|
|
711
|
+
if not name or name in seen_inputs or name in {"exec_in", "exec_out"}: continue
|
|
712
|
+
seen_inputs.add(name)
|
|
713
|
+
|
|
714
|
+
type_combo = self.inputs_table.cellWidget(r, 1)
|
|
715
|
+
p_type = type_combo.currentText() if type_combo else "any"
|
|
716
|
+
|
|
717
|
+
widget_combo = self.inputs_table.cellWidget(r, 2)
|
|
718
|
+
p_widget = widget_combo.currentText() if widget_combo else None
|
|
719
|
+
|
|
720
|
+
p_options_str = self.inputs_table.item(r, 3).text() if self.inputs_table.item(r, 3) else ""
|
|
721
|
+
p_options = [o.strip() for o in p_options_str.split(",")] if p_options_str else None
|
|
722
|
+
p_default_str = self.inputs_table.item(r, 4).text().strip() if self.inputs_table.item(r, 4) else ""
|
|
723
|
+
inputs.append(PortModel(name=name, type=p_type, widget_type=p_widget or None, options=p_options, default=p_default_str or None))
|
|
724
|
+
|
|
725
|
+
outputs = []
|
|
726
|
+
seen_outputs = set()
|
|
727
|
+
for r in range(self.outputs_table.rowCount()):
|
|
728
|
+
name_item = self.outputs_table.item(r, 0)
|
|
729
|
+
if not name_item: continue
|
|
730
|
+
name = name_item.text().strip()
|
|
731
|
+
if not name or name in seen_outputs or name in {"exec_in", "exec_out"}: continue
|
|
732
|
+
seen_outputs.add(name)
|
|
733
|
+
|
|
734
|
+
type_combo = self.outputs_table.cellWidget(r, 1)
|
|
735
|
+
p_type = type_combo.currentText() if type_combo else "any"
|
|
736
|
+
p_default_str = self.outputs_table.item(r, 4).text().strip() if self.outputs_table.item(r, 4) else ""
|
|
737
|
+
outputs.append(PortModel(name=name, type=p_type, default=p_default_str or None))
|
|
738
|
+
|
|
739
|
+
display_name = self.display_name_edit.text().strip() or node_id
|
|
740
|
+
|
|
741
|
+
definition = NodeDefinitionJSON(
|
|
742
|
+
node_id=node_id,
|
|
743
|
+
name=display_name,
|
|
744
|
+
description=self.desc_edit.toPlainText(),
|
|
745
|
+
category=self.category_combo.currentText() or "General",
|
|
746
|
+
icon_path=self.icon_edit.text() or None,
|
|
747
|
+
inputs=inputs,
|
|
748
|
+
outputs=outputs,
|
|
749
|
+
python_code=self.code_edit.toPlainText()
|
|
750
|
+
)
|
|
751
|
+
|
|
752
|
+
nodes_dir = os.path.join(app_dir(), 'nodes')
|
|
753
|
+
os.makedirs(nodes_dir, exist_ok=True)
|
|
754
|
+
|
|
755
|
+
file_path = os.path.join(nodes_dir, f"{node_id}.json")
|
|
756
|
+
with open(file_path, "w") as f:
|
|
757
|
+
f.write(definition.model_dump_json(indent=4))
|
|
758
|
+
|
|
759
|
+
if NodeRegistry.register_definition(definition):
|
|
760
|
+
QMessageBox.information(self, "Success", f"Node '{node_id}' saved and registered.")
|
|
761
|
+
self.accept()
|
|
762
|
+
else:
|
|
763
|
+
QMessageBox.critical(self, "Error", "Failed to register node class. Check Python code.")
|
|
764
|
+
|
|
765
|
+
def _load_existing_node(self):
|
|
766
|
+
self.sync_timer.stop() # prevent any pending sync from overwriting loaded data
|
|
767
|
+
self._is_syncing = True
|
|
768
|
+
try:
|
|
769
|
+
defn = NodeRegistry.get_definition(self.editing_node_id)
|
|
770
|
+
if defn:
|
|
771
|
+
self.name_edit.setText(defn.node_id)
|
|
772
|
+
# Populate display name only when it differs from the slug
|
|
773
|
+
self.display_name_edit.setText(defn.name if defn.name != defn.node_id else "")
|
|
774
|
+
self.desc_edit.setPlainText(defn.description)
|
|
775
|
+
self.category_combo.setCurrentText(defn.category or "General")
|
|
776
|
+
self.icon_edit.setText(defn.icon_path or "")
|
|
777
|
+
_exec_names = {"exec_in", "exec_out"}
|
|
778
|
+
self._update_table(self.inputs_table, [p for p in defn.inputs if p.name not in _exec_names])
|
|
779
|
+
self._update_table(self.outputs_table, [p for p in defn.outputs if p.name not in _exec_names])
|
|
780
|
+
# Set exec checkboxes from existing code
|
|
781
|
+
code = defn.python_code
|
|
782
|
+
default_exec = bool(
|
|
783
|
+
re.search(r'super\(\)\.__init__\(\s*\)', code) or
|
|
784
|
+
re.search(r'super\(\)\.__init__\(use_exec\s*=\s*True\)', code)
|
|
785
|
+
)
|
|
786
|
+
self.exec_in_check.setChecked(default_exec or bool(re.search(r'add_exec_input', code)))
|
|
787
|
+
self.exec_out_check.setChecked(default_exec or bool(re.search(r'add_exec_output', code)))
|
|
788
|
+
init_first_match = re.search(r'^\s*init_first\s*=\s*(True|False)', code, flags=re.MULTILINE)
|
|
789
|
+
self.init_first_check.setChecked(bool(init_first_match) and init_first_match.group(1) == "True")
|
|
790
|
+
self.code_edit.setPlainText(code)
|
|
791
|
+
finally:
|
|
792
|
+
self._is_syncing = False
|
|
793
|
+
|
|
794
|
+
def get_node_definition(self) -> dict:
|
|
795
|
+
inputs = []
|
|
796
|
+
for r in range(self.inputs_table.rowCount()):
|
|
797
|
+
name_item = self.inputs_table.item(r, 0)
|
|
798
|
+
if not name_item: continue
|
|
799
|
+
name = name_item.text().strip()
|
|
800
|
+
if not name: continue
|
|
801
|
+
|
|
802
|
+
type_combo = self.inputs_table.cellWidget(r, 1)
|
|
803
|
+
p_type = type_combo.currentText() if type_combo else "any"
|
|
804
|
+
|
|
805
|
+
widget_combo = self.inputs_table.cellWidget(r, 2)
|
|
806
|
+
p_widget = widget_combo.currentText() if widget_combo else None
|
|
807
|
+
|
|
808
|
+
p_options_str = self.inputs_table.item(r, 3).text() if self.inputs_table.item(r, 3) else ""
|
|
809
|
+
p_options = [o.strip() for o in p_options_str.split(",")] if p_options_str else None
|
|
810
|
+
|
|
811
|
+
p_default_str = self.inputs_table.item(r, 4).text().strip() if self.inputs_table.item(r, 4) else ""
|
|
812
|
+
port_data = {"name": name, "type": p_type}
|
|
813
|
+
if p_widget: port_data["widget_type"] = p_widget
|
|
814
|
+
if p_options: port_data["options"] = p_options
|
|
815
|
+
if p_default_str: port_data["default"] = p_default_str
|
|
816
|
+
inputs.append(port_data)
|
|
817
|
+
|
|
818
|
+
outputs = []
|
|
819
|
+
for r in range(self.outputs_table.rowCount()):
|
|
820
|
+
name_item = self.outputs_table.item(r, 0)
|
|
821
|
+
if not name_item: continue
|
|
822
|
+
name = name_item.text().strip()
|
|
823
|
+
if not name: continue
|
|
824
|
+
|
|
825
|
+
type_combo = self.outputs_table.cellWidget(r, 1)
|
|
826
|
+
p_type = type_combo.currentText() if type_combo else "any"
|
|
827
|
+
p_default_str = self.outputs_table.item(r, 4).text().strip() if self.outputs_table.item(r, 4) else ""
|
|
828
|
+
out_data = {"name": name, "type": p_type}
|
|
829
|
+
if p_default_str: out_data["default"] = p_default_str
|
|
830
|
+
outputs.append(out_data)
|
|
831
|
+
|
|
832
|
+
return {
|
|
833
|
+
"node_id": self.name_edit.text().strip(),
|
|
834
|
+
"name": self.name_edit.text().strip(),
|
|
835
|
+
"description": self.desc_edit.toPlainText(),
|
|
836
|
+
"category": self.category_combo.currentText(),
|
|
837
|
+
"icon_path": self.icon_edit.text(),
|
|
838
|
+
"inputs": inputs,
|
|
839
|
+
"outputs": outputs,
|
|
840
|
+
"python_code": self.code_edit.toPlainText()
|
|
841
|
+
}
|