-module(ghtml@scanner). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/ghtml/scanner.gleam"). -export([to_output_path/1, to_source_path/1, find_ghtml_files/1, find_generated_files/1, find_orphans/1, cleanup_orphans/1]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC(false). -file("src/ghtml/scanner.gleam", 29). ?DOC(false). -spec to_output_path(binary()) -> binary(). to_output_path(Ghtml_path) -> gleam@string:replace(Ghtml_path, <<".ghtml"/utf8>>, <<".gleam"/utf8>>). -file("src/ghtml/scanner.gleam", 34). ?DOC(false). -spec to_source_path(binary()) -> binary(). to_source_path(Gleam_path) -> gleam@string:replace(Gleam_path, <<".gleam"/utf8>>, <<".ghtml"/utf8>>). -file("src/ghtml/scanner.gleam", 64). ?DOC(false). -spec is_orphaned_generated_file(binary()) -> boolean(). is_orphaned_generated_file(Gleam_path) -> case simplifile:read(Gleam_path) of {ok, Content} -> case ghtml@cache:is_generated(Content) of true -> Source_path = to_source_path(Gleam_path), case simplifile_erl:is_file(Source_path) of {ok, true} -> false; _ -> true end; false -> false end; {error, _} -> false end. -file("src/ghtml/scanner.gleam", 84). ?DOC(false). -spec find_recursive(binary(), list(binary()), binary()) -> list(binary()). find_recursive(Dir, Acc, Extension) -> case simplifile_erl:read_directory(Dir) of {ok, Entries} -> gleam@list:fold( Entries, Acc, fun(Acc@1, Entry) -> case gleam@list:contains( [<<"build"/utf8>>, <<".git"/utf8>>, <<"node_modules"/utf8>>, <<"_build"/utf8>>, <<".claude"/utf8>>, <<"fixtures"/utf8>>, <<"examples"/utf8>>, <<"generated"/utf8>>], Entry ) of true -> Acc@1; false -> Path = <<<