backend-infra-engineer: Release v0.3.3 snapshot

This commit is contained in:
scawful
2025-11-21 21:35:50 -05:00
parent 3d71417f62
commit 476dd1cd1c
818 changed files with 65706 additions and 35514 deletions

View File

@@ -6,11 +6,11 @@
#include "absl/strings/match.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_split.h"
#include "core/project.h"
#include "util/file_util.h"
#include "app/editor/system/toast_manager.h"
#include "app/gui/core/icons.h"
#include "core/project.h"
#include "imgui/imgui.h"
#include "util/file_util.h"
namespace yaze {
namespace editor {
@@ -22,38 +22,43 @@ ProjectFileEditor::ProjectFileEditor() {
}
void ProjectFileEditor::Draw() {
if (!active_) return;
if (!active_)
return;
ImGui::SetNextWindowSize(ImVec2(900, 700), ImGuiCond_FirstUseEver);
if (!ImGui::Begin(absl::StrFormat("%s Project Editor###ProjectFileEditor",
ICON_MD_DESCRIPTION).c_str(),
&active_)) {
ICON_MD_DESCRIPTION)
.c_str(),
&active_)) {
ImGui::End();
return;
}
// Toolbar
if (ImGui::BeginTable("ProjectEditorToolbar", 8, ImGuiTableFlags_SizingFixedFit)) {
if (ImGui::BeginTable("ProjectEditorToolbar", 8,
ImGuiTableFlags_SizingFixedFit)) {
ImGui::TableNextColumn();
if (ImGui::Button(absl::StrFormat("%s New", ICON_MD_NOTE_ADD).c_str())) {
NewFile();
}
ImGui::TableNextColumn();
if (ImGui::Button(absl::StrFormat("%s Open", ICON_MD_FOLDER_OPEN).c_str())) {
if (ImGui::Button(
absl::StrFormat("%s Open", ICON_MD_FOLDER_OPEN).c_str())) {
auto file = util::FileDialogWrapper::ShowOpenFileDialog();
if (!file.empty()) {
auto status = LoadFile(file);
if (!status.ok() && toast_manager_) {
toast_manager_->Show(std::string(status.message()),
ToastType::kError);
toast_manager_->Show(std::string(status.message()),
ToastType::kError);
}
}
}
ImGui::TableNextColumn();
bool can_save = !filepath_.empty() && IsModified();
if (!can_save) ImGui::BeginDisabled();
if (!can_save)
ImGui::BeginDisabled();
if (ImGui::Button(absl::StrFormat("%s Save", ICON_MD_SAVE).c_str())) {
auto status = SaveFile();
if (status.ok() && toast_manager_) {
@@ -62,8 +67,9 @@ void ProjectFileEditor::Draw() {
toast_manager_->Show(std::string(status.message()), ToastType::kError);
}
}
if (!can_save) ImGui::EndDisabled();
if (!can_save)
ImGui::EndDisabled();
ImGui::TableNextColumn();
if (ImGui::Button(absl::StrFormat("%s Save As", ICON_MD_SAVE_AS).c_str())) {
auto file = util::FileDialogWrapper::ShowSaveFileDialog(
@@ -73,41 +79,43 @@ void ProjectFileEditor::Draw() {
if (status.ok() && toast_manager_) {
toast_manager_->Show("Project file saved", ToastType::kSuccess);
} else if (!status.ok() && toast_manager_) {
toast_manager_->Show(std::string(status.message()), ToastType::kError);
toast_manager_->Show(std::string(status.message()),
ToastType::kError);
}
}
}
ImGui::TableNextColumn();
ImGui::Text("|");
ImGui::TableNextColumn();
if (ImGui::Button(absl::StrFormat("%s Validate", ICON_MD_CHECK_CIRCLE).c_str())) {
if (ImGui::Button(
absl::StrFormat("%s Validate", ICON_MD_CHECK_CIRCLE).c_str())) {
ValidateContent();
show_validation_ = true;
}
ImGui::TableNextColumn();
ImGui::Checkbox("Show Validation", &show_validation_);
ImGui::TableNextColumn();
if (!filepath_.empty()) {
ImGui::TextDisabled("%s", filepath_.c_str());
} else {
ImGui::TextDisabled("No file loaded");
}
ImGui::EndTable();
}
ImGui::Separator();
// Validation errors panel
if (show_validation_ && !validation_errors_.empty()) {
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.3f, 0.2f, 0.2f, 0.5f));
if (ImGui::BeginChild("ValidationErrors", ImVec2(0, 100), true)) {
ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
"%s Validation Errors:", ICON_MD_ERROR);
ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f),
"%s Validation Errors:", ICON_MD_ERROR);
for (const auto& error : validation_errors_) {
ImGui::BulletText("%s", error.c_str());
}
@@ -115,11 +123,11 @@ void ProjectFileEditor::Draw() {
ImGui::EndChild();
ImGui::PopStyleColor();
}
// Main editor
ImVec2 editor_size = ImGui::GetContentRegionAvail();
text_editor_.Render("##ProjectEditor", editor_size);
ImGui::End();
}
@@ -129,17 +137,17 @@ absl::Status ProjectFileEditor::LoadFile(const std::string& filepath) {
return absl::InvalidArgumentError(
absl::StrFormat("Cannot open file: %s", filepath));
}
std::stringstream buffer;
buffer << file.rdbuf();
file.close();
text_editor_.SetText(buffer.str());
filepath_ = filepath;
modified_ = false;
ValidateContent();
return absl::OkStatus();
}
@@ -147,7 +155,7 @@ absl::Status ProjectFileEditor::SaveFile() {
if (filepath_.empty()) {
return absl::InvalidArgumentError("No file path specified");
}
return SaveFileAs(filepath_);
}
@@ -157,24 +165,24 @@ absl::Status ProjectFileEditor::SaveFileAs(const std::string& filepath) {
if (!absl::EndsWith(final_path, ".yaze")) {
final_path += ".yaze";
}
std::ofstream file(final_path);
if (!file.is_open()) {
return absl::InvalidArgumentError(
absl::StrFormat("Cannot create file: %s", final_path));
}
file << text_editor_.GetText();
file.close();
filepath_ = final_path;
modified_ = false;
// Add to recent files
auto& recent_mgr = project::RecentFilesManager::GetInstance();
recent_mgr.AddFile(filepath_);
recent_mgr.Save();
return absl::OkStatus();
}
@@ -217,7 +225,7 @@ autosave_enabled=true
autosave_interval_secs=300
theme=dark
)";
text_editor_.SetText(template_content);
filepath_.clear();
modified_ = true;
@@ -231,54 +239,54 @@ void ProjectFileEditor::ApplySyntaxHighlighting() {
void ProjectFileEditor::ValidateContent() {
validation_errors_.clear();
std::string content = text_editor_.GetText();
std::vector<std::string> lines = absl::StrSplit(content, '\n');
std::string current_section;
int line_num = 0;
for (const auto& line : lines) {
line_num++;
std::string trimmed = std::string(absl::StripAsciiWhitespace(line));
// Skip empty lines and comments
if (trimmed.empty() || trimmed[0] == '#') continue;
if (trimmed.empty() || trimmed[0] == '#')
continue;
// Check for section headers
if (trimmed[0] == '[' && trimmed[trimmed.size() - 1] == ']') {
current_section = trimmed.substr(1, trimmed.size() - 2);
// Validate known sections
if (current_section != "project" &&
current_section != "files" &&
if (current_section != "project" && current_section != "files" &&
current_section != "feature_flags" &&
current_section != "workspace_settings" &&
current_section != "build_settings") {
validation_errors_.push_back(
absl::StrFormat("Line %d: Unknown section [%s]",
line_num, current_section));
validation_errors_.push_back(absl::StrFormat(
"Line %d: Unknown section [%s]", line_num, current_section));
}
continue;
}
// Check for key=value pairs
size_t equals_pos = trimmed.find('=');
if (equals_pos == std::string::npos) {
validation_errors_.push_back(
absl::StrFormat("Line %d: Invalid format, expected key=value", line_num));
validation_errors_.push_back(absl::StrFormat(
"Line %d: Invalid format, expected key=value", line_num));
continue;
}
}
if (validation_errors_.empty() && show_validation_ && toast_manager_) {
toast_manager_->Show("Project file validation passed", ToastType::kSuccess);
}
}
void ProjectFileEditor::ShowValidationErrors() {
if (validation_errors_.empty()) return;
if (validation_errors_.empty())
return;
ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f), "Validation Errors:");
for (const auto& error : validation_errors_) {
ImGui::BulletText("%s", error.c_str());