-module(sketch_css@generate). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([stylesheets/1]). -file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/generate.gleam", 37). -spec convert_modules(list(sketch_css@module:module_())) -> list({sketch_css@module:module_(), sketch_css@module@stylesheet:style_sheet()}). convert_modules(Modules) -> _pipe = gleam@list:fold( Modules, [], sketch_css@module:convert_style(Modules) ), gleam@list:filter_map( _pipe, fun(Module) -> _pipe@1 = gleam@list:find( Modules, fun(M) -> erlang:element(5, M) =:= erlang:element(1, Module) end ), gleam@result:map( _pipe@1, fun(_capture) -> gleam@pair:new(_capture, erlang:element(2, Module)) end ) end ). -file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/generate.gleam", 27). -spec convert(list(binary()), sketch_css@utils:directories()) -> {ok, list({sketch_css@module:module_(), sketch_css@module@stylesheet:style_sheet()})} | {error, snag:snag()}. convert(Source_files, Directories) -> _pipe = Source_files, _pipe@1 = gleam@list:filter_map( _pipe, fun(_capture) -> sketch_css@module:from_path( _capture, erlang:element(2, Directories) ) end ), _pipe@2 = gleam@list:map(_pipe@1, fun sketch_css@module:remove_pipes/1), _pipe@3 = gleam@list:map(_pipe@2, fun sketch_css@module:rewrite_imports/1), _pipe@4 = gleam@list:map(_pipe@3, fun sketch_css@module:rewrite_exposings/1), _pipe@5 = sketch_css@module:reject_cycles(_pipe@4), gleam@result:map(_pipe@5, fun convert_modules/1). -file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/generate.gleam", 57). -spec write_css_file( {sketch_css@module:module_(), sketch_css@module@stylesheet:style_sheet()}, sketch:style_sheet(), sketch_css@utils:directories() ) -> {ok, nil} | {error, snag:snag()}. write_css_file(Module, Stylesheet, Directories) -> {Stylesheet@1, Names} = sketch_css@module:build_stylesheet( Module, Stylesheet ), Content = sketch:render(Stylesheet@1), {Content@1, Interfaces} = sketch_css@module:build_interface( erlang:element(5, (erlang:element(1, Module))), Content, Names ), Outputs = sketch_css@utils:outputs( Directories, erlang:element(5, (erlang:element(1, Module))) ), gleam@result:'try'( sketch_css@fs:mkdir(erlang:element(2, Outputs), true), fun(_) -> gleam@result:'try'( sketch_css@fs:mkdir(erlang:element(4, Outputs), true), fun(_) -> gleam@result:'try'( sketch_css@fs:write_file( erlang:element(3, Outputs), Content@1 ), fun(_) -> gleam@result:map( sketch_css@fs:write_file( erlang:element(5, Outputs), Interfaces ), fun(_) -> gleam_stdlib:println(<<"========="/utf8>>), gleam_stdlib:println( <<<<"Gleam styles "/utf8, (erlang:element( 5, (erlang:element(1, Module)) ))/binary>>/binary, " converted."/utf8>> ), gleam_stdlib:println( <<<<"CSS file "/utf8, (erlang:element(3, Outputs))/binary>>/binary, " generated."/utf8>> ), gleam_stdlib:println( <<<<"Interface file "/utf8, (erlang:element(5, Outputs))/binary>>/binary, " generated."/utf8>> ), nil end ) end ) end ) end ). -file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/generate.gleam", 78). -spec is_css_file({sketch_css@module:module_(), any()}) -> boolean(). is_css_file(Module) -> Path = erlang:element(2, (erlang:element(1, Module))), (gleam_stdlib:string_ends_with(Path, <<"_styles.gleam"/utf8>>) orelse gleam_stdlib:string_ends_with( Path, <<"_css.gleam"/utf8>> )) orelse gleam_stdlib:string_ends_with(Path, <<"_sketch.gleam"/utf8>>). -file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/generate.gleam", 45). -spec write_css_files( list({sketch_css@module:module_(), sketch_css@module@stylesheet:style_sheet()}), sketch_css@utils:directories() ) -> {ok, nil} | {error, snag:snag()}. write_css_files(Modules, Directories) -> _assert_subject = sketch:stylesheet(ephemeral), {ok, Stylesheet} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"sketch_css/generate"/utf8>>, function => <<"write_css_files"/utf8>>, line => 49}) end, Modules@1 = gleam@list:filter(Modules, fun is_css_file/1), Write_css_file = fun(_capture) -> write_css_file(_capture, Stylesheet, Directories) end, _pipe = gleam@list:map(Modules@1, Write_css_file), _pipe@1 = gleam@result:all(_pipe), gleam@result:replace(_pipe@1, nil). -file("/Users/doctor/Workspace/sketch/sketch_css/src/sketch_css/generate.gleam", 17). -spec stylesheets(sketch_css@utils:directories()) -> {ok, nil} | {error, snag:snag()}. stylesheets(Directories) -> gleam@result:'try'( sketch_css@fs:is_directory(erlang:element(2, Directories)), fun(Is_dir) -> gleam@bool:guard( not Is_dir, snag:error(<<"Not a directory"/utf8>>), fun() -> gleam@result:'try'( sketch_css@fs:readdir( erlang:element(2, Directories), true ), fun(Source_files) -> gleam@result:'try'( convert(Source_files, Directories), fun(Modules) -> write_css_files(Modules, Directories) end ) end ) end ) end ).