Ampify
English

The Ampify API

The reference for the Ampify object that extensions, apps and theme scripts use. To start, read Your first extension. The manifest format is in manifest.md. Coming from Spicetify? See what maps to what.

Each part is tagged [stable] (will not change without a new major API version) or [preview] (works, but can still change).

1. Principles

2. Processes

Apple Music runs as two processes. Ampify.process tells an element where it runs:

processes value Process What runs there
ui (default) AppleMusic.exe The interface: buttons, panels, pages, the player
engine AMPLibraryAgent.exe Sound: audio.*, MIDI, the local remote

The manifest’s processes picks one or both. An element in both runs twice; only one of them should write its storage.

3. Life cycle

  1. At start, Apple Music reads each folder of extensions, apps and themes in %USERPROFILE%\Ampify. A folder without manifest.json, or whose name starts with a dot, is ignored. An app in extensions (or the reverse) is refused.
  2. The manifest is checked: schema, id equal to the folder name, supported kitApi major version, declared files present. A failure gives the state Failed and a log line; the other elements go on.
  3. An element starts only if it is switched on (extensions.<id>.enabled, apps.<id>.enabled; community elements start off). A theme’s main.js runs while the theme is active and theme.parts.script is on.
  4. main is evaluated. An exception gives Failed without stopping the others.
  5. On stop, the functions given to Ampify.onStop run in reverse order.
  6. ampify can start, stop and restart an element without restarting Apple Music (see cli.md).

States: Off, Running, Failed, and Blocked (switched on, but Ampify is in safe mode or on an untested Apple Music version).

An app and an extension may share an id; they are then linked (section 5.8). Inside the kernel, the app is app:<id>.

3.1 Several files: ES modules [preview]

With "type": "module" in the manifest, main.js is an ES module and can import other files of its folder:

import { format } from "./lib/text.js";
import settings from "./settings.mjs";
Ampify.log(format(settings.title));

4. Permissions

A function whose permission is not declared throws PermissionDenied and does nothing.

Permission What it gives Status
(none) Ampify.log, onStop, config, uri, locale, i18n, icons, crypto, color, fonts, link, remote [stable] / [preview]
storage Ampify.storage, one JSON file per element [stable]
notifications Ampify.notify [stable]
player.read Player state, events, lyrics, queue, artwork, audio.volume [stable]
player.control Play, pause, next, previous, seek, shuffle, repeat, volume, queue changes [stable]
audio.analyze Spectrum, levels, tempo and loudness of the sound [preview]
audio.gain Ampify.audio.setGainDb, a gain on the samples [preview]
audio.eq A 10-band equalizer [preview]
audio.mix Ampify.automix: the current song mixed into the next one, in the audio process [preview]
audio.sing Ampify.audio.sing: the karaoke mode, from either process [preview]
ui.topbar, ui.playbar, ui.sidebar, ui.menu, ui.popup Buttons, sidebar entries, menu entries, dialogs [stable]
ui.panel, ui.window A side panel, a secondary window [preview]
ui.fullscreen A view over the whole window, and Apple’s own full-screen and mini players [stable]
ui.page App pages and navigation [stable]
ui.keyboard Global or window shortcuts [preview]
clipboard.write, clipboard.read Ampify.clipboard.copy and paste: text put on, and read from, the Windows clipboard [preview]
ipc.discord Discord presence (also needs the setting discord.enabled) [preview]
midi.input A MIDI controller (also needs midi.enabled) [preview]
ui.tray Entries in the Ampify notification-area icon (also needs tray.enabled) [preview]
fs.output A text file in output\<id>\ of the Ampify folder, and nowhere else [preview]
network:<host> Ampify.http to that host only, over https [stable]
library.read Ampify.library.tracks, the tracks of the library with their play counts [preview]
library.write, services.read Reserved names: a manifest that declares them loads, but no function uses them yet Reserved
kit.manage Ampify.kit.run, which runs ampify.exe. Only the Marketplace holds it; the catalog refuses it elsewhere Internal

Discord, the tray icon, the remote and MIDI are off until the user turns them on. Switching on an element that needs ipc.discord, ui.tray or midi.input turns on the matching service; switching it off leaves the service on.

