16 const char* executable,
19 const std::filesystem::path electronDirectory =
20 (std::filesystem::absolute(executable).parent_path() /
".." /
".." /
".." /
"Electron").lexically_normal();
22 {{
"FRAY_ENGINE_PORT", std::to_string(port)}});
40 std::string arguments;
41 for (
F_long i = 0; i < argc; i++)
43 arguments += (i ?
"\n" :
"") + std::string(argv[i]);
44 if (std::string(argv[i]) ==
"--no-ui")
64 if (stateResult != fray::errors::NONE)
74 if (restoreResult != fray::errors::NONE)
82 F_err result = fray::errors::NONE;
86 if (result != fray::errors::NONE)
96 if (result == fray::errors::NONE)
Owns and coordinates projects, their queues, application work, prompts, and logs. Project work runs o...
F_err openApplicationState(const std::filesystem::path &directory)
Opens the application directory and its default state namespace.
F_err restoreProjects(ipc::IPCManager &ipc)
Queues restoration of the saved project session when enabled.
logs::LogStore & logStore()
Returns the manager-owned log store by reference.
Owns the TCP servers and the threads around them.
F_void setFontReader(std::function< std::vector< std::string >()> reader)
Sets how installed font families are listed during startup. Call before startLoading().
F_void start()
Starts the network thread and the engine message thread, then returns. Does nothing if already starte...
F_void startLoading(const std::string &name, const std::string &version)
Queues the initial hidden loading window and its application information.
TCPServerSP createTCPServer(F_ushort port)
Creates a TCP server and starts it accepting. Must be called before start(). Not thread-safe; call fr...
F_void finish()
Stops IPC, releases servers, and shuts the application down exactly once. Call on the controlling thr...
F_void wait()
Blocks until every server has stopped and the queued messages have been handled. While waiting it pos...
Keeps the sink attached to live managers and detaches it on destruction. Declare after the managers s...
Captures Engine logs before managers exist and forwards them once attached. Construct before startup ...
F_void stopForwarding()
Stops forwarding to the renderer while continuing to store Engine logs.
void setApplicationFolder(const std::filesystem::path &folder)
Set the destination folder for application and fallback entries. Locks _mutex and closes the current ...
Registry of the engine's threads: starts them, names them, asks them to stop and joins them....
F_long F_err
Error return type used across the Engine; the value is a fray::errors::code (0 / NONE means success).
static F_err launchElectron(const char *executable, F_ushort port)
Starts the Electron UI (npm run start in the Electron folder) without waiting for it....
F_err main(F_long argc, F_char *argv[])
Engine entry point: builds the managers, starts the TCP server and message threads,...
#define APPLICATION_VERSION_BUG
Application bug-fix (patch) version number, shared by Engine and Electron.
#define APPLICATION_VERSION_MINOR
Application minor version number, shared by Engine and Electron.
#define BUILD_NAME
Public name of the current application build.
#define APPLICATION_VERSION_MAJOR
Application major version number, shared by Engine and Electron.
const F_char * description(code err)
Formats an error code as "Error <number>: <description>". Not thread-safe: the text lives in a shared...
std::vector< std::string > installedFamilies()
Lists the font families installed on this computer. Safe to call from any thread; it can take a while...
F_void engineInfo(const F_char *fmt,...)
Log info for Engine.
F_void engineError(const F_char *fmt,...)
Log error for Engine.
F_void engineSession(const std::string &name)
Marks the start of a log session under the calling thread's project tag. The Engine records it as a s...
constexpr std::uint32_t MAIN_WINDOW_ID
Renderer instance ID assigned to the first application window.
F_err spawn(const std::vector< std::string > &command, const std::filesystem::path &workingDirectory, const std::vector< std::pair< std::string, std::string > > &environment={})
Starts a child process without waiting for it (fire and forget). The child inherits this process's st...
void sendProjectOpenResult(ipc::IPCManager &ipc, const FrayManager::OpeningOrigin &origin, const std::string &path, F_err result)
Sends the result of a project-open or create request.
Address of the process that requested a project open.
uint16_t F_ushort
Unsigned 16-bit integer (used for ports).
int32_t F_long
Signed 32-bit integer (also the base of F_err).
char F_char
Alias for char.