• 🏠
  • Community stores
  • Widgets and activities
View as Markdown

Widgets and activities

A widget is a small web page of your own inside a community: a mini game, a vote, a scoreboard, a drawing wall. An activity is a widget people start together in a voice channel.

Where widgets show

  • On your page: a page's own widgets.
  • As activities: Design… marks a widget an Activity (and how many players). A channel's header then shows Activities; people Start, Join or Watch one. Games Communities draws the bar of players and watchers above it.

A widget runs only once the viewer says yes for that store (one click, remembered). Officers always see their own. Viewers can turn widgets off in Settings.

The seal

A widget is its own page in a sealed frame: no network, storage, cookies, forms, popups or way out. It talks to Games Communities only through GC.* calls, each returning a Promise.

Widget calls

CallWhat it does
GC.me()The viewer if a member: { id, name, rank, flair }, else null.
GC.store(){ name, accent, games: [{ ident, title }] }.
GC.theme(){ accent, font, dark }.
GC.open(ident)Opens a game's page.
GC.toast(text)A short message in the store's name.
GC.data(key)A public. key of the community's data.
GC.send(name, data)Calls the scripts' widget(name) handler and answers with its return (members only).
GC.on(name, fn)Hears a script's live(name, data).
GC.picture(hash)An upload as a data: address for <img>.
GC.resize(px), GC.autoResize()Its height (60-2400).
GC.fetch(url)A GET of one of its allowed hosts, through Games Communities: { status, type, body }, text up to 256 KB.
DevicesTicked in its editor (microphone, camera, gamepad, fullscreen): the microphone and camera once the viewer says yes (asked once for the group), the rest at once.
GC.show(pieces)Games Communities draws its own pieces instead of the page (below).
GC.burst(name)A burst over this viewer's window (12 a minute).
GC.sounds(), GC.sound(id, volume)The soundboard's sounds, played here (4 a second, cut at 5.2 s).
GC.scare({ picture, sound, seconds, size })A jump scare over the screen (app only, once the viewer allowed it, one every 10 s).
GC.room(name)A shared live room (below).

GC.show

Pieces Games Communities draws for you, with real game cards and buttons:

GC.show([
  { kind: "text", text: "Tonight's pick", size: "big" },
  { kind: "game", ident: "cat-quest" },
  { kind: "row", children: [
    { kind: "button", label: "I'm in", id: "in" },
    { kind: "progress", value: 7, max: 10, label: "7 of 10 seats" },
  ] },
]);
GC.on("press", ({ id }) => GC.send("signup", { id }));

Kinds: text (size: big|small), game, button (presses come to GC.on("press")), picture (hash, alt), progress, row and column with children. Up to 200 pieces, 4 deep. GC.show([]) shows the page again.

GC.room

Every widget can join a shared room, kept in step for everyone in it:

const room = await GC.room("board");
room.on("change", () => draw(room.all()));
room.set("cell-4", "X");        // JSON, up to 16 KB
room.say({ cheer: true });       // a message to the others, not kept

me, write, peers, get, all, set, delete, say, on('change'|'say'|'peers'|'status'), leave.

Widgets with packages

A widget's code can be a module (JavaScript or TypeScript) with npm packages: they are pinned, their licences listed, and bundled when you save. GC.me asks the viewer once whether the widget may know who they are.

Stopped widgets

A widget that keeps the computer busy too long is stopped.