fs.output writes .txt, .json, .csv, .html or .xml files (256 KB and 16 files at most) that another program can read, such as an OBS text source. The element cannot read them back or delete them.

5. The global Ampify object

Asynchronous functions return a Promise.

5.1 Base [stable]

Ampify.version              // Ampify's version
Ampify.kitApi               // "1.0": the API version
Ampify.process              // "ui" or "engine"
Ampify.log(message)         // writes to the log, prefixed with the element id
Ampify.onStop(fn)           // fn runs when the element stops
Ampify.locale               // the app locale, e.g. "en-US"
Ampify.appVersion           // Apple Music's version, e.g. "1.1792.23042.0", "" when unknown   [preview]
Ampify.activeTheme()        // the id of the theme in use, null for none; read it again, the user may change it

Texts in several languages [preview]:

Ampify.i18n.language                    // "de": the language Ampify shows, as two letters
Ampify.i18n.define({ en: { hello: "Hello {name}" }, de: { hello: "Hallo {name}" } })
Ampify.i18n.t("hello", { name: "Lea" }) // the text in that language, else English, else the key
Ampify.i18n.t("kit.tray.next")          // Ampify's own texts, prefix kit.

Ampify.i18n.language is one of en, fr, de, es, pt, ru, ja, zh, it, ko, or another code when Windows uses a language Ampify does not translate. It follows the Windows display language, or the language setting.

5.2 Settings and storage [stable]

Ampify.config.get(key, default)     // reads extensions.<id>.<key> (apps.<id>... for an app, themes.<id>... for a theme)
Ampify.config.set(key, value)       // writes it; an element only reaches its own keys
Ampify.storage.get(key, default)    // a JSON value in storage\<id>.json (1 MB), permission storage
Ampify.storage.set(key, value)
Ampify.storage.remove(key)
Ampify.storage.clear()              // every value of the element

For a setting declared in the manifest, config.get(key) without a default gives the manifest’s default, typed (a boolean for a toggle, a number for a number). A change in Ampify’s settings page restarts the extension.

5.3 Player [stable]

Ampify.player.state()
// -> { playing, positionMs, durationMs,
//      track: { id, title, artist, album, variantId, atmos, lossless, sampleRate, bitDepth, catalogId, contentRating,
//               queueItemId, artwork, artworkColor } | null,
//      source: "apple" | "smtc" | "" }
Ampify.player.on("trackchange" | "statechange" | "lyricschange" | "progress", fn)   // "songchange", "onplaypause" and "onprogress" are Spicetify's names (onplaypause also fires on a position jump)
Ampify.player.off(event, fn)   // removes a listener added with on
Ampify.player.lyrics()      // -> null | { source: "apple", synced, language,
//                                         lines: [{ start, end, text, words: [{ start, end, text }] }], text }
Ampify.player.artwork()     // -> Promise<null | { type: "image/jpeg" | "image/png", base64 }>   [preview]
Ampify.player.play()        // true when the app accepted the command
Ampify.player.pause()
Ampify.player.toggle()
Ampify.player.next()
Ampify.player.previous()
Ampify.player.seek(ms)
Ampify.player.shuffle()     // -> true | false | null        [preview] Apple's own shuffle and repeat buttons
Ampify.player.repeat()      // -> "off" | "all" | "one" | null     (permission player.read, interface process)
Ampify.player.setShuffle(on)        // true once the player is in that state    (permission player.control)
Ampify.player.setRepeat(mode)       // "off" | "all" | "one"
Ampify.player.toggleShuffle()       // flips shuffle
Ampify.player.toggleRepeat()        // off, all, one, off...
Ampify.player.setVolume(volume)     // 0 to 1: Apple's player volume, interface or audio process, [preview]
Ampify.player.setRate(rate)         // 0.5 to 2: Apple's player speed, kept across pauses and songs (1.6, player.control)
Ampify.player.rate()                // the speed in effect, 1 until one is set (player.read)
Ampify.player.skipForward(ms)       // seeks 15 s on (or ms), within the song; false without a track
Ampify.player.skipBack(ms)
Ampify.player.progress()            // 0 to 1, how far the song has gone; 0 while its length is unknown
Ampify.player.formatTime(ms)        // "3:07", "1:02:05"
Ampify.player.muted()               // -> true | false | null   [preview] (permission player.read)
Ampify.player.setMute(on)           // and toggleMute(): also player.control
Ampify.player.toggleMute()
Ampify.player.increaseVolume(step)  // a tenth of Apple's slider (or step, above 0 up to 1)
Ampify.player.decreaseVolume(step)
Ampify.player.queue.list()  // -> { available, complete, source, reason,
//                                   items: [{ id, title, artist, album, durationMs, section, catalogId, artwork }] }
Ampify.player.queue.add(catalogId, { position: "next" | "last" })  // [preview] answers false for now
Ampify.player.queue.remove(itemId)                                 // [preview]
Ampify.player.queue.move(itemId, beforeItemId)                     // [preview] the entry goes right before the other (1.6)

