@mserve-io/mserve v0.3.1
MServe
MServe allows you to easily create and host virtual worlds populated with https://mml.io(MML Documents).
This repository contains tools to aid in deploying your MML documents and world configurations to MServe from the command line or as hook for esbuild-plugin-mml.
CLI
The CLI currently supports deploying a set of MML documents files (or a directory containing them) to a specific project on MServe.
Installation
npm i -g @mserve-io/mserve
This project also provides a Nix flake that packages the CLI with it's shell completions.
Shell Completions
Shell completions can be generated for your current shell, with install instructions, using the following command:
mserve completion
You can get completions for a specific shell by setting the $SHELL
environment variable:
SHELL=bash mserve completion >> ~/.bashrc
Authentication
This tool requires an MServe API key with at least write
permissions to MML Objects the target project. This can be specified on the command line with the --api-key
flag, or as an environment variable (recommended).
mserve --api-key 'msak_<XX>' ...
export MSERVE_API_KEY='msak_<XX>'
mserve ...
Deploy
mserve deploy --project <project-id> ./examples
esbuild plugin
This library exports an OutputProcessorProvider
for esbuild-plugin-mml, which hooks into the build process, re-writes the imports to a format usable on MServe. The mserve deploy
command can be then pointed at the build directory to deploy the build artifacts.
Below is an example usage of the outputProcessor
import { mserveOutputProcessor } from "@mml-io/mserve";
const {
MSERVE_PROJECT,
MSERVE_API_KEY,
MMLHOSTING_PROTOCOL = "wss",
MMLHOSTING_HOST = "mmlhosting.com"
} = process.env as { [env: string]: string };
const buildOptions: esbuild.BuildOptions = {
entryPoints: ["src/world.ts"],
outdir,
bundle: true,
minify: true,
plugins: [
mml({
verbose: true,
outputProcessor: mserveOutputProcessor({
projectId: MSERVE_PROJECT, // Required: The project to deploy the documents and world config to
apiKey: MSERVE_API_KEY, // Required: Your MServe API key
}),
importPrefix: `${MMLHOSTING_PROTOCOL}://${MMLHOSTING_HOST}/v1/`, // Required: re-write the imports to a full URL to the document.
}),
],
};
esbuild.build(buildOptions).catch(() => process.exit(1));
11 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago