Loading editor/src/webedit_api.cpp +55 −27 Original line number Diff line number Diff line Loading @@ -99,7 +99,21 @@ bool queryNodeWidgetDescriptor(const std::string &scriptPath, NodeWidgetDescript writeFile(reqPath, reqJson ? reqJson : "{}"); json_object_put(req); try { (void)blogi::webedit::embedded::runNodeRunner(reqPath, resPath); } catch (const std::exception &e) { std::cerr << "[webedit] node metadata failed for " << scriptPath << ": " << e.what() << std::endl; std::remove(reqPath.c_str()); std::remove(resPath.c_str()); return false; } catch (...) { std::cerr << "[webedit] node metadata failed for " << scriptPath << ": unknown exception" << std::endl; std::remove(reqPath.c_str()); std::remove(resPath.c_str()); return false; } std::string raw = readFile(resPath); json_object *res = raw.empty() ? nullptr : json_tokener_parse(raw.c_str()); Loading Loading @@ -178,6 +192,7 @@ std::vector<NodeWidgetDescriptor> nodeWidgetCatalog() { if (!std::filesystem::exists(widgetsDir, ec) || ec) continue; try { for (const auto &entry : std::filesystem::directory_iterator(widgetsDir, ec)) { if (ec) break; if (!entry.is_regular_file()) continue; Loading @@ -201,6 +216,13 @@ std::vector<NodeWidgetDescriptor> nodeWidgetCatalog() { namesSeen.insert(desc.name); catalog.push_back(std::move(desc)); } } catch (const std::exception &e) { std::cerr << "[webedit] failed to scan widget dir '" << widgetsDir << "': " << e.what() << std::endl; } catch (...) { std::cerr << "[webedit] failed to scan widget dir '" << widgetsDir << "': unknown exception" << std::endl; } } std::sort(catalog.begin(), catalog.end(), [](const NodeWidgetDescriptor &a, const NodeWidgetDescriptor &b) { Loading Loading @@ -586,6 +608,7 @@ bool webedit::Api::handleRequest(libhttppp::HttpRequest &curreq, const int tid, void webedit::Api::handleGetPlugins(libhttppp::HttpRequest &curreq) { json_object *arr = json_object_new_array(); try { const auto catalog = nodeWidgetCatalog(); for (const auto &desc : catalog) { json_object *obj = json_object_new_object(); Loading @@ -596,6 +619,11 @@ void webedit::Api::handleGetPlugins(libhttppp::HttpRequest &curreq) { json_object_object_add(obj, "can_have_children", json_object_new_boolean(desc.canHaveChildren)); json_object_array_add(arr, obj); } } catch (const std::exception &e) { std::cerr << "[webedit] handleGetPlugins failed: " << e.what() << std::endl; } catch (...) { std::cerr << "[webedit] handleGetPlugins failed: unknown exception" << std::endl; } json_object *resp = json_object_new_object(); json_object_object_add(resp, "plugins", arr); Loading Loading
editor/src/webedit_api.cpp +55 −27 Original line number Diff line number Diff line Loading @@ -99,7 +99,21 @@ bool queryNodeWidgetDescriptor(const std::string &scriptPath, NodeWidgetDescript writeFile(reqPath, reqJson ? reqJson : "{}"); json_object_put(req); try { (void)blogi::webedit::embedded::runNodeRunner(reqPath, resPath); } catch (const std::exception &e) { std::cerr << "[webedit] node metadata failed for " << scriptPath << ": " << e.what() << std::endl; std::remove(reqPath.c_str()); std::remove(resPath.c_str()); return false; } catch (...) { std::cerr << "[webedit] node metadata failed for " << scriptPath << ": unknown exception" << std::endl; std::remove(reqPath.c_str()); std::remove(resPath.c_str()); return false; } std::string raw = readFile(resPath); json_object *res = raw.empty() ? nullptr : json_tokener_parse(raw.c_str()); Loading Loading @@ -178,6 +192,7 @@ std::vector<NodeWidgetDescriptor> nodeWidgetCatalog() { if (!std::filesystem::exists(widgetsDir, ec) || ec) continue; try { for (const auto &entry : std::filesystem::directory_iterator(widgetsDir, ec)) { if (ec) break; if (!entry.is_regular_file()) continue; Loading @@ -201,6 +216,13 @@ std::vector<NodeWidgetDescriptor> nodeWidgetCatalog() { namesSeen.insert(desc.name); catalog.push_back(std::move(desc)); } } catch (const std::exception &e) { std::cerr << "[webedit] failed to scan widget dir '" << widgetsDir << "': " << e.what() << std::endl; } catch (...) { std::cerr << "[webedit] failed to scan widget dir '" << widgetsDir << "': unknown exception" << std::endl; } } std::sort(catalog.begin(), catalog.end(), [](const NodeWidgetDescriptor &a, const NodeWidgetDescriptor &b) { Loading Loading @@ -586,6 +608,7 @@ bool webedit::Api::handleRequest(libhttppp::HttpRequest &curreq, const int tid, void webedit::Api::handleGetPlugins(libhttppp::HttpRequest &curreq) { json_object *arr = json_object_new_array(); try { const auto catalog = nodeWidgetCatalog(); for (const auto &desc : catalog) { json_object *obj = json_object_new_object(); Loading @@ -596,6 +619,11 @@ void webedit::Api::handleGetPlugins(libhttppp::HttpRequest &curreq) { json_object_object_add(obj, "can_have_children", json_object_new_boolean(desc.canHaveChildren)); json_object_array_add(arr, obj); } } catch (const std::exception &e) { std::cerr << "[webedit] handleGetPlugins failed: " << e.what() << std::endl; } catch (...) { std::cerr << "[webedit] handleGetPlugins failed: unknown exception" << std::endl; } json_object *resp = json_object_new_object(); json_object_object_add(resp, "plugins", arr); Loading