Skip to main content

metapage.json

The metapage.json file defines the complete workflow: which metaframes to load, the data connections between them, and optional layout metadata.

TypeScript types

// Top-level definition
interface MetapageDefinition {
version: "2";
metaframes: Record<string, MetaframeDefinition>;
meta?: MetapageMeta;
}

interface MetaframeDefinition {
url: string; // URL of the metaframe web application
inputs?: MetaframeInput[]; // Incoming data connections
}

interface MetaframeInput {
metaframe: string; // Source metaframe key
source: string; // Source output name (glob supported)
target: string; // Target input name (or path prefix ending in /)
}

interface MetapageMeta {
name?: string;
layouts?: {
"react-grid-layout"?: ReactGridLayoutConfig;
};
}

Annotated example

{
"version": "2",

"metaframes": {
"data-generator": {
"url": "https://random.mtfm.io/#?distribution=sin"
},

"chart": {
"url": "https://plot.mtfm.io/",
"inputs": [
{
"metaframe": "data-generator",
"source": "v",
"target": "v"
}
]
},

"editor": {
"url": "https://editor.mtfm.io/",
"inputs": [
{
"metaframe": "data-generator",
"source": "v",
"target": "value"
}
]
}
},

"meta": {
"layouts": {
"react-grid-layout": {
"docs": "https://www.npmjs.com/package/react-grid-layout",
"props": {
"cols": 12,
"rowHeight": 200,
"margin": [10, 20],
"containerPadding": [5, 5]
},
"layout": [
{ "i": "data-generator", "x": 0, "y": 0, "w": 6, "h": 3 },
{ "i": "chart", "x": 6, "y": 0, "w": 6, "h": 4 },
{ "i": "editor", "x": 0, "y": 3, "w": 6, "h": 2 }
]
}
}
}
}

Field reference

metaframes[key]

FieldTypeDescription
urlstringURL of the metaframe web application. May include URL parameters. Supports _param_ substitution from the metapage URL (see URL parameters).
inputsMetaframeInput[]Incoming data connections. Empty means the frame receives no piped data.

inputs[n]

FieldTypeDescription
metaframestringKey of the source metaframe
sourcestringOutput name from the source, or a glob pattern (see Data Flow)
targetstringInput name in this metaframe. Ends with / to use as a directory prefix; omit for same name as source.

meta.layouts.react-grid-layout

Layout positions use the react-grid-layout format:

FieldTypeDescription
istringMetaframe key (must match a key in metaframes)
xnumberColumn position (0–cols)
ynumberRow position
wnumberWidth in columns
hnumberHeight in row units

Loading programmatically

import { Metapage } from "@metapages/metapage";

const definition = {
version: "2",
metaframes: { /* ... */ },
};

const metapage = await Metapage.from(definition);

Or fetch from a hosted URL:

const definition = await fetch("https://metapage.io/m/<id>/metapage.json").then(r => r.json());

Source: metapage/v0_4/metapage.ts