Manifest (manifest.json)
manifest.json sits at the root of the project (and of the mini program package) and describes what the content is and what it needs.
{
"id": "com.example.day-progress",
"name": { "en": "Day Progress", "zh-Hans": "今日进度" },
"type": "widget",
"version": "1.0.0",
"apiVersion": 1,
"author": "Example",
"icon": "assets/icon.png",
"widget": { "sizes": ["small", "medium"] },
"parameters": [
{ "key": "accent", "title": "Accent Color", "type": "color", "default": "#0A84FF" }
]
}| Field | Required | Description |
|---|---|---|
id | Yes | A unique identifier in reverse domain name form, only letters, digits, dots and hyphens, e.g. com.example.clock |
name | Yes | The name shown in the library, can be translated, see Localization |
type | Yes | wallpaper, widget or companion (desktop companion), see Types |
version | Yes | The version, semantic versioning is recommended, e.g. 1.0.0 |
apiVersion | The lowest runtime API version it needs, see API versions | |
author | The author, shown in the details pane | |
description | A sentence or two about it, can be translated | |
icon, preview | The icon and the preview image, paths in the package | |
previewDark | The preview image in dark mode, a path in the package: for content that follows the system appearance, preview is then the one in light mode. Without it, preview shows in both | |
widget.sizes | The sizes of a widget, the first by default: small 164×164, medium 344×164, large 344×344, and sizes of its own (API 8), see Widget sizes; small by default | |
widget.resize | Lets the user or the content resize a widget within a range (API 8), see Widget sizes | |
wallpaper.span | true when a wallpaper can span displays, see Spanning displays | |
permissions | The permissions it needs, see Permissions | |
network.domains | With network | The domains it connects to, see Network |
audio.volume | With audio: the volume the user's volume for it starts at, 0...1 (API 9), see Audio | |
parameters | Options users can change, see Options | |
converter | For a package a tool made from something else: the tool and what it was made from, see Made by a tool |
desktopengine validate checks the manifest by the app's rules; the app refuses packages that break them.
Types
type | What it is |
|---|---|
wallpaper | A dynamic wallpaper: fills a display (or all of them, see wallpaper.span) below every window |
widget | Sits where the user puts it, on the desktop or above all windows, in the sizes of widget.sizes |
companion | A desktop companion: a character, a mascot, a little vehicle, a game… that lives above all windows and moves around the screen on its own |
companion needs "apiVersion": 2. Apps with API 1 know companions by their old name, pet: a manifest that still says pet works everywhere and the app treats it as companion, validate only warns. launchOptions.type is the type as the manifest writes it.
Widget sizes
widget.sizes lists the sizes the user picks from in the app, the first by default. The app lists them by area, smallest first, whatever their order here. Besides the presets, a widget can declare sizes of its own, mixed with them (needs "apiVersion": 8):
"widget": {
"sizes": [
{ "id": "standard", "width": 440, "height": 196, "name": { "en": "Standard", "zh-Hans": "标准" } },
{ "id": "compact", "width": 300, "height": 133, "name": { "en": "Compact", "zh-Hans": "紧凑" } },
"medium"
]
}| Field | Description |
|---|---|
id | Lowercase letters, digits and hyphens, not a preset's name, each once: launchOptions.size gives it |
width, height | Whole points, at least 32. There's no upper limit: the app scales a widget bigger than its display's visible frame down in its shape (validate warns about sizes a 1280×800 display can't show whole) |
name | Shown in the app's size picker, can be translated like name |
A widget keeps the size picked unless widget.resize lets it change (needs "apiVersion": 8):
"widget": {
"sizes": ["medium"],
"resize": { "by": ["user"], "minWidth": 200, "minHeight": 120, "maxWidth": 800, "aspectRatio": "fixed" }
}| Field | Description |
|---|---|
by | Who resizes it: user, by its edges and corners on the desktop like an ordinary window; content, by its window's style; or both |
minWidth, minHeight | The smallest size, whole points; 32 by default |
maxWidth, maxHeight | The largest size; no limit by default |
aspectRatio | fixed: the width and height keep the ratio of the size picked |
The size picked is the one it starts in. The app remembers the size it was left in and starts it in that size next time; picking a size again starts it in that one. See Widget size for how the window behaves.
JSON Schema
Add $schema to the manifest and editors such as VS Code complete and check its fields:
{
"$schema": "https://desktopengine.app/desktopengine-sdk/manifest.schema.json",
"id": "com.example.day-progress"
}The same schema is in the npm package, schema/manifest.schema.json.
Localization
name, description, and the title and options[].title of options can be a string, or translations by language. The app picks the user's preferred language, and en when none matches:
"name": { "en": "Day Progress", "zh-Hans": "今日进度" }Language codes are the ones macOS uses, e.g. en, zh-Hans, zh-Hant, ja; codes with a region such as zh-CN match too. Text drawn on a canvas is translated by your code, picking by DesktopEngine.launchOptions.locale.
Options (parameters)
You only declare the options; the app draws them as a native form in the details pane, so you don't build a settings UI.
{ "key": "accent", "title": "Accent Color", "type": "color", "default": "#0A84FF" }| type | Control | default |
|---|---|---|
toggle | A switch | A boolean |
number | A slider when it has both min and max (step is the step), a number field otherwise | A number |
text | A text field | A string |
color | A color well | #RRGGBB |
choice | A pop-up menu, options is [{ "value": …, "title": "…" }] | One of the values |
An option that only matters for some values of another can be shown only then with showWhen: the key of an earlier toggle or choice option, and the values of it that show this one. A hidden option keeps its value and is still in DesktopEngine.launchOptions.parameters. Apps with an API older than 8 show every option.
[
{ "key": "style", "title": "Style", "type": "choice", "default": "digital",
"options": [{ "value": "digital", "title": "Digital" }, { "value": "analog", "title": "Analog" }] },
{ "key": "seconds", "title": "Second Hand", "type": "toggle", "default": true,
"showWhen": { "key": "style", "values": ["analog"] } }
]When the user changes an option, the new values are in DesktopEngine.launchOptions.parameters. Content that listens to parameterschange applies them while it keeps running, see When options change; the app restarts other content (dragging a slider or typing is coalesced into one restart).
Permissions
| Permission | Meaning |
|---|---|
network | Connect to the domains in network.domains |
audio | Play sound |
system-info | How the Mac is doing: CPU and memory usage, and DesktopEngine.systemStatus (processor, memory, network, power, temperature, disk) |
mouse | Where the pointer is and the clicks, in any app (needs "apiVersion": 3), see Following the Mouse |
system-audio | How loud the sound other apps play on the Mac is, overall and from low to high, never the sound itself (needs "apiVersion": 6); content with it can't have network too, see What the Mac plays |
window-positions | Where other apps' windows are, their size and order, and which belong to the app in use; never their titles or what they show (needs "apiVersion": 6), see Other Apps' Windows |
Any other permission is an error: the app neither lists nor asks for permissions it doesn't know, and the content never gets them. The app lists these permissions in the details pane. audio isn't asked for: content that declares it can make sound, and users control it with its mute switch (on until they turn the sound on), its volume and Mute All Content, see Volume and mute. The other permissions are asked for one by one the first time the user adds the content to the desktop; the user can allow only some of them and change them any time in the details pane (the content restarts). Content that declares no permissions never prompts. On a Mac before macOS 14.2 system-audio isn't asked for either: there's nothing to hear, so the content gets it and hears silence (supported is false).
A denied permission doesn't stop the content: it starts as usual with that capability off, so plan for running without it. The permissions it got are in DesktopEngine.launchOptions.permissions, each once, in the app and in the web preview alike. The previews in the app's details pane are silent and don't see other apps' windows, so audio and window-positions aren't there:
const permissions = DesktopEngine.launchOptions?.permissions ?? [];
if (permissions.includes('network')) {
refresh();
} else {
showOfflineHint(); // don't keep retrying
}With network, list the domains the content connects to; it can reach those and nothing else, and the permission prompt shows them to users:
"permissions": ["network"],
"network": { "domains": ["api.example.com", "*.tile.example.org"] }The runtime enforces network (no network without it, and only the listed domains with it, see Network), audio (no sound without it, see Audio), system-info (DesktopEngine.systemStatus is null without it), mouse (DesktopEngine.input's mouse events never come without it), window-positions (DesktopEngine.windows is null without it) and system-audio (DesktopEngine.systemAudio is null without it). Declaring both system-audio and network is an error: desktopengine validate reports it, and the app and the store refuse the package. Content run by desktopengine dev or the Develop menu is yours, so it isn't asked and gets every permission it declares, under the same rules as installed content (network, for example, still reaches only the listed domains). The ones it doesn't declare are off there too.
Audio
audio.volume is the volume the content plays at until the user sets one for it, 0...1: e.g. 0.5 for content that's loud for what it is. Without it the volume starts at 1. The user's volume replaces it, and the content reads either in DesktopEngine.audioSettings. It needs the audio permission; a number outside 0...1 is an error.
{
"permissions": ["audio"],
"audio": { "volume": 0.5 },
"apiVersion": 9
}Apps with an older API ignore it and play at full volume until the user sets one, so validate only warns without "apiVersion": 9.
Made by a tool
A tool that makes packages from something else, such as a converter from another format, can say so in converter: then the tool, or the user, can tell later which tool and version made a package and from what, for example to make it again with a newer version.
"converter": { "name": "example-convert", "version": "0.3.0", "source": { "type": "scene", "hash": "9f2c41…" } }name and version are strings that aren't empty or only spaces, source is an object in the tool's own terms; desktopengine validate checks them. Apps don't act on it: a package whose converter they can't read is imported as if it had none. A tool that makes a package again from the same source should keep its id, so the options the user chose, its data and where it is stay with it, and give it a higher version.
API versions
The runtime has an integer API version that goes up when APIs are added: DesktopEngine.apiVersion in JavaScript. This SDK describes version 9 (the first line of desktopengine --help shows it too). When you use an API added later, put its version in "apiVersion" and apps with an older API refuse to import the package and ask users to update; or leave it out and check DesktopEngine.apiVersion at run time to fall back.
| Version | Added |
|---|---|
| 1 | The first version |
| 2 | The companion type, formerly pet |
| 3 | DesktopEngine.input and the mouse permission, see Following the Mouse |
| 4 | Image's size fill (stretched) and none (its own size), Video's objectFit none; every mouse button's mousedown and mouseup, with button and buttons in the mouse events' payload, see Mouse; queueMicrotask, atob, btoa and crypto (getRandomValues, randomUUID), see Globals; currentTime, duration and paused of Video |
| 5 | ellipse(), roundRect(), getTransform(), createConicGradient(), letterSpacing and wordSpacing of 2D canvases, setTransform() taking a matrix, the blend modes (multiply…luminosity), the rest of TextMetrics, Path2D, isPointInPath and isPointInStroke; createImageBitmap and new ImageData(); structuredClone, MessageChannel, FileReader, CustomEvent and navigator, see Globals |
| 6 | BroadcastChannel, with the scopes package and namespace, see Messages Between Content; DesktopEngine.systemAudio and the system-audio permission, see What the Mac plays; DesktopEngine.windows (list(), visibleTopEdges() and change) and the window-positions permission, see Other Apps' Windows; an Image loads its src before it's in a component, so its load can be waited for before adding it |
| 7 | DesktopEngine.syncStorage, keys and values that follow the user to their other Macs, see Synced storage |
| 8 | showWhen of options, shown only for some values of another, see Options; DesktopEngine.systemStatus: processor, memory, network, power and the battery, temperature and disk, with events when they change and resume after the content was suspended, see System Status (system-info permission); widget sizes of its own and widget.resize, the user or the content resizing a widget, and no half-display limit for a widget's window, see Widget sizes; DesktopEngine.system.cpuUsage() and memoryUsage() are removed: DesktopEngine.systemStatus reads the processor (cpu.usage) and memory (memory.used, memory.total); wheel on widget and companion windows while the pointer is over them, see Mouse |
| 9 | FontFace and DesktopEngine.fonts: fonts of the content's own for 2D canvases, from package files, defile://, blob: and data: URLs, installed fonts or bytes, see Fonts; A Video is a source for canvases, as a video element is: WebGL's texImage2D / texSubImage2D (and texImage3D / texSubImage3D), drawImage, createPattern and createImageBitmap take its frame showing now; its videoWidth, videoHeight, readyState and the loadedmetadata, loadeddata and canplay events; it plays out of a window while canvases read it, and a video never in a window loads when it has a src, see Video; a looping Video goes on from the start without a pause and doesn't fire ended at each end any more, as a looping video element: in every package, whatever its apiVersion, see Looping; DesktopEngine.audioSettings, the mute and volume the user set for the content, and audio.volume in the manifest, see Volume and mute |
Version 4 also changed APIs as in browsers: the double click event is dblclick (it was dbclick), and click and dblclick get the mouse events' payload, { x, y, … } (it was { position: { x, y } }). It removed wxBindCanvasTexture and blBindCanvasTexture of WebGL contexts, the global mixin and promisify, and the files, now-playing and window-positions permissions, which had no API (version 6 brings window-positions back with DesktopEngine.windows). Content that used them needs "apiVersion": 4 once it's changed.
