Skip to content

SurfaceHandle

public sealed class SurfaceHandle

Namespace Sideload.Api

Added in 1.13.0

Handle to a mounted surface: the same call and event channel an app has, minus everything that only makes sense on a phone.

public string Id { get; }

Added in 1.13.0

The id this surface was mounted under.

public SurfaceHandle OnCall(string name, Func<string, string> handler)

Added in 1.13.0

Answer s1.call(name, arg) from this surface’s page. Same rules as an app’s handler: it runs on the Unity main thread in the same frame, and returns a string.

public SurfaceHandle Emit(string name, string payload = "")

Added in 1.13.0

Push an event at this surface’s page - s1.on(name, fn). Nothing happens when the surface is not mounted; the page picks the state up when it next builds.

public SurfaceHandle AllowHost(string host)

Added in 1.13.0

Let this surface’s page reach one host with fetch. The allowlist starts empty.

public SurfaceHandle Image(string name, byte[] png)

Added in 1.32.0

Publish a picture this surface’s page can draw with <img src="s1://<name>">, exactly as an app does. Null or empty bytes remove it.

It was missing, and the store never cared: pictures are held by (id, name) and nothing asks whether the id belongs to an app or a surface. So a surface could always have them - it just had no supported way to say so, and the one mod that needed it reached past this file into the internals because it compiles the shim in as source. A mod that references the DLL could not have done that at all.

PNG bytes rather than a texture, for the reason the whole file gives: nothing here references a Unity type and nothing here is going to start.

surface.Image("icon/" + itemId, pngBytes);
public void Unmount()

Added in 1.13.0

Take this surface down.