Skip to content

API 参考 ​

每个公开包一页,由 npm run docs:api(site/tools/apigen,标准库 go/doc)从源码注释生成,按 darwin/arm64 的构建标签选文件。也可以用 go doc 在本地查看同样的内容。

标「实验性」的包任何 0.x 版本都可能有不兼容变化;标「部分实验性」的包只有 api/stable/<包>.txt 列出的符号是稳定层,页面里逐个标出实验性符号(docs/release.md「API 稳定性」)。

目录搬迁

能力包位于 github.com/tangoui/tango/sys/<名字>,更新器位于 github.com/tangoui/tango/service/updater。

核心 ​

包说明
github.com/tangoui/tangoPackage tango is the core of the Tango application framework: one Go program that runs on desktop (macOS, Windows, Linux) and mobile, showing its interface in the system WebView.
assetPackage asset serves a front end to Tango surfaces: static files from an fs.FS, or, in development builds (-tags tango_dev, which tan dev adds), a reverse proxy to a dev server (Vite).
automationPackage automation drives a running Tango application from Go tests, like Playwright drives a browser: it starts the program (a development build: -tags tango_dev, which Launch adds when it builds a package) with the automation control channel turned on, finds windows, locates nodes of self-drawn windows through their semantics tree, clicks, types, waits, evaluates JavaScript in WebView windows, takes screenshots and quits the app at the end of the test.
bindPackage bind exposes the exported methods of a Go value as ipc calls named "Name.Method" using reflection.
i18nPackage i18n gives a Tango app the user's system languages, a current locale the app may override, and a small message catalog with named arguments and CLDR plural categories.
ipcPackage ipc implements Tango's IPC wire protocol (version 2) on top of raw page messages: calls (JS→Go request/response), events (both directions) and flow-controlled, bidirectional streams that either side may open and that carry JSON values and bytes both ways.
jsapiPackage jsapi exposes Tango's system capabilities to the page: the window the page lives in, app information and control, clipboard, dialogs, notifications, shell, context menus and global shortcuts.
macoslite 实验性Package macoslite is a minimal macOS-native window host for small utility windows (settings, updaters, prompts).
runtime-js/runtimejsPackage runtimejs embeds the IIFE build of @tangoui/runtime.

系统能力 sys/ ​

包说明
sys/appctlPackage appctl controls the app as a whole in the window manager: hide and show all its windows, the dock / taskbar badge and progress bar, bouncing the dock icon or flashing the taskbar button, and the dock icon itself (tray-only apps).
sys/autostartPackage autostart starts the app when the user logs in.
sys/backgroundPackage background runs work while the app is in the background: periodic content refresh and longer maintenance tasks, scheduled with the system's task scheduler (BGTaskScheduler on iOS, JobScheduler on Android) and run when the system decides.
sys/biometricPackage biometric verifies the device owner with Face ID / Touch ID (iOS, macOS) or BiometricPrompt (Android 9+).
sys/clipboardPackage clipboard reads and writes the system clipboard: text, images (PNG bytes) and file lists.
sys/devicePackage device holds small device controls of mobile apps: asking for a store rating, opening the app's settings page, keeping the screen on, screen brightness, the status bar, and the software keyboard.
sys/dialogPackage dialog shows native message and file dialogs.
sys/envPackage env describes the environment the app runs in: operating system and version, CPU architecture, whether this is a debug build, and the WebView engine.
sys/flyoutPackage flyout shows a borderless panel under a tray icon — a popover in the macOS menu bar, a flyout above the Windows notification area — that hides itself when it loses focus.
sys/hapticsPackage haptics plays haptic feedback: impacts, selection ticks and notification patterns (UIFeedbackGenerator on iOS, View.performHapticFeedback on Android, which needs no permission).
sys/hotkeyPackage hotkey registers keyboard shortcuts.
sys/jumplistPackage jumplist sets the app's shortcut menu: the menu of the Dock icon on macOS and the "Tasks" of the taskbar Jump List on Windows.
sys/locationPackage location reads the device's location once or continuously (Core Location on iOS, LocationManager on Android — no Google Play services needed).
sys/mediaPackage media lets the user pick photos and videos from the library or take a photo with the camera.
sys/menuPackage menu builds native menus in Go and routes their clicks to Go callbacks.
sys/networkPackage network reports whether the machine is online, over what kind of link, whether the connection is metered, and when that changes.
sys/notifyPackage notify shows system notifications (Notification Center on macOS, the notification area on Windows, the freedesktop notification service on Linux) and reports clicks on them.
sys/orientationPackage orientation reads and locks the interface orientation.
sys/permissionPackage permission queries and requests runtime permissions with one API on iOS and Android.
sys/powerPackage power reports the machine's power state (AC or battery, charge, power-saving mode), tells the app when the system sleeps and wakes, and keeps the machine awake while the app plays video or runs a long task.
sys/printPackage print prints through the system print dialog: the page shown in a WebView surface, PDF documents and images.
sys/pty 实验性Package pty runs programs on local pseudo-terminals, the connection a terminal emulator such as ui/terminal needs to run a shell.
sys/purchasePackage purchase sells in-app products through the platform store.
sys/pushPackage push registers the app for remote (push) notifications and reports notifications that arrive or that the user taps.
sys/recentPackage recent keeps the app's list of recently opened documents.
sys/safeareaPackage safearea reports the parts of a page covered by system UI (status bar, notch / Dynamic Island, home indicator, navigation bar) and follows their changes, e.g.
sys/screenPackage screen lists the displays attached to the computer.
sys/securestorePackage securestore keeps small secrets (tokens, keys, passwords) in the platform's protected storage: the Keychain on iOS and macOS (generic passwords of the app, this device only, available after first unlock); on Android values encrypted with an AES key held in the Android Keystore, stored in the app's private SharedPreferences; the Credential Manager on Windows (generic credentials of the user, not roaming); and the Secret Service on Linux (GNOME Keyring, KWallet) through libsecret.
sys/sharePackage share opens the system share sheet with text, a URL and/or files: UIActivityViewController on iOS, an ACTION_SEND chooser on Android, NSSharingServicePicker on macOS.
sys/shellPackage shell hands URLs and files to the operating system: open a link in the default browser, a file with its default app, or show a file in Finder / Explorer / the file manager.
sys/singlePackage single keeps one instance of an app running per user.
sys/themePackage theme reads the system's light/dark appearance and accent color and follows their changes.
sys/theme/uivarsPackage uivars injects the design tokens of Tango's self-drawn UI (ui/theme) into every WebView page as CSS custom properties, and keeps them in step with the system's light/dark appearance, so the pages of an app and its self-drawn windows look the same.
sys/trayPackage tray shows an icon in the system tray (macOS menu bar extras, Windows notification area, Linux AppIndicator / StatusNotifierItem).
sys/widgetPackage widget updates the app's home-screen widget.
sys/windowstatePackage windowstate remembers where a window was: its position, size and whether it was maximized, saved as it changes and restored the next time the app starts.

