@aglyn/aglyn

中文文档
1.19.0发布于 2026/11/07Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 1.7万

The core of Aglyn: the platform's data model (hosts, screens, layouts, node trees), the runtime managers that hold components, plugins and the canvas, and the framework-independent utilities the rest of the @aglyn packages are built on. Install it if yo

原始使用文档
文档目录5 节
  1. Install
  2. What's in it
  3. Usage
  4. How it fits
  5. License

@aglyn/aglyn

The core of Aglyn: the platform's data model (hosts, screens, layouts, node trees), the runtime managers that hold components, plugins and the canvas, and the framework-independent utilities the rest of the @aglyn packages are built on. Install it if you are building on Aglyn's model: a renderer, an editor, a plugin, or a tool that reads and writes Aglyn documents.

Published to npm from the Aglyn monorepo. Versions follow semantic versioning.

Install

npm install @aglyn/aglyn

Peer dependencies:

  • react is required.
  • next, firebase, @mui/material and @mui/system are declared optional (peerDependenciesMeta). The package installs and bundles with only react. Bring the optional ones only for the modules that use them:
    • @mui/material for the consent UI modules (@aglyn/aglyn/app-utils/consent-banner-ui, @aglyn/aglyn/app-utils/consent-preferences-dialog); @mui/material and @mui/system also supply types that some node and component type definitions refer to.
    • next for @aglyn/aglyn/app-utils/advertising-tag-mounts, which uses next/script.
    • firebase is declared for apps that pair the model with Firebase, as Aglyn's own apps do. No module in this package needs it to load.

This is the "logic only" consumer story: @aglyn/aglyn together with @aglyn/besigner installs with react as the only peer, and needs no UI library, no next, and no Firebase SDK.

What's in it

Entry points:

  • @aglyn/aglyn is the full barrel, for client code.
  • @aglyn/aglyn/server is the server-safe barrel. It re-exports the same model, managers and pure utilities without the client React contexts, so it can be imported from React Server Components. It also carries the modules that use Node built-ins or a JavaScript parser and are therefore kept out of the client barrel: the Web-to-(req, res) API adapter, API idempotency, the person key, the plugin bundle checks, and the server side of realm plugins.
  • @aglyn/aglyn/* maps to a file under src/lib, for example @aglyn/aglyn/aglyn or @aglyn/aglyn/app-utils/markdown-lite. A subpath names a file, not a folder. Importing by subpath keeps a bundle to what it uses.

Main areas under src/lib:

  • aglyn is the runtime singleton. It exports aglyn and its parts: emitter, plugins, components, canvas and logger. The instance is keyed on globalThis, so duplicate module copies in one JavaScript realm share one runtime.
  • types holds the node and screen model: NodeSchema, NodesMap, ComponentSchema, PresetSchema, ScreenSchema, routing and AST types.
  • foundation holds the platform document types (AglynHost, AglynScreen, AglynLayout, AglynHostTheme, organization and billing shapes, and their id types) and shared constants.
  • emit-manager is EmitManager (an eventemitter2 emitter) and the AglynEvent enum of lifecycle and action events.
  • components-manager is ComponentManager, the registry of component factories, their schemas, and presets.
  • plugin-manager is PluginManager (plugin registration and dependency status) plus the plugin seams: the plugin loader (createPluginLoader), contributions, configuration, permissions, entitlements, events, services and jobs. Aglyn's feature plugins attach to the platform through these.
  • canvas-manager is CanvasManager, the observable node tree: set, create, delete, duplicate, reparent and reorder nodes, with undo and redo history.
  • app-utils is a large set of pure helpers over the model: node composition and sanitizing, binding tokens and variables, datasets and collections, SEO and sitemap helpers, the markdown-lite dialect, permissions and roles, consent, analytics keys, media references, and more. Its React contexts (site context, media picker, enabled plugins and others) are exported from the client barrel only.
  • utils has the feature-flag predicates such as isFeatureEnabled.

Usage

import { AglynEvent, canvas, components, emitter } from '@aglyn/aglyn'

emitter.on(AglynEvent.COMPONENT_REGISTERED, ({ $id }) => {
  console.log('registered', $id)
})

components.registerComponent(MyBox, {
  $id: 'my-box',
  pluginId: 'my-plugin',
  displayName: 'My box',
})

components.getSchema('my-box')

// `nodes` is a NodesMap: node id -> NodeSchema
canvas.setNodes(nodes)
const root = canvas.rootNode

From a Server Component or other server code:

import type { AglynScreen, NodeSchema } from '@aglyn/aglyn/server'

How it fits

@aglyn/aglyn is the core scope of the package map. It imports only itself and the generic @aglyn/shared-* packages. It holds no rendering, no designer, no tenancy and no plugin: the core never imports a plugin, and a plugin's domain lives in that plugin. Everything else stands on it: @aglyn/aglyn-node-renderer turns its node trees into React, @aglyn/besigner and @aglyn/besigner-ui edit them, the @aglyn/tenant-* packages serve them, and every @aglyn/plugins-* package registers into its managers.

License

Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/aglyn

版本与发布记录

@aglyn/aglyn 共发布 161 个版本,首次发布于 2026/09/21;过去 12 个月发布了 161 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.19.0latest2026/11/07今天
1.18.02026/11/07今天
1.17.02026/11/07今天
1.16.02026/11/07今天
1.15.22026/11/061 天前
1.15.12026/11/061 天前

其他发布通道:beta → 1.0.0-beta.296。

关于 @aglyn/aglyn 的常见问题

@aglyn/aglyn 是什么?

The core of Aglyn: the platform's data model (hosts, screens, layouts, node trees), the runtime managers that hold components, plugins and the canvas, and the framework-independent utilities the rest of the @aglyn packages are built on. Install it if yo

如何安装 @aglyn/aglyn?

在项目目录运行 npm install @aglyn/aglyn,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.2.8)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aglyn/aglyn 支持 TypeScript 吗?

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

@aglyn/aglyn 支持 ESM 还是 CommonJS?

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

@aglyn/aglyn 可以商用吗?

@aglyn/aglyn 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aglyn/aglyn 的下载量有多少?

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

@aglyn/aglyn 还在维护吗?

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