Skip to documentation
DevelopersManaurum Platform v2
Back to Manaurum

Manaurum Platform v2

Browser SDK reference

Import the public ES module and initialize it once. The shared example below applies theme, appearance, accent and language to the document root.

Contracts reviewed: · SDK version: 2.6.1

Lifecycle and context

ManaurumV2.init(options) returns a singleton. onReady(cb) receives the context; onThemeChange(cb) receives a theme string after context updates, so read appearance and accent from app.context. onDeviceChange(cb) receives updated device context; onLocaleChange(cb) receives locale and direction; onAuthFailure(cb) receives a 401 response. Each subscription returns an unsubscribe function. Getters: context, theme, appearance, accent, device, platform, isMobile, locale, dir. Before readiness, context/theme/appearance/accent/locale/dir are null; device/platform default to desktop and isMobile to false. ManaurumV2.version identifies the SDK.

js
import { ManaurumV2 } from 'https://manaurum.com/sdk/manaurum-v2.mjs';
const app = ManaurumV2.init();
const applyContext = () => {
  const ctx = app.context;
  if (!ctx) return;
  const root = document.documentElement;
  root.dataset.theme = ctx.theme;
  root.dataset.appearance = ctx.appearance;
  root.dataset.accent = ctx.accent;
  root.lang = ctx.locale || navigator.language;
  root.dir = ctx.dir || (root.lang.startsWith('he') ? 'rtl' : 'ltr');
};
app.onReady(applyContext);
app.onThemeChange(applyContext);
app.onLocaleChange(applyContext);

HTTP and layout diagnostics

app.fetch(path, init) follows the Fetch API and defaults to credentials: include. Use rooted paths or absolute HTTPS URLs. Set Content-Type when sending JSON. Retries are off by default (one attempt). Opt in with retry.attempts in the second argument to app.fetch. Then GET/HEAD/OPTIONS retry network failures, 429 and 5xx; retry.force is for writes you have made idempotent. Check response.ok yourself. app.checkLayout() reports clipped content to the shell and console. Automatic checks can be disabled on the first init with layoutCheck: false; explicit checkLayout() still runs.

js
const response = await app.fetch('/api/items', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ title: 'First item' }),
});
if (!response.ok) throw new Error(String(response.status));
const item = await response.json();

const listResponse = await app.fetch('/api/items', {
  retry: { attempts: 3, baseDelayMs: 200 },
});
if (!listResponse.ok) throw new Error(String(listResponse.status));
const items = await listResponse.json();

Drive picker and capability requests

pickFromDrive(options) opens the shell picker, returning cancellation or file handles with short-lived download URLs; download promptly and ask again instead of caching handles. capabilities() returns allowed, pending, not_allowed and turned_off lists, or an error. requestCapability(name, note) opens a request from the user’s own action: allowed, requested, pending, opened_permissions and cancelled are distinct outcomes. Do not automatically reopen a dismissed request. waitingForAdmin(options) returns a localized DOM block with a request button. All these bridges require a ready shell; handle no_shell, timeout and unavailable outcomes.

js
app.onReady(async () => {
  const access = await app.capabilities();
  if (access.ok && !access.allowed.includes('os.ai.complete')) {
    document.querySelector('#summaries').replaceWith(
      app.waitingForAdmin({ capability: 'os.ai.complete', feature: 'Summaries' }),
    );
  }
});
async function chooseImage() {
  const result = await app.pickFromDrive({ accept: ['image/'] });
  if (result.cancelled) return;
  const response = await fetch(result.files[0].download_url);
  if (!response.ok) throw new Error(String(response.status));
  return response.blob();
}

This is a feature reference, not a live service-health dashboard. Availability also depends on workspace permissions, integrations and feature flags.

Getting startedFeature availability