5.4 Audio [preview]

Sound is processed in AMPLibraryAgent.exe ("processes": ["engine"]), on Ampify’s audio hooks (src/win/audio/), which go in by themselves when the interface asks for the sound. The interface (AppleMusic.exe) reads what that process shares: onFrame, analyze(), loudness() and volume() work there too, about 100 ms behind. The gain and the equalizer stay in the engine: in the interface setGainDb answers 0, the equalizer false and eq.bands() is empty, without throwing.

Ampify.audio.setGainDb(db)          // gain on the samples, capped by audio.maxGainDb, back to 0 at stop
Ampify.audio.onFrame(fn)            // fn({ bands, rms, peak, time }), up to 20 times a second
Ampify.audio.analyze()              // -> { tempo, confidence, loudness: { momentary, shortTerm }, rms, peak, bands, frequencies }
Ampify.audio.loudness()             // -> { momentary, shortTerm } in LUFS, or null
Ampify.audio.volume()               // -> the player's gain, 0 to 1, or null (permission player.read)
Ampify.audio.eq.setBand(index, gainDb)   // 10 bands, 31 Hz to 16 kHz, +/- 12 dB
Ampify.audio.eq.preset(name)        // "flat", "rock", "jazz", "bass-booster"...
Ampify.audio.eq.reset()
Ampify.audio.eq.bands()             // -> [{ frequency, gainDb, q, type }]
Ampify.audio.eq.presets()           // -> preset names

Sing [preview]

Permission audio.sing. Sing turns the singer’s voice down, as Apple Music Sing does on the iPhone. The interface asks and the audio process does the work, so set and state work from both processes, through the block they share.

Ampify.audio.sing.set({ mode, voice, music, model })  // mode "off" | "light" | "studio", voice and music 0 to 1,
                                                      // model "standard" | "precise"; true once the request is written
Ampify.audio.sing.state()                // -> { available, mode, voice, music, model, phase, progress, delay, reason, installed, downloadSize }
Ampify.audio.sing.onChange(fn)           // fn(state) when the state moves (polled every 250 ms); returns the function that stops

AutoMix [preview]

While a mix is heard, Ampify shows it on Apple’s progress line, in the play bar and in the full-screen player, as Apple Music does on the iPhone: the part played glows and “Mixing” shows under the middle of the line, or in place of the artist line when the bar keeps the song’s display, a light passing over it (still when Windows’ animations are off).

Ampify.automix (permission audio.mix, audio process only) plays the end of the current song into the next one. Ampify starts a second player on the current song a few seconds ahead, delays its sound until it is Apple’s to the sample, lets it take the song over, moves Apple’s player to the next song at the plan’s start, then shapes both songs along the plan: volumes, bass, and the current song’s speed. The automix extension plans each mix from Apple’s analysis of the two songs (beats, bars, phrases, key, fades, loudness).

Ampify.automix.state()            // -> { available, playing, current, next, mix, features }
Ampify.automix.schedule(plan)     // -> { ok: true } or { ok: false, reason }
Ampify.automix.cancel(reason)
Ampify.automix.preferStereo(want) // -> true once the wish reached Apple's player, false in another process

5.5 Interface [stable]

An interface is a tree of nodes { type, ...attributes, children }, written directly or with Ampify.React (section 5.9). Ampify draws it with WinUI controls and, on each render, only changes the nodes that changed (matched by position or key). Each node gets the AutomationId AMPIFY_<element>_<node>. Limits: 8 levels, 300 nodes, 500 characters per text; attributes are plain values, except onClick and onChange, which take a function in a tree written by hand as in a React one.

