@astrato-io/app-runtime

中文文档
0.5.0发布于 2026/11/06SEE LICENSE IN LICENSETypeScriptES Module近 30 天下载 1.6万

Browser runtime for Astrato Apps. It creates an Astrato SDK client using the app's authorized context. See the runtime reference for the public API.

原始使用文档
文档目录3 节
  1. Create and destroy the runtime
  2. Runtime boundaries
  3. Publication changes

Astrato App runtime

Browser runtime for Astrato Apps. It creates an Astrato SDK client using the app's authorized context. See the runtime reference for the public API.

npm install @astrato-io/app-runtime

Follow the installation instructions for package access available to your organization. @astrato-io/sdk is an ordinary production dependency installed by npm; applications importing the SDK directly must use a compatible version. This runtime requires SDK ^0.6.0. Preview bootstrap and the runtime must resolve to the same SDK module so they share the established iframe connection.

Create and destroy the runtime

import { createAstratoApp } from '@astrato-io/app-runtime';

const app = await createAstratoApp();
// Use app.client and app.dataBinding with the SDK and visualization packages.
// Release the runtime when the app is unmounted.
app.destroy();

Retain one runtime across charts. Reload after semantic model changes to refresh metadata; query results are not cached by this package.

The package is ESM-only and browser-only. Run it at the origin printed by astrato dev, an Astrato App preview with an established host connection, or an enabled hosted publication URL. It cannot bootstrap from a raw Vite origin or server-side rendering.

The factory accepts an optional abort signal, bootstrap timeoutMs, and explicit runtime selection (publication, local or preview). An explicitly selected preview requires an established host connection and does not fall back to HTTP bootstrap. Application code supplies no account token, tenant ID, semantic-layer ID or custom transport; the hosting boundary establishes those values.

Runtime boundaries

Hosted apps use governed direct data-node access. Expired or replaced publication sessions require reload. Preview data access is read-only. Procedure execution and row writeback are available only in local development under the caller's existing permissions; hosted and preview apps reject them. See local write methods.

Publication changes

Hosted publications automatically reload after a confirmed version change, with a per-tab loop guard. Register onPublicationChanged in createAstratoApp() to save app state before navigation or return false to defer and call the event's reload() after a user decision. Async callbacks are awaited; a failed callback or blocked automatic reload falls back to a manual prompt. The hook can run during bootstrap before the factory resolves. It does not run in local development, previews or SDK-only apps.

See the hook reference, persistence and confirmation examples for the complete contract, loop guard and package availability. Published versions 0.2.1 and earlier do not include this behavior; existing apps require an updated runtime, rebuild and republish.

Externally hosted apps that authenticate and host themselves, and Workbooks created in the Workbook Editor, do not need this package.

版本与发布记录

@astrato-io/app-runtime 共发布 5 个版本,首次发布于 2026/10/20;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.5.0latest2026/11/061 天前
0.4.02026/10/299 天前
0.3.12026/10/2711 天前
0.2.12026/10/2018 天前
0.0.0-stage2026/10/2018 天前

关于 @astrato-io/app-runtime 的常见问题

@astrato-io/app-runtime 是什么?

Browser runtime for Astrato Apps. It creates an Astrato SDK client using the app's authorized context. See the runtime reference for the public API.

如何安装 @astrato-io/app-runtime?

在项目目录运行 npm install @astrato-io/app-runtime,或使用 pnpm add / yarn add / bun add。

@astrato-io/app-runtime 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@astrato-io/app-runtime 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@astrato-io/app-runtime 可以商用吗?

@astrato-io/app-runtime 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@astrato-io/app-runtime 的下载量有多少?

根据 npm 官方下载统计,@astrato-io/app-runtime 在 2026/10/07 – 2026/11/05 这 30 天内被下载 15,700 次,日均约 523 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@astrato-io/app-runtime 还在维护吗?

最新版本 0.5.0 发布于 2026/11/06(1 天前);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/10/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。