LiveGTech / gShell

Interactive graphical desktop environment for LiveG OS.
https://liveg.tech/os
Other
15 stars 3 forks source link

Add support for base apps (such as Calculator and Camera) #27

Open James-Livesey opened 1 year ago

James-Livesey commented 1 year ago

It would be cool to also be able to run most of these apps via a web browser on non-LiveG OS devices, while providing extra functionality when on LiveG OS for better integration.


Base apps should be present in the gShell file tree (so they can be directly included in the gShell environment for when used offline), but could also be present on the LiveG website to be accessible in a web browser on non-LiveG OS devices. We can do this by creating a git repo for each base app, and then using git submodules to include those repos in the gShell tree.

For importing libraries such as Adapt UI in both contexts (inside and outside of gShell), we can use await import instead of import to allow for the use of arbitrary/conditional URLs:

// Without arbitrary URL support (JS requires simple string literal with this syntax)

import * as $g from "https://opensource.liveg.tech/Adapt-UI/src/adaptui.js";
// With arbitrary URL support

const LIB_ADAPT_UI_ROOT = _sphere.isSystemApp() ? "gshell://lib/adaptui" : "https://opensource.liveg.tech/Adapt-UI";

var $g = await import(`${LIB_ADAPT_UI_ROOT}/src/adaptui.js`);

The advantages of this are:

Any app or website can detect whether it's running in gShell by determining if there is the window._sphere object present. We can enhance this by providing a function (isSystemApp) which checks window.location.href to see if it starts with gshell:// — this would then make it clear that we're running as a base app as opposed to an app installed from Sphere. (It might also benefit to have a function such as isInstalledApp to determine whether a page is running in Sphere or as part of an installed web app.)

It will also be necessary for us to implement custom web API functionality through _sphere; for example, to switch the camera between front and back in the Camera app, and to set system wake timers in the Clock app for functionality such as alarms and timers. Some non-standard API ideas could also be implemented in _sphere and then exposed publicly for all installed web apps by being abstracted in Adapt UI.