@decocms/eitri

中文文档
7.85.2发布于 2026/11/10ES Module构建来源已验证近 30 天下载 5792

Deco binding for the Eitri mobile stack: produces a well-filled .deco (self-contained schema + decofile snapshot) so Studio can author content. No rendering — Eitri renders natively.

原始使用文档
文档目录7 节
  1. What Eitri owns vs. what deco owns
  2. Sections
  3. Install
  4. Setup
  5. Generate
  6. Programmatic API
  7. Flags

@decocms/eitri

Deco binding for the Eitri mobile stack. Unlike @decocms/nextjs / @decocms/tanstack, this package does not render anything — Eitri renders sections natively on its own mobile runtime. @decocms/eitri only produces a well-filled .deco so Studio can author content against your Eitri sections:

  • a self-contained .deco/meta.gen.json (section schemas plus the framework block types — Page, matchers, Resolvable, the section picker — baked in, so an FS-based Studio reads it verbatim with no runtime), and
  • the bundled .deco/blocks.gen.json decofile snapshot the Eitri runtime consumes.

It is a thin, Eitri-flavored wrapper over @decocms/blocks-cli's generate orchestrator (--platform eitri). See docs/eitri-stack-design.md for the full design.

What Eitri owns vs. what deco owns

Owner
Section Props → JSON Schema, decofile snapshot (.deco)@decocms/eitri (this package)
Authoring content (forms, page composition)Studio (reads .deco)
Fetching the decofile on-device + rendering sectionsEitri platform / your app

There is intentionally no runtime SDK here.

Sections

An Eitri section is exactly a deco section: a default-exported component in src/sections/** with an exported Props interface documented with JSDoc.

// src/sections/Banners/Hero.tsx
import { Image, View } from "eitri-luminus";

export interface Props {
  /** @title Hero image. */
  image: string;
  /** @title Alt text. */
  alt?: string;
  /** @title Publish date. @format datetime */
  datetime?: string;
}

export default function HeroBanner({ image, alt }: Props) {
  return <View><Image src={image} alt={alt} /></View>;
}

@title, @format (e.g. textarea, datetime → normalized to date-time), and the other JSDoc widget tags drive the Studio form. Sections may be .tsx, .ts, .jsx, or .js.

Install

# in your Eitri app (as a dev tool)
npm i -D @decocms/eitri

Setup

npx deco-eitri init

This scaffolds (never overwriting existing files):

  • tsconfig.json extending @decocms/eitri/tsconfig — required; generate-schema needs a tsconfig to parse your Props types.
  • src/eitri-env.d.ts — ambient shims for eitri-luminus / eitri-bifrost so your editor and tsc don't flag those imports. Purely ergonomic; generation works without it. Delete it if you install the real eitri-luminus types.

If you prefer to wire it by hand, your tsconfig.json need only be:

{ "extends": "@decocms/eitri/tsconfig", "include": ["src"] }

Generate

# from the app root
npx deco-eitri generate

# or, targeting a sub-app in a monorepo without cd:
npx deco-eitri generate --root eitri-shopping-example-shared

Add it as a script:

{ "scripts": { "deco:generate": "deco-eitri generate" } }

Output under .deco/:

  • meta.gen.json — self-contained schema (framework: "eitri").
  • blocks.gen.json — decofile snapshot (starts as {} for a fresh app; Studio fills it as content is authored).
  • generate.digests.json — the incremental-generation cache (commit it).

The React-runtime artifacts (sections.gen.ts, blocksManifest.gen.ts, loaders.gen.ts, invoke.gen.ts) are intentionally not produced — Eitri doesn't use them.

Programmatic API

import { generateEitri } from "@decocms/eitri";

const code = await generateEitri({ root: "path/to/app", force: true });

Flags

deco-eitri generate forwards every @decocms/blocks-cli generate flag (--root, --force, --dry-run, --sections-dir, --namespace, --site, …). Run npx deco-eitri generate --help for the full list. --platform eitri is always applied.

版本与发布记录

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

版本发布日期距今
7.85.2latest2026/11/102 天前
7.85.12026/11/075 天前
7.85.02026/11/075 天前
7.84.12026/11/075 天前
7.84.02026/11/075 天前
7.83.22026/11/075 天前

关于 @decocms/eitri 的常见问题

@decocms/eitri 是什么?

Deco binding for the Eitri mobile stack: produces a well-filled .deco (self-contained schema + decofile snapshot) so Studio can author content. No rendering — Eitri renders natively.

如何安装 @decocms/eitri?

在项目目录运行 npm install @decocms/eitri,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 deco-eitri,可以用 npx deco-eitri 直接运行。

@decocms/eitri 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/decocms__eitri 是否存在。

@decocms/eitri 支持 ESM 还是 CommonJS?

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

@decocms/eitri 可以商用吗?

@decocms/eitri 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@decocms/eitri 的下载量有多少?

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

@decocms/eitri 还在维护吗?

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