Skip to content

AP.boot

Start a panel with AP.boot. Options, the ctx object passed to start, and the boot lifecycle.

Every panel calls AP.boot exactly once, from its src/panels/<id>/main.js code. ap check fails when a panel never calls it.

AP.boot({
start: function (ctx) {
// Build your UI here.
},
license: false, // default. true, or { offlineGraceDays, checkInBackground }
renderLicense: function (api, root) {}, // required when license is on
updates: { check: "auto", mode: "background" } // defaults
});
Option Type Default Meaning
start function (ctx) required Your app. Called once, when the panel may run.
license false, true, or { offlineGraceDays, checkInBackground } false Turns licensing on. See licensing.md.
renderLicense function (api, root) none Draws the license screen. Required when license is on.
updates.check "auto" or "manual" "auto" "auto" checks at start and every 6 hours. See updates.md.
updates.mode "background", "prompt" or "silent" "background" What happens when an update is found. "background" installs it without asking, then your update screen offers Reload now (AP.updates.reload()). "prompt" waits for your Install button. "silent" installs and shows nothing. See updates.md.

Unknown values are replaced by the default with a console warning. If license is on and renderLicense is missing, AP.boot logs an error and throws; the panel stays empty.

start(ctx) receives:

ctx = {
product: { bundleId: "com.afterpresets.seller.tool", version: "1.2.0" },
panel: { id: "main" }, // this panel's id from afterpresets.json
license: AP.license, // license api; status is "disabled" when licensing is off
updates: AP.updates, // see updates.md
host: AP.host // see host.md
};

The same objects are also available as globals (AP.license, AP.updates, AP.host, AP.panels, AP.events) for code that runs outside start.

  1. The page loads. The runtime is already defined; nothing has run yet.
  2. Your entry code calls AP.boot(options).
  3. When the DOM is ready:
    • License off: AP.license.state.status is "disabled" and start(ctx) runs immediately.
    • License on: the runtime adds an empty <div id="ap-license-root"> to <body>, calls renderLicense(api, root), and validates the license. start(ctx) runs once the status becomes active or offline_grace. It never runs for any other status.
  4. After start, if updates.check is "auto", the runtime checks for updates now and every 6 hours. In the default "background" mode a found update is installed right away and AP.updates.onInstalled fires; the panel keeps running the old version until AP.updates.reload() or the next launch.

start runs at most once per panel load. If the license later becomes invalid (for example the buyer signs out), the license root is shown again over your app; start is not called a second time.

AP.boot({
start: function (ctx) {
var app = document.getElementById("app");
app.textContent = "Hello from " + ctx.product.bundleId + " (" + ctx.panel.id + ")";
}
});
AP.boot({
start: function (ctx) {
renderHome(document.getElementById("app"), ctx); // imported from src/app/home/home.js
},
license: true,
renderLicense: renderLicense, // imported; see licensing.md
updates: { check: "auto", mode: "background" }
});
  • Do not build app UI before start runs. Put it inside start.
  • Do not call start yourself, and do not call AP.boot twice (the second call is ignored with a warning).
  • Do not wrap AP.boot in try/catch to hide the missing-renderLicense error. Fix the options instead.