Node Attributes
stack, row, list gap, children
grid columns (whole number, 1 to 12, 2 by default), gap (0 to 1000, as in the other containers), children: equal columns, the children filled row by row
tabs gap, children: tab nodes side by side
tab label, selected (the tab that is on, drawn in the accent colour), disabled, onClick; only in tabs
menu label, disabled, children: item nodes, opened as a flyout from the menu’s button; only item nodes
item label, disabled, onClick; only in menu; no icon in this version
layer children, stacked on top of each other
card title, subtitle, onClick, children
text text, variant (title, subtitle, body, caption) and the text style below
button label, icon (SVG), disabled, variant (primary, secondary, tertiary), onClick
toggle label, checked, disabled, onChange
checkbox label, checked, disabled, onChange (true or false): Apple’s check box
slider label, min, max, step, value, unit (text after the value shown in the header, " %"), disabled, onChange
progress value, max (100 by default), label: a bar filled to value; without value it moves on its own
spinner size (16 to 128, 32 by default), label: the spinning ring, for a wait of unknown length
divider A thin line across its container, in Apple’s divider colour
textfield label, value, placeholder, disabled, onChange
dropdown, option label, value, disabled, onChange; children are option nodes with value, label
image src (https, a file path, "artwork": Apple’s image of the song playing, following it, the previous cover fading out in 500 ms on a new song except in eco glass or with Windows’ animation effects off, or "artwork:<id>": the cover of a queue entry, as queue.list() gives it), label, onClick, fit (cover, contain, fill), cornerRadius, width, height
icon icon (SVG), label, onClick
lyrics size, color, placeholder, onChange: the lyrics of the song playing, lit as Apple’s own view does (the whole line, or word by word when Apple times the words), the current line larger and kept in view; placeholder shows while the song has none; a click on a line gives its start in ms to onChange; the wheel scrolls the lines once the pointer has rested on them for a second, and scrolls the page or panel around them before that
any tooltip, tooltipPlacement (top, bottom, left, right), tooltipDelay (0 to 10000 ms)

A card, image or icon with an onClick works from the keyboard as well: Tab stops on it, Enter or Space clicks it, and a card lights up while it has the focus as it does under the pointer.

A tab is a button that never takes a value: its onClick runs, and the app moves selected to the new tab when it draws again (Ampify.components.Tabs does this with value and onChange). A menu takes no onClick of its own; each item has one, and the flyout closes when an item is clicked. A grid with a child that has grow does not stretch it: every child gets one cell of the same width.

Where Attribute Values
any opacity, scale 0 to 1; 0 to 10 around the center
any transition "opacity 400ms", "scale 0.3s", "translation 200ms", "all 300ms" (comma-separated, 10 s max) or "none"
any align, valign start, center, end, stretch (on a text, align is left, center, right)
any grow true: takes the space left in its row or stack
any inert true: the node and everything under it take no click, no hover and no keyboard focus, and the pointer reaches what lies beneath. It is still drawn: pair it with opacity: 0 for controls that fade out, which would take clicks otherwise
stack, row, layer, card background #RRGGBB, #AARRGGBB, acrylic, acrylic(#AARRGGBB, 0.6), or linear-gradient(#top, #bottom). A panel’s root gives its background to the panel’s whole card
stack, row, layer, card padding A number, or "top,right,bottom,left"
containers, image cornerRadius, width, height, minWidth, maxWidth Pixels
text size, weight, color, wrap, maxLines 8 to 120 px; 100 to 900; #RRGGBB; false for one line; 0 to 100
Ampify.ui.topbar.addButton({ label, icon, onClick, active })   // no onClick: a text that only shows something
Ampify.ui.playbar.addButton({ label, icon, onClick, active })  // same; any other onClick than a function throws
Ampify.ui.sidebar.addItem({ label, icon, onClick, active })   // icon: a Segoe Fluent Icons glyph; returns the id
Ampify.ui.menu.addItem("context" | "app", { label, icon, onClick, disabled })
Ampify.ui.menu.addItem("context" | "app", { label, icon, items: [{ label, icon, onClick }, ...] })  // a submenu
Ampify.ui.menu.addItem("context", { label, onClick, kinds: ["song", "album"] })  // only in those items' menus
Ampify.ui.topbar.remove(id)            // also playbar.remove, sidebar.remove, menu.remove: false when not its own
Ampify.ui.popup.open(view)
Ampify.ui.popup.show(name, view)       // a named popup: shown again under the same name, it changes in place
Ampify.ui.popup.close(name)
Ampify.ui.fullscreen.open(view)        // permission ui.fullscreen; called again, updates in place
Ampify.ui.fullscreen.close()
Ampify.ui.fullscreen.onClose(fn)       // returns a function that removes fn
Ampify.ui.applePlayer.open()           // permission ui.fullscreen: Apple Music's own full-screen player
Ampify.ui.miniPlayer.open()            // permission ui.fullscreen: Apple Music's own mini player (1.6)
Ampify.ui.miniPlayer.close()           // as Alt+F4 on it does: Apple Music's main window comes back
Ampify.ui.miniPlayer.toggle()          // closes it when it is on screen, opens it otherwise
Ampify.ui.miniPlayer.set({ opacity, favorite, motion })  // what the element asks of its window; null: nothing
Ampify.ui.animatedCover.set({ video, playbar, fullscreen, mini })  // ui.playbar, ui.fullscreen (1.6.2)
Ampify.ui.panel.register(id, view)     // a 380 px column on the right; it slides in from the right
Ampify.ui.panel.remove(id)             // slides it back out; register brings it back
Ampify.ui.panel.onClose(id, fn)        // the user closed it with its Close button: it is removed (register brings it
                                       // back, a React root unmounts) and fn runs; returns a function that removes fn
