Skip to content

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

@James-Livesey

Description

@James-Livesey

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:

  • Always works offline, even when cache does not contain Adapt UI (such as if LiveG OS is booted for first time and a base app is then opened offline)
  • Adapt UI version is pinned to the version present in gShell (this guarantees stability regarding version compatibility)
  • Possibly faster loading times (not resolving through cache but instead directly working with gshell:// protocol when running on gShell)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions