mathinggames

Marketplace

Repos

Marketplace repos are designed to be fully static. An example of the directory structure can be seen here.

|-- apps
|   |-- anura.example
|   |   |-- app.zip
|   |   |-- manifest.json
|-- libs
|   |-- anura.examplelib
|   |   |-- lib.zip
|   |   |-- manifest.json
list.json
manifest.json

Manifest

Each app is supposed to have its own manifest that lists details about the app.

Here is an example of a manifest.json

{
    "name": "Example app",
    "icon": "example.png",
    "summary": "(tiny app description)",
    "desc": "(longer app description)",
    "package": "anura.example",
    "data": "app.zip",
    "installHook": "install.js",
    "screenshots": [
        {
            "path": "screenshots/something.png",
            "desc": "(screenshot desc)"
        },
        {
            "path": "screenshots/something2.png",
            "desc": "(screenshot desc)"
        }
    ],
    "version": "1.0.0",
    "dependencies": ["(package identifier)"],
    "category": "game"
}

This is mostly the same for libraries, minus the dependencies and installHook sections.

Publishing

To make a repo accessible via the Store Library you should use the utility create-anura-repo. It is as simple as running a command in your terminal.

$ npx create-anura-repo

After doing this you can add host the repo statically and be able to use it in libstore.

libstore

Initialization

To initialize the libstore library, call the Store constructor with a networking client. The client must have a fetch function that returns Response objects.

Usage:

let libstore = await anura.import("anura.libstore@2.0.0");

marketplace = new libstore.Store(anura.net, {
    onError: (appName, error) => {
        anura.notifications.add({
            title: "libstore",
            description: `libstore encountered an error while installing ${appName}: ${error}`,
            timeout: 5000,
        });
    },
    onDownloadStart: (appName) => {
        anura.notifications.add({
            title: "libstore",
            description: `libstore started downloading ${appName}`,
            timeout: 5000,
        });
    },
    onDepInstallStart: (appName, libName) => {
        anura.notifications.add({
            title: "libstore",
            description: `libstore started installing dependency ${libName} for ${appName}`,
            timeout: 5000,
        });
    },
    onComplete: (appName) => {
        anura.notifications.add({
            title: "libstore",
            description: `libstore finished installing ${appName}`,
            timeout: 5000,
        });
    },
});

Adding a repo

To fetch a repo and its contents use the getRepo method. This method will return a StoreRepo or a StoreRepoLegacy Object. The repo url must end with a trailing slash.

Usage:

const marketplaceRepo = await marketplace.getRepo(
    "Anura App Repository",
    "https://raw.githubusercontent.com/MercuryWorkshop/anura-repo/master/",
);