@genrojs/builders

中文文档
0.7.0发布于 2026/10/20Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 4246

Grammar-driven builders: typed Source trees from JSON grammars, for any dialect, with pluggable renderers.

原始使用文档
文档目录3 节
  1. Install and verify
  2. Documentation
  3. Explicit pointer suffixes and raw HTML

genro-builders-js

Build typed Source trees from JSON grammars and render static HTML, SVG or XML. The generic renderer also supports dialect-defined object output. This package has no DOM, browser subscriptions, server or database dependencies.

Version 0.7.0 targets npm and JSR with the Bag 0.11 contract. Python parity is bounded by documented differences. Recipes are not implemented. A builder declares the SourceBag class of its Source in static _sourceClass (Source class).

import { HtmlBuilder } from '@genro/builders';

const page = new HtmlBuilder();
page.data.setItem('price', 1234.5);
const body = page.root.html().body();
body.h1('Hello');
body.div('^price', {format: '#,##0.00', locale: 'it-IT', mask: '€ %s'});
const html = page.render();

Install and verify

The same package is published on two registries:

  • npm: npm install @genrojs/builders, then import from @genrojs/builders;
  • JSR: npx jsr add @genro/builders (or bunx jsr add), then import from @genro/builders.

From a local checkout, run npm install --no-package-lock and npm test. Node.js 22 or later and Bun are the supported server runtimes. First-party npm dependencies use verified minimum versions without upper bounds. JSR imports use verified caret ranges as an owner-approved JSR-only exception: publication rejects both >= and wildcard constraints. Setup and CI resolve current releases without a lockfile; use npm update --no-package-lock to refresh an existing installation. Bag 0.11.0 provides recursive population and the current Python/JavaScript TYTX format. Consumers must resolve one shared Bag class and TYTX registry; an older nested Bag copy cannot share the same suffix. The source imports Bag and TYTX as @genrojs/bag and @genrojs/tytx, the npm names; jsr.json maps them to jsr:@genro/bag and jsr:@genro/tytx. Each registry's package therefore depends on one Bag class and one TYTX registry instance from the same registry.

Deno publication keeps a 24-hour cooldown for external dependencies and exempts jsr:@genro/* and npm:@genrojs/* to permit verified sequential releases.

Documentation

Build the Sphinx manual locally:

python -m pip install -r docs/requirements.txt
python -m sphinx -W --keep-going -n -b html docs build/docs

The manual uses the classic Read the Docs theme. No hosting is configured or implied. See CHANGELOG for the local version change.

Copyright 2025–2026 Softwell S.r.l. Apache-2.0; see LICENSE and NOTICE.

Explicit pointer suffixes and raw HTML

Attributes use explicit ^path:{}px templates or ^path:=!{} expressions. Ordinary ${name} text remains literal and consumes no helper attributes. Static expressions return null; a consuming runtime supplies its compiler hook.

Node values never interpolate template tokens; Data pointers and resolvers still resolve normally. This preserves JavaScript template literals in script content.

For HTML output, a node value ending in ::HTML emits raw markup and drops the suffix. Ordinary text remains escaped. This marker does not enable templates, does not sanitize markup and does not change attribute escaping. For example, <b>${name}</b>::HTML emits <b>${name}</b> literally.

See the pointer suffix and dtype migration guide.

版本与发布记录

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

版本发布日期距今
0.7.0latest2026/10/2026 天前
0.6.02026/10/1729 天前
0.5.22026/10/151 个月前
0.5.12026/10/151 个月前
0.5.02026/10/131 个月前
0.4.22026/10/041 个月前

关于 @genrojs/builders 的常见问题

@genrojs/builders 是什么?

Grammar-driven builders: typed Source trees from JSON grammars, for any dialect, with pluggable renderers.

如何安装 @genrojs/builders?

在项目目录运行 npm install @genrojs/builders,或使用 pnpm add / yarn add / bun add。

@genrojs/builders 支持 TypeScript 吗?

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

@genrojs/builders 支持 ESM 还是 CommonJS?

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

@genrojs/builders 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@genrojs/builders 可以商用吗?

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

@genrojs/builders 的下载量有多少?

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

@genrojs/builders 还在维护吗?

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