Frostdev
All guides

Glaze Field guide

Glaze mods

Make a Glaze mod: the manifest, permissions, slots and the glaze object your code talks to.

33 min read10 chaptersBy FrostdevUpdated
GlazeA practical path
  1. 01Enable on your site
  2. 02Choose your palette
  3. 03Make it comfortable

Mods need Glaze 3.0.4 or newer.

A mod is a signed bundle with settings Glaze draws for it and, in Chrome, code and UI slots that talk to Glaze through the glaze object below. The manifest can also carry Look parts, which apply while the mod is on, with or without code.

  • Code runs only in Chrome, in a sandbox with no extension APIs or access to the school’s page. Workers have no network of their own; they use glaze.fetch. Where a mod has code, the editor says it needs Chrome.
  • Everything a mod can do is in this document. Glaze checks broker calls against what the student allowed and draws component trees from data, with textContent and setProperty only. A frame UI draws its own page inside its slot.
  • Types for editor completion: types/glaze.d.ts. Add /// <reference path="path/to/glaze.d.ts" /> to the top of a script.

Widgets with no code use blocks, drawn by Glaze on Chrome, Firefox and Safari.

A mod

my-mod/
  mod.json        the manifest
  hooks.js        code, run in a Worker (optional)
  tile.html       a page for a slot, with its .css and .js files (optional; only without data permissions)
  img/leaf.png    pictures a component tree draws

mod.sig, the author’s signature, is added when the mod is exported. Leave it out of the folder.

Files. js html css json txt md png jpg jpeg gif webp avif woff2, checked against their bytes. No SVG, wasm or archives. Paths use letters, digits, _ - . and /, no part starts with a dot, at most 200 characters and 8 levels. At most 256 files, 2 MiB in all, 256 KiB of .js; mod.json at most 64 KiB. A .glazemod file is a zip of these; a glazemod1: code is the same zip as text, up to 64 KiB.

mod.json

{
  "glaze": 1,
  "name": "Next Due Countdown",
  "version": "1.0.0",
  "author": { "name": "Kai", "key": "<your author key>" },
  "permissions": [{ "id": "todo", "why": "Finds your next due date so the tile can count down to it." }],
  "hooks": "hooks.js",
  "ui": { "tiles": [{ "id": "next-due", "name": "Next due", "sizes": ["s", "m"] }] },
  "replaces": [],
  "settings": [{ "id": "course", "type": "toggle", "label": "Show the course name", "default": true }]
}

Glaze takes mod.json exactly as written or refuses the mod, naming the field: an unknown key, a wrong type or an over-long value is an error, and nothing is trimmed.

Field
glaze Required. 1.
name Required. One line, at most 40 characters. Its normalized name is part of the mod’s id; changing that makes a different mod.
version Required. 1.2.3 or 1.2.3-beta.1; no +build.
author Required. name (at most 40) and key, your Ed25519 public key (43 base64url characters). In a folder loaded in dev mode, leave key out and Glaze uses your author key.
permissions [{ id, why }], below.
parts Look parts, below.
packs Sticker and pet files, below; no code or permissions required.
ui Slots: tiles (at most 8: id, name, sizes of s m l, optional file), rail (at most 4: id, name, optional file), nav and background (null, {} or { "file": "x.html" }). Ids are a-z 0-9 -, up to 32, starting with a letter. A file is an HTML file of the mod.
hooks A .js file of the mod, run in a Worker.
replaces What the mod can take over, below.
settings At most 32, below.
tools At most 8, for the agent apps the student connects, below.

packs

Up to 24 stickers (png, webp, avif, json for Lottie) and 4 pets (png or webp sprite sheets). Each entry has a unique id (the slot-id rules), a one-line name of at most 40 characters, and a file in this bundle. Stickers are checked and cleaned before display; pets go through the existing pet import checks when added to the library. Packs need no hooks or UI and work on Chrome, Firefox and Safari.

{ "packs": { "stickers": [{ "id": "leaf", "name": "Leaf", "file": "img/leaf.png" }], "pets": [{ "id": "buddy", "name": "Buddy", "file": "img/buddy.webp" }] } }

Permissions

Each is declared with a reason. The student sees Glaze’s description of it and the reason quoted (“The author says”), chooses what to allow, and can take any of it back later. A call without its grant rejects with permission.

id Gives
courses glaze.courses(), glaze.cards.decorate() and the courses event.
todo glaze.todo(), glaze.schedule() and the todo, complete and submit events.
grades glaze.grades() and the grade event.
nav.read glaze.nav.model() and the nav.change, nav.navigate, nav.expand, nav.collapse and nav.sheet events. Glaze’s bar shows course names and unread counts, so this is personal data.
nav.items glaze.nav.add(), glaze.nav.update() and glaze.nav.remove(): up to 8 items of the mod’s own in Glaze’s bar, and the nav.action event.
nav.layout glaze.nav.layout(), a layout returned from glaze.nav.items(), and a nav in glaze.look.override(): a layout proposed over the student’s while the mod runs. Its links go only to pages of the school’s site.
agents Agent apps the student connects in Settings → AI → Agents can call the mod’s tools, below.
network:<host> glaze.fetch() to https://<host>/. The host is a lowercase DNS name with at least two labels: no port, wildcard, address or local name, and subdomains don’t count. At most 8.
documents On the Documents page: glaze.documents.list(), open(), create(), add(), remove() and style(), and the documents.action and documents.change events. The list holds the titles, courses and word counts of the student’s documents, so this is personal data.
documents.read glaze.documents.read() and glaze.documents.export(): a document’s text, and the file it saves as. Needs documents too.

why is one line of at most 280 characters.

  • Personal data stays in the Worker. A mod that declares courses, todo, grades, nav.read, documents or documents.read has no page of its own: no HTML file anywhere in its bundle, and every UI is a component tree. A mod that has held such data stays Worker-only through updates.
  • Glaze adds its own warnings to the prompt: personal data together with a network host (“could send your grades to …”), a page of its own (it can contact other sites, which learn the student’s address and when they use it), code tools with a network host (they can send what an app asks for there), unsigned (Dev), not reviewed, and Chrome only.
  • Code is a permission of its own. A mod with hooks or a slot file is listed as “Runs its author’s code”. An update that adds code to a mod that had none (a widget made of blocks) asks again, even with the same permissions, and a followed channel waits for the student’s review.
  • Removing a mod asks whether to remove its stored data too (on by default): what it saved with glaze.storage, its private-data mark, its navigation-layout switch and its stop note. Keep it, and a mod with the same id finds it again.

replaces

Any of bg, nav, effect:<moment> (complete submit grade streak timer.done look.rotate) or tile:<built-in> (notes agenda timer quotes music breathe buddy todo). Each appears as a switch under What it may replace on the mod’s card in the Mods tab. Switches are off by default; the student turns each on for that mod. Updates keep switches for keys still declared and leave new keys off.

  • bg needs ui.background, nav needs ui.nav, and tile:<id> needs a tile in ui.tiles with that same id. The mod’s UI then stands in for Glaze’s own.
  • nav: where Glaze’s bar is drawn, the mod’s nav slot takes its place (the rail, the top bar, or a phone’s tabs) in the room the bar keeps for the page; Glaze’s bar hides and the school’s own stays hidden. Turned off, Glaze’s bar is back. Without Glaze’s bar, it takes the place of the school’s own navigation. A replacement drawn from a tree may call glaze.nav.go(id) within a second of a click in its nav slot; to show the bar’s items it also declares nav.read.
  • effect:<moment> stops Glaze’s own effect for that moment, and the mod hears an effect event instead (not with motion off or the page hidden).
  • Two running mods with the same switch on: the one higher in the student’s order (Mods tab, Order) wins. A replacement without its matching UI slot does not compete.

settings

Glaze draws these in the Mods tab; glaze.settings() returns the student’s values. Each has id (as slot ids), type and label (one line, at most 60).

