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 of success / warning / error / info, defaults to success
  • message: the notification text
  • duration: optional, how long the toast stays visible, in seconds; 0 means 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)
toast requires an object

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.

CodeDisplay nameLanguage
zh简体中文Simplified Chinese
enEnglishEnglish
zh-hant繁體中文Traditional Chinese
deDeutschGerman
esEspañolSpanish
frFrançaisFrench
itItalianoItalian
ja日本語Japanese
ko한국어Korean
ruРусскийRussian
ukУкраїнськаUkrainian
slSlovenščinaSlovenian
thไทยThai
plPolskiPolish
csČeštinaCzech
idBahasa IndonesiaIndonesian
viTiếng ViệtVietnamese

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.

Testing languages locally

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
Call login from within a user gesture

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' })
Esc
Search all docs · to navigate · to open