domain dashboard, hidden css prop, fix bugs

This commit is contained in:
Face
2025-08-16 19:26:52 +03:00
parent d379836405
commit 3ed49fae0d
12 changed files with 561 additions and 19 deletions

View File

@@ -913,6 +913,10 @@ static func parse_utility_class_internal(rule: CSSRule, utility_name: String) ->
rule.properties[utility_name] = "200ms"
return
if utility_name == "hidden":
rule.properties["display"] = "none"
return
# Handle more utility classes as needed
# Add more cases here for other utilities

View File

@@ -112,15 +112,15 @@ func handle_style_element(style_element: HTMLElement) -> void:
parse_result.external_css.append(src)
return
# Handle inline CSS - we'll get the text content when parsing is complete
# For now, create a parser that will be populated later
# Handle inline CSS
if not parse_result.css_parser:
parse_result.css_parser = CSSParser.new()
parse_result.css_parser.init()
func process_styles() -> void:
if not parse_result.css_parser:
return
parse_result.css_parser = CSSParser.new()
parse_result.css_parser.init()
var css_content = Constants.DEFAULT_CSS
var style_elements = find_all("style")

View File

@@ -109,6 +109,12 @@ static func apply_element_styles(node: Control, element: HTMLParser.HTMLElement,
if styles.has("opacity"):
node.modulate.a = styles["opacity"]
if styles.has("display"):
if styles["display"] == "none":
node.visible = false
else:
node.visible = true
# Apply cursor
if styles.has("cursor"):
var cursor_shape = get_cursor_shape_from_type(styles["cursor"])

View File

@@ -5,6 +5,27 @@ static func setup_network_api(vm: LuauVM):
vm.lua_pushcallable(_lua_fetch_handler, "fetch")
vm.lua_setglobal("fetch")
static func resolve_fetch_url(url: String) -> String:
# If URL is already absolute, return as-is
if url.begins_with("http://") or url.begins_with("https://") or url.begins_with("gurt://"):
return url
# Get current domain from main scene
var main_node = Engine.get_main_loop().current_scene
var current_domain = ""
if main_node and main_node.has_method("get_current_url"):
current_domain = main_node.get_current_url()
# If no current domain, default to gurt:// protocol for relative URLs
if current_domain.is_empty():
if url.begins_with("/"):
return "gurt://" + url.substr(1)
else:
return "gurt://" + url
# Use URLUtils to resolve relative URL against current domain
return URLUtils.resolve_url(current_domain, url)
static func _lua_fetch_handler(vm: LuauVM) -> int:
var url: String = vm.luaL_checkstring(1)
var options: Dictionary = {}
@@ -12,6 +33,9 @@ static func _lua_fetch_handler(vm: LuauVM) -> int:
if vm.lua_gettop() >= 2 and vm.lua_istable(2):
options = vm.lua_todictionary(2)
# Resolve relative URLs and default to gurt:// protocol
url = resolve_fetch_url(url)
# Default options
var method = options.get("method", "GET").to_upper()
var headers = options.get("headers", {})

View File

@@ -45,11 +45,16 @@ static func resolve_url(base_url: String, relative_url: String) -> String:
# Relative path
final_path_parts = current_path_parts.duplicate()
if final_path_parts.size() > 0:
var last_part = final_path_parts[-1]
if "." in last_part and not last_part.ends_with("/"):
final_path_parts.resize(final_path_parts.size() - 1)
var href_parts = relative_url.split("/")
for part in href_parts:
if part == "..":
if final_path_parts.size() > 0:
final_path_parts.pop_back()
final_path_parts.resize(final_path_parts.size() - 1)
elif part == "." or part == "":
continue
else:
@@ -59,4 +64,4 @@ static func resolve_url(base_url: String, relative_url: String) -> String:
if final_path_parts.size() > 0:
result += "/" + "/".join(final_path_parts)
return result
return result

View File

@@ -86,6 +86,8 @@ func handle_link_click(meta: Variant) -> void:
func _on_search_submitted(url: String) -> void:
print("Search submitted: ", url)
search_bar.release_focus()
if GurtProtocol.is_gurt_domain(url):
print("Processing as GURT domain")