Ampify.ui.title.set(text)              // title of the element's panel, page and popup
Ampify.ui.title.get()                  // the title shown now
Ampify.ui.title.reset()                // back to the element's name
Ampify.ui.setLabel(id, label)          // new text of a top bar or play bar button, by the id addButton returned
Ampify.ui.setActive(id, on)            // on or off: a button or sidebar entry that is on takes Apple Music's accent colour
Ampify.ui.setDisabled(id, disabled)    // a top bar or play bar button, or a menu entry, greyed: it ignores clicks
Ampify.ui.playbar.mark(id, from, to)   // a stretch of the progress line for a play bar button it added (1.3)
Ampify.ui.playbar.readout(totalMs)     // the time under the pointer on the progress line, for a span that long (1.3)
Ampify.ui.playbar.onHover(fn)          // fn(part): where the pointer is on the line, 0 to 1, null when it leaves (1.3)
Ampify.ui.playbar.audioBadge({ label, icon })  // what Apple's Lossless badge says; null gives Apple's back (1.5.9)
Ampify.ui.page.register(path, view)    // for an app
Ampify.ui.navigate(path)

5.6 Services [preview]

Ampify.notify({ title, text })                      // permission notifications
Ampify.keyboard.bind("Ctrl+Alt+L", fn)              // permission ui.keyboard
Ampify.keyboard.unbind("Ctrl+Alt+L")                // gives it back; false when this element had not bound it
Ampify.clipboard.copy(text) -> boolean              // permission clipboard.write, 1 MB at most
Ampify.clipboard.paste() -> string | null           // permission clipboard.read: null when it holds no text
Ampify.http.get(url, { headers }) -> Promise<{ status, text }>   // [stable] permission network:<host>
Ampify.http.post(url, body, { headers }) -> Promise<{ status, text }>
Ampify.http.put(url, body, { headers }) / Ampify.http.patch(url, body, { headers }) / Ampify.http.del(url, { headers })
Ampify.http.postForm(url, fields) -> Promise<{ status, text }>   // multipart/form-data
Ampify.http.gifFromVideo(url, { side, fps, seconds }) -> Promise<{ type, base64 }>   // an MP4 made a looping GIF
Ampify.http.open(url) -> boolean                    // opens the page in the browser, an Apple Music link in Apple Music
Ampify.crypto.md5(text) -> hexadecimal string
Ampify.uri.parse(text) / Ampify.uri.build(...)      // [stable] https, music:, itms: and itmss: links of music.apple.com
Ampify.uri.isSong(link) / isAlbum / isPlaylist / isArtist / isStation   // a link, or what parse gave
Ampify.icons.get(name) -> SVG string
Ampify.icons.names() -> string[]
Ampify.color.extract(pixels, width, height)         // RGBA pixels -> PROMINENT, VIBRANT, DARK_VIBRANT, LIGHT_VIBRANT,
                                                    //   DESATURATED, VIBRANT_NON_ALARMING, palette
Ampify.color.fromArtwork(url) -> Promise<colors>    // an https://*.mzstatic.com artwork, same keys
Ampify.color.playing() -> Promise<colors | null>    // the cover playing now, library songs too (player.read)
Ampify.music.analysis(catalogIds) -> Promise<{ [id]: analysis }>   // Apple's audio analysis of songs (player.read, 1.6)
Ampify.music.mood(analysis, part?) -> "happy" | "calm" | "sad" | "tense" | null
Ampify.fonts.roles() -> { [role]: { family, weight, size, fromTheme } }
Ampify.fonts.style(name) -> { role, family, weight, size, fromTheme } | null
Ampify.lyrics.current() -> Promise<lyrics | null>   // player.lyrics() as a promise, permission player.read
Ampify.library.tracks() -> Promise<track[]>         // permission library.read
//   track: { persistentId, title, artist, album, albumArtist, genre, composer, year, trackNumber, discNumber,
//            albumId, playCount, skipCount, lastPlayed, dateAdded, durationMs }
//            // text fields and albumId "" (the album's persistent id), numbers 0 when the library does not say

5.7 Local services [preview]

Each service is off until the user sets its setting to 1 (ampify config discord.enabled 1). While off, calls return false and log a line.

// Discord presence, permission ipc.discord, setting discord.enabled
Ampify.discord.setActivity({ clientId, type, statusDisplay, details, state, largeImage, largeText, smallImage,
  smallText, detailsUrl, stateUrl, largeUrl, smallUrl, buttons: [{ label, url }], startMs, endMs })
Ampify.discord.clear()

// Notification-area icon menu, permission ui.tray, setting tray.enabled
Ampify.tray.setMenu([{ label, onClick, checked, enabled }, "-"])   // "-" is a separator, 20 entries at most
Ampify.tray.onClick(fn)

// MIDI controller, permission midi.input, setting midi.enabled (engine process)
Ampify.midi.on("note:60" | "cc:7" | "ch2:note:36" | "note:*" | "*", fn)   // fn({ type, channel, number, value })
Ampify.midi.devices() -> ["name", ...]

// Local remote, setting remote.enabled (engine process), no permission
Ampify.remote.setState(object)         // shown in GET /status under extensions.<id>, 4 KB at most

// Output file, permission fs.output
Ampify.fs.writeText("now-playing.txt", text)   // -> output\<id>\now-playing.txt

Discord: clientId is a Discord application id. type is "playing", "listening", "watching" or "competing"; statusDisplay is "name", "state" or "details". Links are https; two buttons at most. Ampify sends one update every 4 seconds at most, and the last element that calls setActivity wins.

The local remote listens on 127.0.0.1:<remote.port> (8974 by default) only. Send the token (ampify config remote.token) in the X-Ampify-Token header. Requests from web pages are refused.

Request Effect
GET /status { playing, positionMs, durationMs, track, gainDb, extensions }
POST /play, /pause, /next, /previous Player command; 409 if it cannot be done now
POST /volume?db=-6 A gain on the samples, capped by audio.maxGainDb
curl -H "X-Ampify-Token: <token>" http://127.0.0.1:8974/status

MIDI: midi.device picks the device, and midi.map links keys to commands without any element (note:60=next;note:62=previous;cc:20=play;cc:7=gain).

An app and an extension with the same id run side by side and exchange JSON messages (like Spicetify’s subfiles_extension):

Ampify.link.post(message)   // true if the other one is running; 64 KB at most
Ampify.link.on(fn)          // fn(message) for each message; returns a function that removes fn
Ampify.link.connected()     // true if the other one is running

Messages arrive in order on a later turn. If the other side is not running, post returns false and the message is lost, so let the one that starts second say hello. Both share storage\<id>.json: let only one of them write it.

5.9 React and components [stable]

Ampify.React accepts React’s style without JSX and produces the node tree of section 5.5. The target needs its own permission (ui.panel, ui.page, ui.popup or ui.fullscreen).

