Shaidin
Cross
Cross is a library that developers can use to create application for multiple platforms from a single code base.

┌───────┐ ────► iOS(ipa) │ │ │ │ ────► Android(aab/apk) │ │ ┌───────────┐ │ │ ────► Linux(deb) │ The Input │ ────► │ Cross │ └───────────┘ │ │ ────► Windows(msi) │ │ │ │ ────► Mac(pkg) │ │ └───────┘ ────► Web(html/wasm)

The Input
Developers need to provide application core in C++ and the UI in HTML, JS, and CSS format.

Core

Application core contains the following functions that developer needs to provide definition:

namespace life_cycle { void Begin(); void End(); void Create(); void Destroy(); void Start(); void Stop(); void Restart(); }

Life Cycle of Core

Run Forground Show Hide Background Quit Begin ───► Create ───► Start/Restart ◄──► Stop ───► Destroy ───► End ▲ ▲ └────────────────────────────────────────┘

UI

Each application can have one or more logical parts. For each part, developer needs to create a new class overriding the provided class Stage.
The business logic goes into member functions of this class. The UI should be defined in a HTML file in asset folder that will be loaded by its name.
Each part of the application, can have more than one HTML file that can be navigated by links.

Core-UI communication

Within the core, a function is provided to inject JS to UI. The input is c-style string.
Within the UI, a function is provided to post messages to core. The inputs are
  1. id (string)
  2. command (string)
  3. info (string optional)

Handling UI Messages

The class Stage has a member handler_

using HANDLER = std::function<void(const char* command, const char* info)>; std::map<std::string, HANDLER> handlers_;

that developer can fill with functions that needs to be called from UI. The key of the map corresponds to the id of message at UI side.

Feeding Binary Data

The content for HTML elements like img, audio, a, and etc can be provided in binary format from core. The class Stage has a method

virtual void FeedUri(const char* uri, std::function<void( const std::vector<unsigned char>&)>&& consume) = 0;

that receives URI request from UI and feeds it with binary data.

Save and Load

Two functions

std::string GetPreference(const char* key); void SetPreference(const char* key, const char* value);

are provided to save and load key-value pairs that are persistent across application runs.
Build
For each platform there is a separate CMakeLists.txt file that can be built by cmake tool.
Output
  • iOS: ipa file that can be uploaded to app-store
  • Android: aab/apk file that can be uploaded to play-store
  • Linux: deb file that can be installed on Debian based systems
  • Windows: msi file that can be installed on Windows 10
  • Mac: pkg file that can be installed on MacOS
  • Web: html/wasm files that can be served by a http server