type Also Value
toggle default boolean, false by default
choice options (2 to 16 different, each at most 40), default one of options, the first by default
number min, max (required), step, default a number between them (on the step), min by default
text max (1 to 500, default 500), default a line of text, '' by default
color default #rrggbb (lowercase), #000000 by default

tools

Tools that agent apps the student connects in Settings → AI → Agents can call. They need the agents permission, and each appears on its own line in the install prompt; an update that adds a tool, or changes where one’s answers come from, asks again. Apps see a tool’s title as “ (mod): ” and its description after “Written by the mod’s author, not Glaze.” Each tool has:</p> <ul> <li><code>name</code>: <code>[a-z][a-z0-9_]</code>, at most 24 characters, unique in the mod.</li> <li><code>title</code>: one line, at most 60 characters.</li> <li><code>description</code>: one line, at most 500 characters, for the app’s model.</li> </ul> <p><strong>Declarative tools</strong> are answered by Glaze from what it has read, with none of the mod’s code, on every browser and with no school page open:</p> <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="json"><code><span class="line"><span style="color:#E1E4E8">{ </span><span style="color:#79B8FF">"name"</span><span style="color:#E1E4E8">: </span><span style="color:#9ECBFF">"due_soon"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">"title"</span><span style="color:#E1E4E8">: </span><span style="color:#9ECBFF">"Due soon"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">"description"</span><span style="color:#E1E4E8">: </span><span style="color:#9ECBFF">"Open to-dos due in the next week, soonest first."</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">"from"</span><span style="color:#E1E4E8">: </span><span style="color:#9ECBFF">"todo"</span><span style="color:#E1E4E8">,</span></span> <span class="line"><span style="color:#79B8FF"> "select"</span><span style="color:#E1E4E8">: [</span><span style="color:#9ECBFF">"title"</span><span style="color:#E1E4E8">, </span><span style="color:#9ECBFF">"course"</span><span style="color:#E1E4E8">, </span><span style="color:#9ECBFF">"due"</span><span style="color:#E1E4E8">, </span><span style="color:#9ECBFF">"url"</span><span style="color:#E1E4E8">], </span><span style="color:#79B8FF">"where"</span><span style="color:#E1E4E8">: [{ </span><span style="color:#79B8FF">"field"</span><span style="color:#E1E4E8">: </span><span style="color:#9ECBFF">"done"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">"eq"</span><span style="color:#E1E4E8">: </span><span style="color:#79B8FF">false</span><span style="color:#E1E4E8"> }, { </span><span style="color:#79B8FF">"field"</span><span style="color:#E1E4E8">: </span><span style="color:#9ECBFF">"due"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">"days"</span><span style="color:#E1E4E8">: </span><span style="color:#79B8FF">7</span><span style="color:#E1E4E8"> }],</span></span> <span class="line"><span style="color:#79B8FF"> "sort"</span><span style="color:#E1E4E8">: { </span><span style="color:#79B8FF">"field"</span><span style="color:#E1E4E8">: </span><span style="color:#9ECBFF">"due"</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">"order"</span><span style="color:#E1E4E8">: </span><span style="color:#9ECBFF">"asc"</span><span style="color:#E1E4E8"> }, </span><span style="color:#79B8FF">"limit"</span><span style="color:#E1E4E8">: </span><span style="color:#79B8FF">20</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">"input"</span><span style="color:#E1E4E8">: { </span><span style="color:#79B8FF">"course"</span><span style="color:#E1E4E8">: </span><span style="color:#79B8FF">true</span><span style="color:#E1E4E8"> } }</span></span></code></pre> <table> <thead> <tr> <th>Key</th> <th></th> </tr> </thead> <tbody> <tr> <td><code>from</code></td> <td>Required. <code>todo</code> (every to-do), <code>schedule</code> (to-dos with a due date), <code>courses</code> or <code>grades</code>: the fields of <code>glaze.todo()</code>, <code>glaze.courses()</code> or <code>glaze.grades()</code>. Needs that permission (<code>todo</code> for both plans).</td> </tr> <tr> <td><code>select</code></td> <td>The fields each answer has, in that order; all of them when left out.</td> </tr> <tr> <td><code>where</code></td> <td>At most 8 tests, all of which an item passes: <code>{ field, eq }</code>, that value exactly (<code>null</code> for no date, grade or colour), or <code>{ field, days }</code> on <code>due</code> or <code>at</code>, within that many days from now (-366 to 366, not 0; negative looks back).</td> </tr> <tr> <td><code>sort</code></td> <td><code>{ field, order }</code>, <code>asc</code> or <code>desc</code>. Empty values go last; ties keep the source’s order.</td> </tr> <tr> <td><code>limit</code></td> <td>1 to 200 items; 200 when left out.</td> </tr> <tr> <td><code>input</code></td> <td>What the app may pass: <code>"course": true</code>, one course’s items by its id; <code>"days": true</code>, 1 to 60 days from now (ahead for due dates, back for when Glaze read a grade; not for <code>courses</code>).</td> </tr> </tbody> </table> <p><strong>Code tools</strong>, <code>{ name, title, description, code: true, input }</code>, are answered by the mod’s Worker, so they need <code>hooks</code>, and run in Chrome while a school page is open. <code>input</code> is the arguments’ JSON Schema: an object at the root, in the subset <code>ai/schema.js</code> checks, with no <code>reason</code> property; none when left out. The student approves each call in Glaze, which then hands it to the mod on an open page of that school, signed in as the account the app asked about. The Worker answers with <code>glaze.tools.handle</code>:</p> <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#E1E4E8">glaze.tools.</span><span style="color:#B392F0">handle</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">'open_count'</span><span style="color:#E1E4E8">, </span><span style="color:#F97583">async</span><span style="color:#E1E4E8"> () </span><span style="color:#F97583">=></span><span style="color:#E1E4E8"> ({ open: (</span><span style="color:#F97583">await</span><span style="color:#E1E4E8"> glaze.</span><span style="color:#B392F0">todo</span><span style="color:#E1E4E8">()).</span><span style="color:#B392F0">filter</span><span style="color:#E1E4E8">((</span><span style="color:#FFAB70">i</span><span style="color:#E1E4E8">) </span><span style="color:#F97583">=></span><span style="color:#F97583"> !</span><span style="color:#E1E4E8">i.done </span><span style="color:#F97583">&&</span><span style="color:#F97583"> !</span><span style="color:#E1E4E8">i.submitted).</span><span style="color:#79B8FF">length</span><span style="color:#E1E4E8"> }));</span></span></code></pre> <p>The answer is accepted only while that tab is still signed in as the requested account. Cancelling before dispatch stops the call; once dispatched, it runs to its answer or the 15 s timeout. Each broker write takes its own serialized turn.</p> <h3 id="look-parts">Look parts</h3> <p><code>parts</code> holds the same data as a theme code’s parts, cleaned by <code>looks/lookparts.js</code>, which has every field and limit. An installed mod’s <code>parts</code> apply while it is on (and not blocklisted; a development copy only while development mode is on), on every browser: a mod with only <code>parts</code> and no code is a whole mod, and a code mod’s parts apply in Firefox and Safari too, where its code can’t run. They go where a Look’s parts go, including live course tabs, never on quiz or tool pages. The student’s Look is the base, or on a course that wears a Look of its own, that Look; each mod’s parts lay over it in the student’s mod order: the first mod to set a key (<code>bg</code>, <code>anim</code>, <code>fx</code>, <code>cursor</code>, <code>pointer</code>, <code>type</code>, <code>nav</code>) wins it whole, and <code>rules</code> add up, the Look’s first, to 64 in all. A mod’s background is drawn whatever kind of background the student chose. <code>glaze.look.override()</code> layers from running code go on top of all of these. Turning the mod off, removing it or reordering applies at once:</p> <table> <thead> <tr> <th>Key</th> <th>What</th> </tr> </thead> <tbody> <tr> <td><code>bg.shader</code></td> <td><code>{ src }</code>: a fragment shader in GLSL ES 1.00, ASCII, at most 8 KiB, written as <code>vec4 scene(vec2 uv)</code> (<code>uv</code> 0 to 1, y up; rgb is the colour, a how much covers the ground). Uniforms <code>uTime</code> <code>uAspect</code> <code>uPx</code> <code>uAmount</code> <code>uGround</code> <code>uC1</code> <code>uC2</code> <code>uC3</code>, helpers <code>hash</code> <code>noise</code> <code>fbm</code> <code>amt</code> <code>rot</code> <code>px</code>. Checked by <code>looks/glsl.js</code> before anything draws.</td> </tr> <tr> <td><code>bg.layers</code></td> <td>1 to 4 layers, bottom first: <code>scene</code>, <code>noise</code>, <code>gradient</code> or <code>particles</code>.</td> </tr> <tr> <td><code>bg.media</code></td> <td><code>{ type, src, fit?, dim?, loop? }</code>: a looping <code>video</code>, an animated <code>image</code> (WebP or AVIF) or a <code>lottie</code> animation. <code>src</code> is an <code>https:</code> address (the install prompt names its host), or <code>./<path></code>, a file in the bundle: <code>.webm</code> or <code>.mp4</code> for a video, <code>.webp</code> or <code>.avif</code> for a picture, <code>.json</code> for Lottie. The file must be what <code>type</code> says and within a Look background’s limits (video 12 MiB, picture 6 MiB, Lottie 1 MiB); it also shares the bundle’s 2 MiB with every other file, so in practice a bundled background is a Lottie animation, an animated WebP or AVIF, or a short clip. Otherwise the bundle is refused, as it is for a <code>file:</code> source; the file is checked again each time a page or the editor’s preview asks for it. A video file may be in a bundle only as this. The gallery takes only <code>./</code> files.</td> </tr> <tr> <td><code>anim</code></td> <td>Keyframes for <code>page.enter</code> <code>panel.enter</code> <code>card.enter</code> <code>tile.enter</code> <code>rail.open</code> <code>tooltip.in</code> <code>card.hover</code> <code>button.press</code>.</td> </tr> <tr> <td><code>fx</code></td> <td>Effects for <code>complete</code> <code>submit</code> <code>grade</code> <code>streak</code> <code>timer.done</code> <code>look.rotate</code>.</td> </tr> <tr> <td><code>cursor</code></td> <td>The pointer’s animation, drawn around the system pointer: <code>trail</code>, <code>sparkle</code>, <code>ripple</code>, <code>glow</code>, <code>flicker</code>, <code>orbit</code>, <code>scan</code> or <code>drift</code>, with <code>shape</code> for the marks <code>orbit</code>, <code>drift</code> and <code>sparkle</code> use.</td> </tr> <tr> <td><code>pointer</code></td> <td>The pointer set, by name: <code>aqua</code> <code>lilac</code> <code>pearl</code> <code>aurora</code> <code>quill</code> <code>terminal</code> <code>lava</code> <code>neon</code> <code>clear</code> <code>lagoon</code> <code>rose</code> <code>ghost</code> <code>pumpkin</code>, or <code>own</code> (the student’s own picture, which never travels in a code).</td> </tr> <tr> <td><code>type</code></td> <td>A typing effect at the caret: <code>embers</code>, <code>ink</code>, <code>sparks</code>, <code>pixels</code>, <code>petals</code>, <code>snow</code>, <code>bubbles</code> or <code>wisps</code>, with <code>c</code>, <code>size</code> and <code>count</code> (per key). Never in password, card or one-time-code fields, never while composing, never on quiz or tool pages; it never reads what is typed.</td> </tr> <tr> <td><code>nav</code></td> <td>A nav layout, below.</td> </tr> <tr> <td><code>rules</code></td> <td>At most 64 rules on named page parts, below.</td> </tr> </tbody> </table> <p>Colours are a palette token or <code>#rrggbb</code>. A shader or layers background draws when the worn Look’s background is set to Custom shader or Layers. The editor’s builders produce the same data.</p> <h2 id="dev-mode">Dev mode</h2> <p>In the editor’s <strong>Mods</strong> tab, <strong>Mod development</strong>:</p> <ol> <li>Turn on <strong>Dev mode</strong>. Without it, an unsigned mod can’t be installed or run. Turning it off stops Dev copies; turning it back on restores their saved on/off state.</li> <li><strong>Load mod folder…</strong> (Chrome) reads the folder and shows the install prompt. The mod is installed unsigned, marked <strong>Dev</strong>, “From a folder”. It needs an author key: <strong>Make author key</strong>, or put <code>author.key</code> in <code>mod.json</code>.</li> <li>After editing, press <strong>Reload</strong>. The folder is read again; if the mod asks for nothing new it updates quietly, and mods open on school pages restart without a page reload. Nothing watches the folder.</li> <li><strong>Export signed</strong> writes <code><name>.glazemod</code>, signed with your author key.</li> </ol> <p>A Dev copy never replaces a signed one, and a signed one can’t replace a Dev copy until you remove it. The folder is read without dot-files or a top-level <code>mod.sig</code>, with the same limits as a bundle. Open <a href="https://github.com/frostdev-ops/glaze/blob/main/examples/mods"><code>examples/mods</code></a> to see a folder.</p> <h2 id="signing-updates-and-sharing">Signing, updates and sharing</h2> <ul> <li><strong>Author key.</strong> An Ed25519 key kept in the browser. Glaze makes it the first time you need one; <strong>Back up key…</strong> saves it to a file locked with a passphrase, and without it you can’t update your mods. Signing needs a browser with WebCrypto Ed25519.</li> <li><strong>Identity.</strong> <code>mod.sig</code> is an Ed25519 signature over the bundle’s files. A mod’s id comes from the author key and the normalized name, so keep the same key and name for updates.</li> <li><strong>Signed updates.</strong> An update has the same id, a higher version and the same signing key; Glaze pins the key at the first install. If it asks for no new permission (or a page of its own) it installs quietly, keeping what the student granted; otherwise the student is asked again. A lower or equal version, a different key, and the same version with different files are refused.</li> <li><strong>Getting it to students.</strong> A <code>.glazemod</code> file, a <code>glazemod1:</code> code, the gallery or a channel link, below.</li> <li><strong>Blocklist.</strong> A mod Glaze has blocked can’t be installed or turned on.</li> </ul> <h3 id="mod-channels">Mod channels</h3> <ul> <li><strong>Author.</strong> Load the folder in <strong>Mods → Mod development</strong>, then <strong>Publish to a channel</strong>. Glaze signs it with your author key and copies the read link. For each update, keep the same name and key, raise <code>version</code>, <strong>Reload</strong>, then publish again. <strong>Copy channel link</strong> copies the same channel’s link later.</li> <li><strong>Student.</strong> Paste the link in <strong>Mods → Add a mod → Mod code</strong>, press <strong>Read code</strong>, review the prompt and install. Installing from the link follows that channel. Its card has <strong>Check now</strong>, <strong>Review update</strong> when more access is requested, and <strong>Stop following</strong>, which keeps the installed copy.</li> <li><strong>Checks.</strong> Opening the editor checks enabled followed mods. Loading code mods on a school page also checks, at most once a day per followed mod; there is no background daily timer. <strong>Check now</strong> also works for a disabled copy. A signed newer version asking for no new access updates quietly; otherwise it waits for review. Failed checks keep the installed copy. Every bundle’s author signature, pinned key, version and blocklist are checked.</li> <li><strong>Relay.</strong> A new channel uses the author’s relay selected in <strong>Sharing → Relay</strong>. Existing channels keep their server. The install prompt and followed mod’s card show the link’s relay host, where Glaze checks for updates. Channel checks use no cookies or referrer and refuse redirects; they do not need a mod’s <code>network:<host></code> permission.</li> </ul> <h2 id="running-code">Running code</h2> <p>Two places, by what the mod asks for:</p> <table> <thead> <tr> <th></th> <th>Worker (<code>hooks</code>)</th> <th>Frame UI (a slot’s <code>file</code>)</th> </tr> </thead> <tbody> <tr> <td>Runs</td> <td><code>hooks.js</code>, once, at the top level. No modules: one classic script.</td> <td>The page’s <code><script src></code> files in order, at the top level.</td> </tr> <tr> <td>Has</td> <td>Timers, <code>OffscreenCanvas</code>, <code>requestAnimationFrame</code> (from Glaze), <code>glaze</code>. No DOM.</td> <td>Its own page: HTML, CSS, canvas, WebGL, <code>glaze</code>.</td> </tr> <tr> <td>UI</td> <td>Component trees and a canvas, drawn by Glaze.</td> <td>Fills its slot.</td> </tr> <tr> <td>Data permissions</td> <td>Yes.</td> <td>Never.</td> </tr> </tbody> </table> <ul> <li><strong>Frame pages.</strong> Scripts and stylesheets must be files of the mod, named by relative path. Inline <code><script></code> and any <code><link></code> that isn’t one of the mod’s stylesheets are removed; inline <code><style></code> works. Images and fonts use <code>data:</code> or <code>blob:</code> URLs; bundle paths are not rewritten. A frame is as tall as its slot: tiles 160 (<code>s</code>), 240 (<code>m</code>) or 360 (<code>l</code>) pixels, rail widgets 120.</li> <li><strong>Network and storage.</strong> <code>fetch</code>, XHR and WebSocket are blocked by the sandbox: use <code>glaze.fetch</code>. Top-page navigation, popups and browser storage are blocked. A frame UI that navigates away is stopped; Glaze still warns that a page of its own can contact other sites. <code>glaze.storage</code> is the mod’s storage.</li> <li><strong>When it runs.</strong> In the top frame of Canvas, Blackboard Ultra and Moodle pages Glaze is on, never on a quiz or a tool’s page; and, for a mod granted <code>documents</code>, its Worker on the Documents page in a tab of its own. It stops when the page goes, the mod is turned off or revoked, or Glaze is turned off.</li> <li><strong>When it is stopped.</strong> A Worker that doesn’t answer the heartbeat (every 2 s) for 5 s, a frame that holds the page for 2 s or more, more than 240 messages from the mod in a second, a frame that navigates away, and an error that is thrown and not caught in a Worker (including one thrown inside a handler or a <code>decorate</code> or <code>items</code> function; a rejected promise doesn’t count). It stays off on that page until the page is reloaded or the student turns the mod off and on; the Mods tab says why.</li> </ul> <h2 id="the-glaze-object">The <code>glaze</code> object</h2> <p>Data reads and broker calls return promises; listeners, <code>cards.decorate</code>, <code>nav.items</code> and <code>ui.commit</code> return nothing. A refused call rejects with an <code>Error</code> whose message is a code: <code>permission</code> (not declared and granted, or a frame asking for personal data), <code>args</code> (wrong arguments or a value Glaze refuses), <code>size</code>, <code>quota</code>, <code>busy</code> (64 calls already waiting), <code>slot</code>, <code>tree</code>, <code>image</code>, <code>method</code>, <code>header</code>, <code>redirect</code>, <code>timeout</code>, <code>network</code>, <code>blocked</code>, <code>mod</code> (not runnable), <code>call</code> (unknown call), <code>write</code>, <code>cancelled</code> or <code>failed</code>.</p> <p>Where a row says Worker, a frame UI can’t use it (personal data goes to Workers only).</p> <table> <thead> <tr> <th>Call</th> <th>Does</th> <th>Needs</th> </tr> </thead> <tbody> <tr> <td><code>glaze.on(event, fn)</code> <code>glaze.off(event, fn)</code></td> <td>Listen for an event, below.</td> <td></td> </tr> <tr> <td><code>glaze.call(name, ...args)</code></td> <td>The raw call behind the rest, by the name Glaze checks (<code>'storage.get'</code>). Prefer the methods.</td> <td></td> </tr> <tr> <td><code>glaze.storage.get(key?)</code></td> <td>One value (<code>null</code> if unset), or with no key everything stored.</td> <td></td> </tr> <tr> <td><code>glaze.storage.set(key, value)</code></td> <td>Keeps a JSON value (not <code>undefined</code>). 1 MiB per mod, device only; key 1 to 256 characters.</td> <td></td> </tr> <tr> <td><code>glaze.storage.remove(key)</code></td> <td>Removes it.</td> <td></td> </tr> <tr> <td><code>glaze.theme()</code></td> <td><code>{ tokens: { accent: '#17c8f4', ... }, dark, motion: 'off' | 'subtle' | 'expressive' }</code>. The <code>tokens</code> are the palette Glaze wears.</td> <td></td> </tr> <tr> <td><code>glaze.settings()</code></td> <td><code>{ [setting id]: value }</code>, with defaults.</td> <td></td> </tr> <tr> <td><code>glaze.courses()</code></td> <td><code>[{ id, name, code, color }]</code>, the courses Glaze has seen on this site. Worker.</td> <td><code>courses</code></td> </tr> <tr> <td><code>glaze.todo()</code></td> <td><code>[{ id, type, courseId, course, title, due, url, done, submitted, graded, late, missing }]</code>, the cached plan of the account signed in on this page; <code>due</code> is ms since 1970 or null; planner notes’ text isn’t included. Worker.</td> <td><code>todo</code></td> </tr> <tr> <td><code>glaze.schedule(from, to)</code></td> <td>Cached due items in <code>[from, to]</code>, including both ends, with the same fields and cleaning as <code>todo</code>. Both arguments are non-negative safe integer ms since 1970, <code>from <= to</code>, at most 60 days apart; at most 500 results in cache order. Undated items are omitted. Uses only the plan Glaze has already read: no fetch for missing days, no class timetable. Worker.</td> <td><code>todo</code></td> </tr> <tr> <td><code>glaze.grades(courseId?)</code></td> <td><code>[{ courseId, name, percent, at }]</code>, each course’s latest grade from Insights for the account signed in on this page, <code>[]</code> until Insights has run or while that account is unknown. Worker.</td> <td><code>grades</code></td> </tr> <tr> <td><code>glaze.fetch(url, init?)</code></td> <td><code>{ status, ok, headers, text }</code>. <code>https</code> on port 443, <code>GET</code> or <code>POST</code> (<code>init.body</code> a string), request headers <code>accept</code> <code>accept-language</code> <code>content-language</code> <code>content-type</code> <code>authorization</code>. No cookies, no referrer, redirects refused, 15 s, 2 MiB back as text; of the response headers only <code>content-type</code> <code>content-length</code> <code>etag</code> <code>last-modified</code> <code>date</code> <code>cache-control</code>.</td> <td><code>network:<host></code></td> </tr> <tr> <td><code>glaze.ui.render(slot, tree)</code></td> <td>Draws a component tree in a slot of the manifest that has no <code>file</code>; <code>null</code> clears it.</td> <td></td> </tr> <tr> <td><code>glaze.ui.canvas(slot)</code></td> <td>The slot’s <code>canvas</code> component as an <code>OffscreenCanvas</code>. Worker.</td> <td></td> </tr> <tr> <td><code>glaze.ui.commit(slot)</code></td> <td>Sends the canvas to the page now. Worker.</td> <td></td> </tr> <tr> <td><code>glaze.cards.decorate(fn)</code></td> <td><code>fn(courses)</code> gets <code>[{ id, name }]</code> for the cards on the page and returns <code>{ [courseId]: { badge, accent, note } }</code> (or a promise of it; <code>{}</code> clears). Applied on the next pass. Worker.</td> <td><code>courses</code></td> </tr> <tr> <td><code>glaze.nav.items(fn)</code></td> <td><code>fn(items)</code> gets <code>[{ id, label }]</code>, the page’s own items shown in Glaze’s bar (or the older rail), each with Glaze’s English name for it (<code>course</code> is <code>Courses</code>), and returns a nav layout to stand in for the student’s own, or nothing. The first mod in the student’s order to give one wins. Returning a layout needs <code>nav.layout</code>; returning nothing needs no permission. Glaze refusing the layout stops the mod, as an error thrown in <code>fn</code> would.</td> <td><code>nav.layout</code> for a layout</td> </tr> <tr> <td><code>glaze.nav.model()</code></td> <td>Glaze’s bar: <code>{ place, items: [{ id, label, icon, badge, active, group }], groups: [{ label, items: [id] }], course: { name, items } | null, active }</code>, hidden items left out, no addresses, at most 64 items; <code>null</code> where the bar isn’t drawn. Worker.</td> <td><code>nav.read</code></td> </tr> <tr> <td><code>glaze.nav.add(item)</code></td> <td>One of the mod’s own items in the bar: <code>{ id, label, icon?, href | action, badge?, group | slot }</code>. <code>id</code> as slot ids; <code>label</code> one line of at most 40, and not the name of Glaze’s own settings or sign-out items in any of Glaze’s languages, compared without case, spaces or punctuation (<code>Glaze settings</code>, <code>Sign out</code>, <code>Log out</code>, <code>Abmelden</code>, …; refused with <code>args</code>); <code>icon</code> one of the bar’s except <code>glaze</code> and <code>signout</code>, which only Glaze’s own items wear (else the link icon); <code>href</code> a page of the school’s site this page is on, nothing else; <code>action: true</code> sends <code>nav.action</code> on a click instead; <code>badge</code> a number or at most 4 characters; <code>group</code> a group’s label or place (0 to 7), or <code>slot</code> <code>top</code> or <code>bottom</code>. At most 8; the same <code>id</code> replaces. They show with the mod’s name and go when it stops.</td> <td><code>nav.items</code></td> </tr> <tr> <td><code>glaze.nav.update(id, patch)</code></td> <td>Changes one of its own items; the patch has the same keys, without <code>id</code>.</td> <td><code>nav.items</code></td> </tr> <tr> <td><code>glaze.nav.remove(id)</code></td> <td>Removes one of its own items.</td> <td><code>nav.items</code></td> </tr> <tr> <td><code>glaze.nav.layout(patch)</code></td> <td>A nav layout proposed over the student’s while the mod runs, never saved; <code>null</code> withdraws it. Its links must be pages of the school’s site, below. <code>place</code> <code>left</code> or <code>top</code> moves the bar. The student’s own choices win where they made them, as with a worn Look; the first mod in the student’s order wins. The bar says “Arranged by” the mod with <strong>Use my own</strong>, which keeps that mod’s layouts off until the student lets it again in <strong>Settings → Navigation → Navigation items</strong>.</td> <td><code>nav.layout</code></td> </tr> <tr> <td><code>glaze.nav.go(id)</code></td> <td>Opens a bar item (or its panel) as a click on it would. Only for the mod whose <code>nav</code> replacement is on, in its Worker, within a second of a click in its tree-drawn <code>nav</code> slot. One click allows one call. Destinations must be on the current school’s origin; the student’s and worn Looks’ off-site HTTPS links still work when clicked directly.</td> <td></td> </tr> <tr> <td><code>glaze.palette.commands(list)</code></td> <td><code>[{ id, title, hint?, run }]</code> for Ctrl+K, at most 16; <code>run()</code> is called here when the student picks it.</td> <td></td> </tr> <tr> <td><code>glaze.rules.set(rules)</code></td> <td>Page rules, below; <code>[]</code> clears.</td> <td></td> </tr> <tr> <td><code>glaze.effects.play(kind, options?)</code></td> <td>A particle effect: <code>kind</code> is <code>burst</code>, <code>confetti</code>, <code>rain</code>, <code>ring</code>, <code>sprite</code> or <code>contour</code> (up to 4 nested rings stepping out to <code>size</code>, traced round <code>spread</code> degrees and lifted by -<code>gravity</code> × 4 px, then its <code>shapes</code> round the rim). Options: <code>count</code> 1 to 60, <code>shapes</code> (up to 4 of <code>dot</code> <code>star</code> <code>snow</code> <code>heart</code> <code>leaf</code> <code>spark</code>), <code>c</code> (up to 6 colours), <code>spread</code> 0 to 360, <code>gravity</code> -2 to 2, <code>life</code> 200 to 2500 ms, <code>size</code> 2 to 48, <code>x</code> and <code>y</code> 0 to 1 (fractions of the window; 0.5 and 0.33 by default). One a mod every 200 ms; none with motion off or the page hidden.</td> <td></td> </tr> <tr> <td><code>glaze.look.override(parts)</code></td> <td>Look parts laid over the student’s Look while the mod runs, never saved; <code>null</code> removes them. The first mod in the student’s order to give a part wins it; <code>rules</code> add up. Media <code>src</code> and <code>type</code> must exactly match <code>parts.bg.media</code> in the installed manifest; code can change its fit, dim and loop controls. A <code>nav</code> is a nav layout from code, as <code>glaze.nav.layout()</code>’s, and needs <code>nav.layout</code>. Use <code>glaze.fetch</code> for network requests.</td> <td><code>nav.layout</code> for a <code>nav</code></td> </tr> <tr> <td><code>glaze.broadcast(data)</code></td> <td>To this mod’s other Worker and frames on the page, as a <code>broadcast</code> event; not back to the sender. At most 64 KiB.</td> <td></td> </tr> <tr> <td><code>glaze.tools.handle(name, fn)</code></td> <td>Answers an agent app’s calls to the code tool <code>name</code> in mod.json: <code>fn(args)</code> returns JSON, or a promise of it, within 15 s; what it throws is the call’s error. A name mod.json doesn’t declare as a code tool throws. Worker.</td> <td><code>agents</code></td> </tr> <tr> <td><code>glaze.documents.list()</code></td> <td><code>[{ key, kind, title, format, words, updated, course }]</code>: every document the page lists (none in its Trash), newest first, its title as shown, <code>updated</code> in ms since 1970, <code>course</code> <code>''</code> for none. Never its text. Documents page, Worker.</td> <td><code>documents</code></td> </tr> <tr> <td><code>glaze.documents.open(key)</code></td> <td>Opens a document in this tab, restoring it first if it is in Trash. Only within a second of the student’s click on one of the mod’s own items; one click allows one call, and any other rejects with <code>permission</code>.</td> <td><code>documents</code></td> </tr> <tr> <td><code>glaze.documents.create({ format })</code></td> <td>Starts a new document in this tab: <code>format</code> <code>plain</code> (Blank, the default), <code>mla9</code>, <code>apa7</code> or <code>chicago17</code>. As <code>open</code>, after a click.</td> <td><code>documents</code></td> </tr> <tr> <td><code>glaze.documents.read(key)</code></td> <td><code>{ key, title, text }</code>: a listed document’s text, a line a paragraph.</td> <td><code>documents.read</code></td> </tr> <tr> <td><code>glaze.documents.export(key)</code></td> <td><code>{ name, mime, bytes }</code>: a listed document as the file its kind saves (<code>Lastname_Title.docx</code>), <code>bytes</code> a <code>Uint8Array</code>.</td> <td><code>documents.read</code></td> </tr> <tr> <td><code>glaze.documents.add(slot, { id, label })</code></td> <td>One of the mod’s own items: <code>slot</code> <code>documents.toolbar</code> (a button in the toolbar) or <code>documents.card</code> (an entry in every card’s ⋯ menu, after Glaze’s own). <code>id</code> as slot ids, <code>label</code> one line of at most 40. At most 4 a slot; the same <code>id</code> replaces. They show with the mod’s name and go when it stops; a click sends <code>documents.action</code>.</td> <td><code>documents</code></td> </tr> <tr> <td><code>glaze.documents.remove(slot, id)</code></td> <td>Removes one of its own items.</td> <td><code>documents</code></td> </tr> <tr> <td><code>glaze.documents.style(hooks)</code></td> <td>The page’s hooks while the mod runs, never saved; <code>null</code> withdraws them: <code>radius</code> (0 to 32 px), <code>glass</code> (the blur, 0 to 40 px), <code>thumb</code> (the thumbnails’ scale, 0.6 to 1.6), <code>column</code> (the grid’s narrowest column, 160 to 400 px). The first mod in the student’s order to set one wins it.</td> <td><code>documents</code></td> </tr> </tbody> </table> <p><strong>Nav layout</strong> (<code>glaze.nav.items</code>, <code>glaze.nav.layout</code>, <code>glaze.look.override</code>, <code>parts.nav</code>): <code>{ place: 'left' | 'top' | 'bottom' | 'dock', groups: [{ label, items: [id] }] (up to 6), hidden: [id], links: [{ id, n, u, i }] (up to 8), icons: { id: icon } }</code>. Ids are the navigation’s own names (<code>course</code>, <code>calendar</code>, <code>grades</code>, …), <code>link:<id></code> for your own links (<code>id</code> is 12 characters of <code>a-z0-9</code>) or <code>w:clock</code>, <code>w:next</code>, <code>w:timer</code>, <code>w:pet</code>. Icons are <code>link</code> <code>book</code> <code>video</code> <code>chat</code> <code>doc</code> <code>calendar</code> <code>folder</code> <code>code</code> <code>star</code> <code>globe</code>. Unknown ids are dropped. In a layout from code (the first three), each link’s <code>u</code> must be an <code>http(s)</code> page of the school’s site the page is on, the same rule as <code>glaze.nav.add</code>’s <code>href</code>; a link anywhere else refuses the whole call with <code>args</code>, so none of that layout applies. Otherwise its address could carry what the mod read off the site without a network permission. A bundle’s static <code>parts.nav</code> carries no data of the student’s, so its links may go to other sites.</p> <p>Reserved item names also compare compatibility characters, accents, and common Cyrillic/Greek lookalikes of Latin letters (for example, <code>Glаze settings</code> with Cyrillic <code>а</code>). This comparison does not change the displayed label.</p> <p><strong>Rules</strong> (<code>glaze.rules.set</code>, <code>parts.rules</code>): <code>{ p, do, ... }</code> on a named part from <code>looks/parts.js</code> (<code>ultra.course-card.title</code>). <code>do</code> is <code>hide</code>, <code>show</code>, <code>move</code> (with <code>to</code>, the part to move beside, and <code>at</code>, <code>before</code> or <code>after</code>), <code>style</code> (with <code>st</code>: <code>bg</code> <code>fg</code> <code>bc</code> colours, <code>bw</code> 0 to 4, <code>r</code> 0 to 32, <code>p</code> and <code>g</code> 0 to 6, <code>sh</code> 0 to 3, <code>o</code> 0 to 100, <code>f</code> a font id) or <code>label</code> (with <code>t</code>, up to 60 characters). At most 64 with the Look’s.</p> <h2 id="events">Events</h2> <p><code>glaze.on(event, fn)</code>. The data events (<code>courses</code>, <code>todo</code>, <code>grade</code>, <code>complete</code>, <code>submit</code>, and the bar’s <code>nav.*</code> events but <code>nav.items</code> and <code>nav.action</code>) reach only mods granted the permission and carry little: ask the call.</p> <table> <thead> <tr> <th>Event</th> <th>When</th> <th>Data</th> </tr> </thead> <tbody> <tr> <td><code>stop</code></td> <td>Glaze is about to stop the mod.</td> <td></td> </tr> <tr> <td><code>page</code></td> <td>At start and when the address changes.</td> <td><code>{ site: 'ultra' | 'canvas' | 'moodle' | 'documents', kind: 'course' | 'courses' | 'dashboard' | 'grades' | 'calendar' | 'documents' | 'other', courseId }</code></td> </tr> <tr> <td><code>visible</code></td> <td>The page is shown or hidden.</td> <td>boolean</td> </tr> <tr> <td><code>theme</code></td> <td>Glaze’s colours or motion changed: ask <code>glaze.theme()</code>.</td> <td></td> </tr> <tr> <td><code>settings</code></td> <td>The student changed the mod’s settings: ask <code>glaze.settings()</code>.</td> <td><code>{}</code></td> </tr> <tr> <td><code>courses</code></td> <td>Glaze saw new courses (<code>courses</code>).</td> <td><code>{}</code></td> </tr> <tr> <td><code>todo</code></td> <td>The plan changed (<code>todo</code>).</td> <td><code>{}</code></td> </tr> <tr> <td><code>grade</code></td> <td>A grade came in (<code>grades</code>).</td> <td><code>{}</code></td> </tr> <tr> <td><code>complete</code> <code>submit</code></td> <td>Work was ticked off or handed in (<code>todo</code>).</td> <td><code>{}</code></td> </tr> <tr> <td><code>effect</code></td> <td>A moment the mod replaces happened.</td> <td><code>{ moment, x?, y? }</code>, x and y fractions of the window</td> </tr> <tr> <td><code>ui</code></td> <td>A button or input in a tree was used (a real click or change).</td> <td><code>{ slot, id, kind: 'click' | 'change', value? }</code></td> </tr> <tr> <td><code>broadcast</code></td> <td>Another part of this mod called <code>glaze.broadcast</code>.</td> <td>what it sent</td> </tr> <tr> <td><code>cards</code></td> <td>The cards on the page changed (<code>courses</code>); <code>cards.decorate</code> answers this.</td> <td><code>{ courses: [{ id, name }] }</code></td> </tr> <tr> <td><code>nav.items</code></td> <td>The navigation changed; <code>nav.items</code> answers this. Every mod hears it, so it carries only the page’s own items by id with Glaze’s English names: not what the student renamed or added, not the account item, Glaze’s own items or other mods’ items (<code>glaze.nav.model()</code> reads the bar as drawn, with <code>nav.read</code>).</td> <td><code>{ items: [{ id, label }] }</code></td> </tr> <tr> <td><code>nav.change</code></td> <td>Glaze’s bar changed (<code>nav.read</code>): ask <code>glaze.nav.model()</code>.</td> <td><code>{}</code></td> </tr> <tr> <td><code>nav.navigate</code></td> <td>The student used an item of the bar (<code>nav.read</code>).</td> <td><code>{ id }</code></td> </tr> <tr> <td><code>nav.expand</code> <code>nav.collapse</code></td> <td>The rail opened or closed (<code>nav.read</code>).</td> <td><code>{}</code></td> </tr> <tr> <td><code>nav.sheet</code></td> <td>A phone’s More sheet opened or closed (<code>nav.read</code>).</td> <td><code>{ open }</code></td> </tr> <tr> <td><code>nav.action</code></td> <td>The student clicked one of the mod’s own <code>action</code> items.</td> <td><code>{ id }</code></td> </tr> <tr> <td><code>documents.action</code></td> <td>The student clicked one of the mod’s own items on the Documents page (<code>documents</code>).</td> <td><code>{ slot, id, doc? }</code>: <code>doc</code>, the card’s summary as <code>list()</code> gives it, for a <code>documents.card</code> item</td> </tr> <tr> <td><code>documents.change</code></td> <td>The documents changed (<code>documents</code>): ask <code>glaze.documents.list()</code>.</td> <td><code>{}</code></td> </tr> <tr> <td><code>canvas.size</code></td> <td>Worker. A slot’s canvas has this size in device pixels.</td> <td><code>{ slot, w, h, dpr }</code></td> </tr> <tr> <td><code>canvas.pause</code></td> <td>Worker. Nothing of the mod’s canvases shows (page hidden, motion off, canvas not on the page); animation frames wait.</td> <td><code>{ paused }</code></td> </tr> <tr> <td><code>tool.call</code></td> <td>Worker. An agent app called one of the mod’s code tools; <code>tools.handle</code> answers this.</td> <td><code>{ id, name, args }</code></td> </tr> </tbody> </table> <h2 id="ui-slots-and-components">UI slots and components</h2> <p>A slot is <code>tile:<id></code> (a tile on the student’s widget boards), <code>rail:<id></code> (a widget in Glaze’s navigation rail), <code>nav</code> (with <code>replaces: ["nav"]</code>) or <code>background</code> (with <code>replaces: ["bg"]</code>), as <code>ui</code> in <code>mod.json</code> declares it.</p> <ul> <li>A slot <strong>with a <code>file</code></strong> is a frame UI and fills its slot.</li> <li>A slot <strong>without one</strong> is drawn by Glaze from a tree: <code>glaze.ui.render('tile:next-due', tree)</code>. Anything the tree breaks rejects the whole call with <code>tree</code>, and nothing is drawn.</li> <li>Colours: a palette token (<code>accent</code> <code>accent-hi</code> <code>accent-soft</code> <code>accent-ink</code> <code>surface</code> <code>surface-2</code> <code>ink</code> <code>ink-muted</code> <code>ink-faint</code> <code>line</code> <code>line-strong</code> <code>ok</code> <code>warn</code> <code>err</code>) or <code>#rrggbb</code>. Text has control and direction characters turned into spaces. A string over its limit refuses.</li> <li>At most 8 levels, 200 nodes, 50 children a node, one <code>canvas</code>. Ids (<code>a-z 0-9 -</code>, up to 32) are unique in a tree.</li> <li>A re-render keeps the focus and caret where the student had them.</li> </ul> <table> <thead> <tr> <th>Component</th> <th>Keys (<code>*</code> required)</th> </tr> </thead> <tbody> <tr> <td><code>stack</code></td> <td><code>children*</code>, <code>label</code>, <code>gap</code> 0 to 6, <code>align</code> <code>start</code> <code>center</code> <code>end</code> <code>stretch</code></td> </tr> <tr> <td><code>row</code></td> <td>as <code>stack</code>, and <code>wrap</code></td> </tr> <tr> <td><code>list</code></td> <td><code>children*</code>, <code>label</code>, <code>ordered</code></td> </tr> <tr> <td><code>text</code></td> <td><code>text*</code> (at most 500; line breaks kept), <code>size</code> <code>xs</code> <code>s</code> <code>m</code> <code>l</code> <code>xl</code>, <code>weight</code> <code>normal</code> <code>bold</code>, <code>color</code>, <code>muted</code></td> </tr> <tr> <td><code>number</code></td> <td><code>value*</code>, <code>label</code>, <code>unit</code> (at most 12), <code>digits</code> 0 to 4, <code>size</code>, <code>color</code></td> </tr> <tr> <td><code>ring</code></td> <td><code>value*</code>, <code>max</code> (100), <code>label</code>, <code>color</code></td> </tr> <tr> <td><code>progress</code></td> <td>as <code>ring</code>, a bar</td> </tr> <tr> <td><code>countdown</code></td> <td><code>to*</code> (ms since 1970), <code>label</code>, <code>done</code> (said after; at most 80)</td> </tr> <tr> <td><code>image</code></td> <td><code>src*</code> (a png, jpg/jpeg, gif, webp or avif of the mod, at most 4096 pixels a side), <code>alt*</code> (<code>''</code> for a decoration), <code>w</code>, <code>h</code> (1 to 2000), <code>fit</code> <code>contain</code> <code>cover</code></td> </tr> <tr> <td><code>button</code></td> <td><code>id*</code>, <code>label*</code> (at most 60), <code>tone</code> <code>primary</code> <code>plain</code>, <code>disabled</code></td> </tr> <tr> <td><code>input</code></td> <td><code>id*</code>, <code>kind*</code>, <code>label*</code>, <code>disabled</code>, then by <code>kind</code>: <code>text</code> (<code>value</code>, <code>maxLength</code>, <code>placeholder</code>), <code>number</code> (<code>value</code>, <code>min</code>, <code>max</code>, <code>step</code>), <code>toggle</code> (<code>value</code>), <code>select</code> (<code>options*</code> up to 32 different, <code>value</code>)</td> </tr> <tr> <td><code>canvas</code></td> <td><code>h</code> 24 to 800 CSS pixels, <code>label</code></td> </tr> </tbody> </table> <p><strong>Canvas.</strong> Render a tree with a <code>canvas</code>, then <code>const c = await glaze.ui.canvas(slot)</code> and draw with <code>requestAnimationFrame</code>. The canvas has the slot’s width in device pixels (at most 2 a CSS pixel and 4096 a side) and Glaze resizes it as the slot changes. Its picture goes to the page after each animation frame in which the mod drew on it (any call or assignment on the canvas’s context counts; a context taken from <code>OffscreenCanvas.prototype</code> directly isn’t seen, so call <code>glaze.ui.commit</code> after drawing with one), or on <code>glaze.ui.commit</code>, at most 60 a second. Frames stop while <code>canvas.pause</code> says so. Nothing animates with motion off.</p> <h2 id="the-documents-page">The Documents page</h2> <p>Glaze Writer’s Documents page, in a tab of its own (the popup’s Documents, or Settings → Writer’s Documents link), runs the Worker of each mod granted <code>documents</code>, as a school page runs mods, and nothing of the others. Documents opened as a page of a school’s site (Ctrl+K, the navigation’s Documents) and a document opened from the list run no mods. There a mod has <code>glaze.storage</code>, <code>glaze.theme()</code>, <code>glaze.settings()</code>, <code>glaze.broadcast()</code> and <code>glaze.documents</code>; any other call rejects with <code>call</code>, as <code>glaze.documents</code> does on a school page. Its <code>page</code> event says <code>{ site: 'documents', kind: 'documents', courseId: null }</code>. A key is a random opaque handle, <code>document:<uuid></code>, scoped to this mod on this page, without the school host or user id in the internal storage key. It comes from <code>glaze.documents.list()</code> or <code>documents.action</code>; do not persist it across page loads or mod restarts. The document must still be listed; any other key rejects with <code>args</code>.</p> <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="js"><code><span class="line"><span style="color:#E1E4E8">glaze.documents.</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">'documents.card'</span><span style="color:#E1E4E8">, { id: </span><span style="color:#9ECBFF">'count'</span><span style="color:#E1E4E8">, label: </span><span style="color:#9ECBFF">'Count sentences'</span><span style="color:#E1E4E8"> });</span></span> <span class="line"><span style="color:#E1E4E8">glaze.</span><span style="color:#B392F0">on</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">'documents.action'</span><span style="color:#E1E4E8">, </span><span style="color:#F97583">async</span><span style="color:#E1E4E8"> ({ </span><span style="color:#FFAB70">id</span><span style="color:#E1E4E8">, </span><span style="color:#FFAB70">doc</span><span style="color:#E1E4E8"> }) </span><span style="color:#F97583">=></span><span style="color:#E1E4E8"> {</span></span> <span class="line"><span style="color:#F97583"> if</span><span style="color:#E1E4E8"> (id </span><span style="color:#F97583">!==</span><span style="color:#9ECBFF"> 'count'</span><span style="color:#E1E4E8">) </span><span style="color:#F97583">return</span><span style="color:#E1E4E8">;</span></span> <span class="line"><span style="color:#F97583"> const</span><span style="color:#E1E4E8"> { </span><span style="color:#79B8FF">text</span><span style="color:#E1E4E8"> } </span><span style="color:#F97583">=</span><span style="color:#F97583"> await</span><span style="color:#E1E4E8"> glaze.documents.</span><span style="color:#B392F0">read</span><span style="color:#E1E4E8">(doc.key); </span><span style="color:#6A737D">// documents.read</span></span> <span class="line"><span style="color:#F97583"> await</span><span style="color:#E1E4E8"> glaze.storage.</span><span style="color:#B392F0">set</span><span style="color:#E1E4E8">(doc.key, text.</span><span style="color:#B392F0">split</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">/</span><span style="color:#79B8FF">[.!?]</span><span style="color:#F97583">+</span><span style="color:#79B8FF">\s</span><span style="color:#9ECBFF">/</span><span style="color:#E1E4E8">).</span><span style="color:#79B8FF">length</span><span style="color:#E1E4E8">);</span></span> <span class="line"><span style="color:#E1E4E8">});</span></span></code></pre> <p>The page wears the student’s Look, background and glass included. These hooks restyle it, through <code>glaze.documents.style()</code> (a Look has no CSS of its own):</p> <table> <thead> <tr> <th>Property</th> <th>Default</th> <th></th> </tr> </thead> <tbody> <tr> <td><code>--gd-radius</code></td> <td>the Look’s corners</td> <td>The panels’, cards’ and menus’ corners (<code>radius</code>).</td> </tr> <tr> <td><code>--gd-glass</code></td> <td>the Look’s blur</td> <td>The blur behind the panels, cards and menus over a background (<code>glass</code>).</td> </tr> <tr> <td><code>--gd-thumb</code></td> <td><code>1</code></td> <td>The thumbnails’ scale (<code>thumb</code>).</td> </tr> <tr> <td><code>--gd-column</code></td> <td><code>224px</code></td> <td>The grid’s narrowest column (<code>column</code>).</td> </tr> <tr> <td><code>--gd-lift</code></td> <td>Glaze’s hover lift (<code>--gz-lift</code>: up 2px, 4px and 1% larger on Expressive, none with motion or hover effects off)</td> <td>A hovered card’s and New tile’s lift, a <code>transform</code>.</td> </tr> <tr> <td><code>--gd-panel</code></td> <td>the Look’s surface, opaque enough to read</td> <td>The panels’ and cards’ fill.</td> </tr> </tbody> </table> <p>The page’s parts keep these class names: <code>gd-top</code> (the heading and New), <code>gd-new</code>, <code>gd-tile</code>, <code>gd-bar</code> (the toolbar), <code>gd-search</code>, <code>gd-extra</code> (the toolbar’s added items), <code>gd-docs</code>, <code>gd-card</code>, <code>gd-pic</code>, <code>gd-title</code>, <code>gd-meta</code>, <code>gd-more</code>, <code>gd-menu</code> and <code>gd-added</code> (an added menu item).</p> <h2 id="limits">Limits</h2> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td>A bundle</td> <td>256 files, 2 MiB in all, 256 KiB of <code>.js</code>, <code>mod.json</code> 64 KiB</td> </tr> <tr> <td>A call</td> <td>arguments 1 MiB as JSON, an answer 4 MiB, 64 calls waiting</td> </tr> <tr> <td>Messages</td> <td>240 a second from a mod; over that the mod is stopped. Canvas pictures count against their own canvas, 240 a second each</td> </tr> <tr> <td><code>glaze.storage</code></td> <td>1 MiB per mod</td> </tr> <tr> <td><code>glaze.fetch</code></td> <td>15 s, 2 MiB back, no redirects</td> </tr> <tr> <td><code>courses</code>, <code>todo</code>, <code>schedule</code>, <code>grades</code></td> <td>at most 500 items; <code>schedule</code> spans at most 60 days</td> </tr> <tr> <td>A component tree</td> <td>8 levels, 200 nodes, 50 children a node, 500 characters of text, one canvas</td> </tr> <tr> <td>A canvas</td> <td>24 to 800 CSS pixels tall, at most 2 pixels per CSS pixel and 4096 a side, at most 60 pictures a second</td> </tr> <tr> <td><code>glaze.effects.play</code></td> <td>one a mod every 200 ms</td> </tr> <tr> <td><code>glaze.cards.decorate</code></td> <td>up to 200 courses; <code>badge</code> at most 12 characters, <code>note</code> at most 120</td> </tr> <tr> <td><code>glaze.palette.commands</code></td> <td>16</td> </tr> <tr> <td><code>glaze.nav.add</code></td> <td>8 items a mod; label 40, badge 4 characters</td> </tr> <tr> <td><code>glaze.broadcast</code></td> <td>64 KiB</td> </tr> <tr> <td><code>glaze.documents.add</code></td> <td>4 items a slot; label 40 characters</td> </tr> <tr> <td><code>tools</code></td> <td>8 a mod; a declarative tool’s answer at most 200 items; a code tool answers within 15 s, at most 1 MiB as JSON</td> </tr> <tr> <td>Hangs</td> <td>a Worker silent for 5 s, or a frame holding the page for 2 s, is stopped</td> </tr> </tbody> </table> <h2 id="examples">Examples</h2> <p>Each mod folder in <a href="https://github.com/frostdev-ops/glaze/blob/main/examples/mods"><code>examples/mods</code></a> loads with <strong>Load mod folder…</strong>.</p> <table> <thead> <tr> <th>Folder</th> <th>Shows</th> </tr> </thead> <tbody> <tr> <td><code>examples/mods/countdown-tile</code></td> <td>A tile drawn from a component tree: counts down to the next open due item (<code>todo</code>), with a setting.</td> </tr> <tr> <td><code>examples/mods/rail-widget</code></td> <td>A rail widget with a page of its own: HTML, CSS and a script that follows Glaze’s theme and keeps a count in <code>glaze.storage</code>.</td> </tr> <tr> <td><code>examples/mods/card-decorator</code></td> <td>A badge on each course card (<code>courses</code>).</td> </tr> <tr> <td><code>examples/mods/workload-tool</code></td> <td>A code tool for agent apps: how many open to-dos are due on each of the next days (<code>agents</code>, <code>todo</code>).</td> </tr> </tbody> </table> <p><a href="https://github.com/frostdev-ops/glaze/blob/main/examples/looks/shader-background"><code>examples/looks/shader-background</code></a> is a Look-parts example: paste its GLSL into <strong>Look → Background → Custom shader</strong>. It becomes part of the worn Look; <strong>Copy theme code</strong> shares it.</p> </div> <p class="guide-caption">Also on <a href="https://github.com/frostdev-ops/glaze/wiki/Mods-API">Glaze's GitHub wiki</a>.</p> </article> </div> <div class="guide-endcap"><p>Keep exploring.</p><a href="/guides">Find your next guide <span aria-hidden="true">→</span></a></div> </div> </main> <footer class="marketing-footer" data-astro-cid-c6rkp36v> <span data-astro-cid-c6rkp36v>© 2026 Frostdev</span> <nav aria-label="Footer navigation" data-astro-cid-c6rkp36v> <a href="https://github.com/frostdev-ops" data-astro-cid-c6rkp36v>GitHub</a> <a href="https://ko-fi.com/frostdev_ops" data-astro-cid-c6rkp36v>Support us on Ko-fi</a> <a href="/glaze/privacy" data-astro-cid-c6rkp36v>Glaze privacy</a> <a href="/glaze/terms" data-astro-cid-c6rkp36v>Terms</a> <a href="mailto:admin@frostdev.io" data-astro-cid-c6rkp36v>Contact</a> </nav> </footer> </div> </body> </html><script type="module" src="/_site/MarketingLayout.astro_astro_type_script_index_0_lang.DdkPM2su.js"></script><script type="module">var e=document.querySelector(`.guide-page`);if(e){let t=e.querySelector(`.guide-article`),n=[...e.querySelectorAll(`[data-guide-chapter]`)],r=n.map(e=>document.getElementById(e.dataset.guideChapter??``)),i=e.querySelector(`.guide-reading-progress`),a=i?.querySelector(`span`);if(t&&i&&a){i.hidden=!1;let e=!1,o=()=>{e=!1;let i=t.getBoundingClientRect(),o=Math.max(1,i.height-window.innerHeight);a.style.transform=`scaleX(${Math.min(1,Math.max(0,-i.top/o))})`;let s=0;r.forEach((e,t)=>{e&&e.getBoundingClientRect().top<=180&&(s=t)}),n.forEach((e,t)=>{t===s?e.setAttribute(`aria-current`,`location`):e.removeAttribute(`aria-current`)})},s=()=>{e||(e=!0,requestAnimationFrame(o))};window.addEventListener(`scroll`,s,{passive:!0}),window.addEventListener(`resize`,s,{passive:!0}),o()}}</script>