const { h, useState } = Ampify.React;

function Counter() {
  const [n, setN] = useState(0);
  return h("stack", null,
    h("text", null, "Clicks: " + n),
    h("button", { label: "Add one", onClick: () => setN(n + 1) }));
}

Ampify.ReactDOM.render(h(Counter), "panel:counter");
Ampify.ready.then(() => Ampify.log("ready"));
Ampify.React.createElement(type, props, ...children)  // also Ampify.React.h
Ampify.React.Fragment
Ampify.React.isValidElement(value)
Ampify.React.cloneElement(element, props, ...children)
Ampify.React.Children.toArray(children)              // also map, forEach, count, only
Ampify.React.createContext(default)                   // -> { Provider, Consumer }
Ampify.React.memo(component)
Ampify.React.useState(initial)                        // also useReducer, useEffect, useLayoutEffect,
Ampify.React.useContext(context)                      //   useRef, useMemo, useCallback
Ampify.hooks.usePlayer()                              // player state, kept up to date (permission player.read)
Ampify.hooks.useArtworkColor()                        // colors of the cover playing (color.playing), or null
Ampify.ReactDOM.render(element, target)
Ampify.ReactDOM.createRoot(target)                    // -> { render(element), unmount() }
Ampify.ReactDOM.unmountComponentAtNode(target)
Ampify.ready                                          // resolves once the element has started
Component Props
Button (ButtonPrimary, ButtonSecondary, ButtonTertiary) label or a text child, icon, disabled, variant, onClick
Toggle label, value or checked, disabled, onChange(checked)
Checkbox The props of Toggle, drawn as Apple’s check box
Slider label, min, max, step, value, unit, disabled, onChange(number)
TextField label, value, placeholder, disabled, onChange(text)
Dropdown label, value, options (texts or { value, label }), disabled, onChange(value)
ProgressBar value, max (100 by default), label: filled to value; without value it moves on its own
Spinner size (16 to 128, 32 by default), label: Apple’s turning ring
Divider No props of its own: a thin line in Apple’s divider colour
Grid columns (1 to 12), gap (0 to 1000), children
Tabs value, options (texts or { value, label }), onChange(value): a tab per option, the one of value on
Menu label, disabled, items ({ label, disabled, onClick } each): a flyout under a button
Card title, subtitle, onClick, children, box style
List children
Text (TextComponent) text or children, variant, size, weight, color, align, wrap, maxLines
Tooltip (TooltipWrapper) label or content, placement, delay, children
ConfirmDialog isOpen, titleText, descriptionText, confirmText, cancelText (Ampify’s “Confirm” and “Cancel” in the display language by default), onConfirm, onClose: render it into a popup; it closes when the element renders it with isOpen: false or unmounts it

Each component draws the node of section 5.5 that has its name, so a tree written by hand and a React tree look the same. Every component but Divider accepts tooltip, tooltipPlacement and tooltipDelay. Full example: examples/react-panel/.

useArtworkColor() reads the cover again at each new track. Right after the change, Windows may still give the previous cover for a second or two (player.artwork).

6. Themes, apps and snippets

6.1 Themes [stable]

A theme is a folder with colors.ini, user.css, resources.xaml and optionally a main.js that runs like an extension while the theme is active. Format: themes/format.md.

6.2 Apps [stable]

An app lives in apps\<id>, is switched on with ampify app enable <id>, and adds pages with Ampify.ui.page.register. Its manifest icon does not create a sidebar entry by itself: the app adds one with Ampify.ui.sidebar.addItem and opens its page with Ampify.ui.navigate("/<path>"). A page can lead to another of its pages (Ampify.ReactDOM.render(view, { page: "/<path>/item" }), then navigate): the arrow of the page header goes back to the previous one. Each page mounts anew when it opens, so keep what must outlive it (the tab, the search) in a module variable. Ampify.ui.navigate("/ampify/settings") opens Ampify’s settings page.

6.3 Snippets [stable]

A snippet is a user.css, a resources.xaml fragment, or both, switched on by itself (format).

7. Errors and the log

8. Not in API 1.0

9. Versions

kitApi is MAJOR.MINOR. A minor version only adds; a major version removes or changes a stable function. A removed function stays one more minor version, with a warning in the log. The kernel accepts any minor version of its major.