Website and HTML panels โ
Use ObjectDefinition.web to open a developer-chosen website or a bundled HTML interface when someone taps your Gizmo. The source is fixed in your definition. Players cannot configure its URL or replace its HTML. Scape owns opening, dismissal, source labels and deletion permissions.
Choose a website for an existing app that permits framing. Choose bundled HTML for a self-contained interface with inline styles and optional JavaScript. Each player gets a separate document; shared state lives in validated Gizmo actions and reaches the interface through ObjectView.webData.
A fixed website โ
ts
import { defineObject, exactKeys, record } from '@scape-wtf/sdk';
export const website = defineObject<Record<string, never>>({
type: 'my-project.website',
version: 1,
emoji: '๐',
label: 'My website',
hint: 'open my website',
initial: () => ({}),
valid: (state): state is Record<string, never> => record(state) && exactKeys(state, []),
actions: {},
web: { title: 'My website', url: 'https://example.com/app' },
});1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
The floored example chooses https://floored.app/ and bundles the site's app icon as its sprite. It has no URL field, Configure menu or gameplay bridge. Delete is its only management action. This is a generic SDK capability: use your own fixed HTTPS endpoint in your own definition.
Sites must permit framing through their CSP and X-Frame-Options policies. Scape preserves the site's origin for modules and storage inside a scriptless wrapper that permits the declared origin. Off-origin redirects are blocked; choose the final embed origin. Browser restrictions on third-party storage and login still apply. Scape's own hostname cannot be embedded.
Optional expansion โ
Website, static HTML and interactive HTML panels include an Expand button by default. Developers can hide it with fullscreen: false in the fixed web declaration, or explicitly enable it with fullscreen: true:
web: { title: 'My website', url: 'https://example.com/app', fullscreen: false }
This option is implemented in source and awaits npm/host publication. Expanding keeps the same document and public bridge alive. Desktop uses a phone-shaped panel up to 430 ร 860 CSS pixels, scaled to fit between Scape's controls. Mobile fills the available safe area while keeping those controls visible. The panel tracks window and keyboard changes; retracting restores its anchored layout. This does not enable the browser Fullscreen API inside the frame.
Bundled HTML with shared state โ
Static HTML needs only web: { title, html }. Set interactive: true to enable inline JavaScript. Add context: true to receive public state and a MessagePort; list each participant action the document may request in actions.
This complete counter keeps DOM updates local while its reducer validates shared state changes. Use Puzzle terminal for a fuller interface with clues, pending state, results and a connection to another Gizmo.
ts
import { defineObject, exactKeys, record, requirePayload } from '@scape-wtf/sdk';
const html = `
<style>body { font: 16px system-ui; padding: 16px; } button { padding: 12px; }</style>
<p>Count: <output id="count">0</output></p>
<button id="increment" disabled>Add one</button>
<script>
let port;
let request = 0;
const button = document.getElementById('increment');
window.addEventListener('message', event => {
if (event.source !== window.parent ||
event.data?.protocol !== 'scape.web.v1' ||
event.data?.type !== 'connect' || event.ports.length !== 1) return;
port?.close();
port = event.ports[0];
port.onmessage = ({ data }) => {
if (data?.protocol !== 'scape.web.v1') return;
if (data.type === 'context') {
document.getElementById('count').textContent = String(data.data.count);
button.disabled = !data.actions.includes('increment');
}
if (data.type === 'result') button.disabled = false;
};
port.start();
});
button.addEventListener('click', () => {
if (!port) return;
button.disabled = true;
port.postMessage({ protocol: 'scape.web.v1', type: 'action',
id: 'increment-' + (++request), name: 'increment', payload: {} });
});
window.addEventListener('keydown', event => {
if (event.key === 'Escape') port?.postMessage({ protocol: 'scape.web.v1', type: 'close' });
});
</script>
`;
export const counter = defineObject<{ count: number }>({
type: 'my-project.html-counter',
version: 1,
emoji: '๐งฎ',
label: 'HTML counter',
hint: 'open the counter',
initial: () => ({ count: 0 }),
valid: (state): state is { count: number } =>
record(state) && exactKeys(state, ['count']) &&
Number.isSafeInteger(state.count) && Number(state.count) >= 0 && Number(state.count) <= 999999,
actions: {
increment: {
permission: 'participant',
run: (state, payload) => {
requirePayload(payload, []);
return { count: Math.min(999999, state.count + 1) };
},
},
},
web: { title: 'Counter', html, interactive: true, context: true, actions: ['increment'] },
view: state => ({
title: 'Counter', description: '', controls: [], webData: { count: state.count },
}),
});1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
webData updates preserve the document and focus. Use textContent for received values, and keep drafts such as keypad input in the document. Never construct HTML or scripts from untrusted data. Scape does not synchronize DOM or JavaScript variables between players.
Bridge messages โ
Register the window message listener before the document finishes loading. On opening, Scape transfers one MessagePort in a scape.web.v1 / connect message. Bundled HTML checks event.source === window.parent, as above. A remote website has a wrapper between it and Scape, so it must check both:
js
if (event.source !== window.parent.parent || event.origin !== 'https://scape.wtf') return;1
Also validate the protocol, connect type and exactly one transferred port before accepting it. Use that port for subsequent messages; close an earlier port if replaced.
| Direction | Type | Fields besides protocol and type |
|---|---|---|
| Scape โ panel | context | roomId (string or null), objectId, objectType, floor, data, actions |
| Panel โ Scape | action | id, name, payload |
| Scape โ panel | result | id, ok, optional error |
| Panel โ Scape | close | None |
An accepted result means the authoritative action completed. Render shared state from context, not from a guessed local result. Match responses by request ID, show a useful failure state and wait before retrying. Malformed messages can be ignored without a result. Closing or suspending a panel revokes its port; there is no durable request queue or delivery to the next opening.
Only explicitly listed participant actions are available. Editor and remover actions cannot be exposed. The host also checks current object/session, permissions, room restrictions and connection locks. Reducers must still validate every payload; a client-side check or hidden button provides no authority.
Context is public and unsigned. It contains no authenticated player identity, account session or credentials. It is not authentication for an external service. There are no wallet, stone, native-plugin or arbitrary game-service calls.
Describe an embedded form for agents โ
Return webForm from view(state, viewer) when an embedded panel has a player action. Supply a public description, standard SDK fields and controls. Give each control its existing bridge action and list the fields it submits. The room gateway checks the web action allowlist, room restrictions, agent permissions and current values. Continue to validate inputs in the action handler.
The Puzzle terminal supplies its four clues and a Four-digit code field bound to submit. When solved, its form reports Signal restored and disables the submit control. The agent can read the same clues as the person using the keypad. Keep answers, private identities and server-only data out of these descriptions.
Connect the puzzle to a lamp โ
- Place Puzzle terminal and Lamp from the developer-world palette.
- Use Connect toโฆ to connect the terminal's Solved output to the Lamp's Power input.
- Open the terminal and solve the clues (
3142). Itssubmitaction validates the guess and sets shared solved state. - The boolean output powers the lamp for everyone. The lamp's manual power controls are locked while connected.
- As an editor, confirm Reset puzzle to release the output and play again.
The HTML can submit a guess; it cannot reset the puzzle or edit wiring. Other compatible boolean inputs also work. This does not lock doors or change world admission. The solution is public source: use it for gameplay, never as an authentication or payment boundary. See connectors and signals. Both web projects are learning examples, not shop offers.
Isolation and lifecycle โ
Bundled HTML has an opaque origin. Static documents cannot run scripts; interactive documents can run inline scripts but cannot access Scape's DOM, storage or credentials. Their content policy blocks fetch/XHR, external scripts and styles, nested frames, workers, objects, forms and media. Inline CSS and data images are permitted. Dynamic evaluation is not enabled.
Remote websites retain their own origin and networking. They remain sandboxed without top-level navigation, popups, downloads or access to Scape's internals. The host denies sensitive features including camera, microphone, geolocation, screen capture, clipboard, fullscreen and browser payments. Referrers are suppressed.
These controls are not CPU or memory quotas. Bundled HTML can attempt to navigate itself, which may send a request before the host observes the load and revokes the bridge. Never include secrets in HTML, public data or source bundles. Remote content may change after a Gizmo release; a source label does not guarantee reviewed content.
Closing, backgrounding, navigation or changing worlds unloads the frame and revokes the bridge. State refreshes cannot reopen it; close and tap the Gizmo to open a fresh document. Cooperating HTML sends close for Escape. The host cannot capture Escape inside an arbitrary remote document; users can tap outside or Tab back to host controls.
Installed iOS with embedded-web isolation version 1 uses the same anchored viewer for websites and bundled HTML. Embedded content cannot call native app plugins; WebKit capture, motion permissions and media playback are disabled. Scape audio continues through its native services. Older app binaries require an update. This support requires a matching native build; source completion is separate from App Store/TestFlight availability and device acceptance.
Shop previews do not run embeds. Optional rooms.allow and rooms.deny restrict placements; deny wins and an empty allow list denies all. They are not signed identity or an external-backend access policy.
API and limits โ
Declare exactly one of url or html on ObjectDefinition.web. Do not put data in the declaration: return public data from ObjectView.webData and opt into context. The former state-derived ObjectView.web field is rejected.
Use validGizmoWebDefinition to check a fixed declaration, validGizmoWebUrl to check an HTTPS source and resolveGizmoWebView to combine a definition with public view data. GizmoWebView / validGizmoWebView describe the resolved view; gizmoWebRoomAllowed evaluates its room restriction. boundedJsonData(value, maxLength) checks JSON data against an encoded-character budget without expanding shared references; cycles and repeated object references are rejected.
See web API declarations, sprite images and limits for exact bounds.
