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});Options
Section titled “Options”| 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.
Lifecycle
Section titled “Lifecycle”- The page loads. The runtime is already defined; nothing has run yet.
- Your entry code calls
AP.boot(options). - When the DOM is ready:
- License off:
AP.license.state.statusis"disabled"andstart(ctx)runs immediately. - License on: the runtime adds an empty
<div id="ap-license-root">to<body>, callsrenderLicense(api, root), and validates the license.start(ctx)runs once the status becomesactiveoroffline_grace. It never runs for any other status.
- License off:
- After
start, ifupdates.checkis"auto", the runtime checks for updates now and every 6 hours. In the default"background"mode a found update is installed right away andAP.updates.onInstalledfires; the panel keeps running the old version untilAP.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.
Example: a free extension
Section titled “Example: a free extension”AP.boot({ start: function (ctx) { var app = document.getElementById("app"); app.textContent = "Hello from " + ctx.product.bundleId + " (" + ctx.panel.id + ")"; }});Example: a paid extension
Section titled “Example: a paid extension”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" }});Mistakes to avoid
Section titled “Mistakes to avoid”- Do not build app UI before
startruns. Put it insidestart. - Do not call
startyourself, and do not callAP.boottwice (the second call is ignored with a warning). - Do not wrap
AP.bootintry/catchto hide the missing-renderLicenseerror. Fix the options instead.