服务 service/ ​

包说明
servicePackage service ties long-lived Go values ("services") to the lifecycle of a tango.App: they start in registration order once the app is ready and shut down in reverse order when it terminates.
service/fileserverPackage fileserver serves a local directory over HTTP, for showing user files (downloads, generated images, a documents folder) in a page.
service/kvPackage kv is a small thread-safe key-value store for app settings and state: kept in memory and, optionally, persisted to a JSON file.
service/logPackage log sets up application logging on log/slog: records go to stderr and to a log file that rotates by size, and the page can log through ipc (Handler).
service/pathsPackage paths returns the per-user directories an application keeps its files in, on every platform Tango runs on.
service/updaterPackage updater keeps a Tango desktop app up to date: it fetches a signed update manifest, refuses anything older than what it runs (or has seen), downloads a binary patch or the full release, verifies it, installs it once the app quits, and rolls back if the new version does not confirm that it starts.
service/updater/updateui 实验性Package updateui is a ready-made update window for apps that use service/updater: it checks for updates in the background, shows what a new release contains, downloads it with progress, and restarts into it when the user agrees.

自绘 UI ​

包说明
ui 部分实验性Package ui is the self-drawn GUI layer of Tango: an immediate-mode API over retained widget state, rendered by a pure-Go pipeline (no cgo) with the visual language of Ant Design 6.7 (default), Element Plus and shadcn/ui.
ui/a11yPackage a11y defines the platform-neutral accessibility (semantics) tree produced by the Tango UI runner.
ui/chart 实验性Package chart is the chart library of the Tango self-drawn UI: line, area, column / bar, pie / donut, scatter / bubble, radar, gauge, funnel, heatmap, dual axes, liquid and tiny (sparkline) charts, drawn with the ui/paint display list and styled after Ant Design Charts (G2) for the Ant flavor and ECharts for Element Plus.
ui/codehl 实验性Package codehl implements ui.CodeHighlighter with the code editor's language support: the Monarch grammars of ui/editor/langs and the incremental tokenizer of ui/editor/highlight.
ui/editor 实验性Package editor is the code editor.
ui/editor/buffer 实验性Package buffer is the immutable text model behind the code editor.
ui/editor/diff 实验性Package diff computes line and character level differences between two versions of a text, the algorithm layer behind a diff editor.
ui/editor/diffview 实验性Package diffview is the diff editor of ui/editor: two editors side by side (or one inline view) showing the differences between an original and a modified text, computed by ui/editor/diff in the background.
ui/editor/highlight 实验性Package highlight runs Monarch tokenization incrementally for the code editor view: the UI thread tokenizes what is about to be drawn within a time budget (Highlight), and a background goroutine (Start) catches up on the rest of the document from immutable buffer snapshots.
ui/editor/keymap 实验性Package keymap parses keybinding text and resolves key events to commands, with VS Code's rule semantics.
ui/editor/langs 实验性Package langs embeds the built-in language data of the code editor: Monaco Monarch grammars, language configurations and file associations, plus the four Monaco base themes.
ui/editor/monarch 实验性Package monarch interprets Monaco Monarch grammars (JSON, as exported by ui/editor/langs) and tokenizes text line by line.
ui/editor/regex 实验性Package regex 编译 Monaco Monarch 语法中的 JavaScript 正则。
ui/editor/theme 实验性Package theme parses Monaco-format editor themes (IStandaloneThemeData: {base, inherit, rules, colors}) and resolves Monarch token types such as "keyword.go" or "string.escape.ts" to display styles.
ui/editor/when 实验性Package when parses and evaluates VS Code "when" clause expressions, the conditions keybindings and commands use to decide whether they apply ("editorTextFocus && !editorReadonly").
ui/geomPackage geom holds the small geometry vocabulary shared by every layer of the Tango self-drawn UI (layout, paint, text, input).
ui/graph 实验性Package graph holds the graph widgets of the Tango self-drawn UI: a node-link diagram canvas (Diagram), an entity-relationship preset built on it (ER) and a git commit graph (GitGraph).
ui/iconPackage icon draws vector UI icons (no icon font).
ui/icon/antd 实验性Package antd is the complete Ant Design icon set (@ant-design/icons-svg, MIT; see LICENSE) in its three themes: Outlined, Filled and TwoTone, named like @ant-design/icons (SearchOutlined, CheckCircleFilled, CheckCircleTwoTone):
ui/icon/element 实验性Package element is the complete Element Plus icon set (@element-plus/icons-svg, MIT; see LICENSE), 293 filled icons on a 1024-unit grid:
ui/icon/filetype 实验性Package filetype picks icons for files and folders, the way an IDE's file tree does: a file name resolves to a Kind (code, image, archive, …) by its exact name or extension, and a Set maps kinds to icons.
ui/icon/lucide 实验性Package lucide is the complete Lucide icon set (lucide-static, ISC; see LICENSE), the default icons of shadcn/ui: 24-unit grid, 2-unit round strokes.
ui/input 部分实验性Package input defines the events a platform host feeds into the Tango self-drawn UI (pointer, multi-touch, wheel, keyboard, committed text and IME composition), the cursor shapes the UI asks the host to show, and the focus/Tab-order bookkeeping shared by focusable widgets.
ui/layout 部分实验性Package layout holds the layout options of the Tango self-drawn UI: Row/Column/Stack containers take Options built here (Grow, W, H, Pad, Gap, Align, Justify, Abs ...), and Box.Style applies more.
ui/mobile 实验性Package mobile provides touch-first widgets for the Tango self-drawn UI in the visual language of Ant Design Mobile (default), Vant and a mobile derivation of shadcn/ui (Shadcn: chosen automatically under a theme.Shadcn ui theme; Drawer-style bottom sheets with a grab handle, grouped action sheet cards, Sonner toasts, segmented tabs): NavBar, TabBar, List/Cell, SwipeCell, PullToRefresh, InfiniteList, ActionSheet, Popup, Dialog, Toast, Picker (cascade, date/time), Stepper, SearchBar, Tabs, Swiper, Grid, NoticeBar, Skeleton, Empty, Result, Badge, Tag, Button, Form, IndexBar, FloatingBubble and SafeArea.
ui/paint 部分实验性Package paint is the display-list layer of the Tango self-drawn UI.
ui/terminal 实验性Package terminal is a terminal component: it connects a Conn, the program end of a terminal such as a pseudo-terminal, to the emulator in ui/terminal/vt.
ui/terminal/vt 实验性Package vt is the terminal emulator core of ui/terminal: it turns the bytes a program writes into screen state, and the keys and text the user types into the bytes the program reads.
ui/text 部分实验性Package text shapes and lays out text for the Tango self-drawn UI.
ui/theme 部分实验性Package theme defines the design tokens of the Tango self-drawn UI.
uihost 部分实验性Package uihost shows Tango's self-drawn UI (package ui) in native windows: it adapts a tango.App to the ui.Window contract and drives a ui.Runner from the backend's canvas callbacks.

以 MIT 许可发布