atomm Object
atomm is a global object injected into the page once the platform SDK (platform-sdk.js) loads. It exposes platform capabilities and UI utilities, and can be used directly in your generator code.
Lifecycle — atomm.lifecycle
Register platform lifecycle hooks via lifecycle.on:
atomm.lifecycle.on('export', async () => { ... })
Toasts — atomm.ui
Shows a platform-wide toast notification. Takes an object as its argument:
type: optional, one ofsuccess/warning/error/info, defaults tosuccessmessage: the notification textduration: optional, how long the toast stays visible, in seconds;0means it won't auto-close; defaults to 3 seconds if omitted
toast() returns the id of that toast; call closeToast(id) to close it manually. A persistent toast with duration: 0 must be closed this way, or it will stay on screen indefinitely.
atomm.ui.toast({ type: 'success', message: '已完成' })
// Show for 5 seconds
atomm.ui.toast({ type: 'info', message: '正在处理…', duration: 5 })
// duration: 0 keeps it on screen; close it with closeToast once the task finishes
const id = await atomm.ui.toast({ type: 'info', message: '导出中…', duration: 0 })
// …task finishes…
await atomm.ui.closeToast(id)
Passing a string (e.g. toast('已完成')) won't work — the platform only reads message and type off an object, so a string is treated as an empty message. The ui namespace currently provides toast (which returns the toast's id) and closeToast.
Language — atomm.app
The platform's current UI language, so your generator can localize along with it.
// Current locale code — always one of the 17 supported languages
const locale = await atomm.app.getLocale()
// All supported locales (code + display name), for building a language selector consistent with the platform
const locales = await atomm.app.getSupportedLocales()
// → [{ code: 'zh', name: '简体中文' }, { code: 'en', name: 'English' }, …]
Calling getLocale() once at startup to pick the initial language is enough. It is a one-time read, not a subscription — changing the platform language reloads the whole page, so your app restarts and reads the new value on its own. You never need to listen for changes.
getLocale() always returns one of the 17 codes below, but your app may not have translated all of them. When you get a language you have no copy for, fall back to English or your own default.
| Code | Display name | Language |
|---|---|---|
zh | 简体中文 | Simplified Chinese |
en | English | English |
zh-hant | 繁體中文 | Traditional Chinese |
de | Deutsch | German |
es | Español | Spanish |
fr | Français | French |
it | Italiano | Italian |
ja | 日本語 | Japanese |
ko | 한국어 | Korean |
ru | Русский | Russian |
uk | Українська | Ukrainian |
sl | Slovenščina | Slovenian |
th | ไทย | Thai |
pl | Polski | Polish |
cs | Čeština | Czech |
id | Bahasa Indonesia | Indonesian |
vi | Tiếng Việt | Vietnamese |
The table is in the order getSupportedLocales() returns, and "Display name" is exactly the name it gives you — use it directly in a language picker.
The developer toolkit's Simulator has a "Preview language" dropdown. Switching it changes what getLocale() returns and reloads your generator, so you don't have to change the language on the real platform. See Developer toolkit.
User — atomm.user
// Whether the user is currently logged in (returns only a boolean, no token or profile data)
const loggedIn = await atomm.user.isLoggedIn()
// If not logged in, opens the login dialog and waits for the user to finish; returns whether they ended up logged in
if (!loggedIn) {
const ok = await atomm.user.login()
if (!ok) return // User canceled or login failed
}
// Reaching here means the user is logged in — continue with your logic
login() opens a login window, so call it from within a user gesture handler (e.g. a click callback) to avoid having it blocked by the browser's popup blocker. Logging in is a long-running interaction, so the platform already extends its timeout for it (about 5 minutes) — you don't need to add your own.
Safe invocation
If you're not sure whether your code is running inside the platform, use optional chaining to avoid errors:
window.atomm?.ui?.toast?.({ type: 'info', message: 'hi' })