@4242labs/design-system

中文文档
2.4.16发布于 2026/10/03MITTypeScriptES Module近 30 天下载 2836

The 42labs Design System — tokens, primitives and the portable compliance check.

原始使用文档
文档目录9 节
  1. Install
  2. Tokens
  3. Components
  4. Compliance check
  5. Rehearsing an unpublished build
  6. The one escape
  7. Programmatic
  8. Versioning
  9. Licence

@4242labs/design-system

The 42labs Design System as an installable package: the tokens, the 29 registry primitives, and the portable compliance check that every consuming project runs in CI.

The canonical reference is https://ds.42labs.io. This package is generated from that repository's own sources at build time — it is not a second copy, and it cannot drift from what the registry serves.

Install

npm install @4242labs/[email protected]

Pin the exact version. The compliance check fails a range: a range lets an install move off the pin with no change in the consuming project, which is the one thing the pin is for.

Tokens

@import "@4242labs/design-system/tokens.css";

tokens.css is byte-identical to the published tokens.v<version>.css. Projects using Tailwind also import the bridge:

@import "@4242labs/design-system/tailwind.css";

Both are declared side effects, so a bundler will not tree-shake them away.

Components

Every export is explicit; there is no wildcard and no root export.

import { Button } from "@4242labs/design-system/components/button";
import { cn } from "@4242labs/design-system/utils";
import { useIsMobile } from "@4242labs/design-system/hooks/use-mobile";

React and Tailwind are optional peers. A project consuming tokens as plain CSS — no React, no Tailwind — installs cleanly and pulls in neither.

Compliance check

npx --package=@4242labs/[email protected] -- \
  42labs-ds-check --scan "src" --expect "2.4.5"

The checker version and the token pin are separate values. A defective checker is rolled back by moving the npx specifier back one patch; --expect does not move, so the pin does not move and no retrofit is triggered.

It asserts:

GateFails on
packagemanifest pin, lockfile entry and installed version disagreeing, a range instead of an exact version, a lockfile resolved anywhere but the public registry, or missing sha512 integrity
vendored-copya second copy of the package's tokens.css or tailwind.css anywhere in the tree, or no stylesheet importing them
1a raw colour — hex, rgb(), hsl(), or a Tailwind palette class
2an arbitrary design value that is not a token reference
3a bespoke primitive where an adopted one exists

Scanned extensions: .ts, .tsx, .js, .jsx, .mjs, .cjs, .css, .html.

The package gate only runs when the consuming project declares this package.

Gates 1 to 3 are own-code gates, so adopted registry primitives are exempt. --ui-dir names where they live and defaults to src/components/ui; pass --ui-dir "" to scan everything.

Rehearsing an unpublished build

42labs-ds-check --scan src --expect 2.4.5 \
  --tarball ./4242labs-design-system-2.4.5.tgz --sha256 <hex>

Rehearsal mode verifies the tarball's hash, name and version against a file: install. It claims nothing about registry integrity, because there is not yet anything published to claim it of.

The one escape

// drift-allow(2026-12-31): upstream widget ships this hex and we do not control it
const brand = "#ff6600";

It expires, and the reason must be at least twelve characters. An expired marker fails. A malformed one fails. Every live marker is reported in the output and in the fleet's nightly report, so an exception is visible rather than forgotten.

Programmatic

import { checkConsumer } from "@4242labs/design-system/check";

const { ok, findings, driftAllows } = await checkConsumer({
  cwd: process.cwd(),
  scan: ["src"],
  expectedVersion: "2.4.5",
});

checkConsumer makes no network call, writes nothing, and never calls process.exit.

Versioning

One SemVer stream, shared with the design system itself. CHANGELOG.md in the repository is the source of truth. Removing or renaming an export requires a dated operator amendment.

Licence

MIT. See THIRD_PARTY_NOTICES for the upstream primitives this system re-themes.

版本与发布记录

@4242labs/design-system 共发布 11 个版本,首次发布于 2026/09/20;过去 12 个月发布了 11 个版本。

版本发布日期距今
2.4.16latest2026/10/031 个月前
2.4.142026/09/281 个月前
2.4.132026/09/281 个月前
2.4.122026/09/281 个月前
2.4.112026/09/281 个月前
2.4.102026/09/221 个月前

关于 @4242labs/design-system 的常见问题

@4242labs/design-system 是什么?

The 42labs Design System — tokens, primitives and the portable compliance check.

如何安装 @4242labs/design-system?

在项目目录运行 npm install @4242labs/design-system,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 42labs-ds-check,可以用 npx 42labs-ds-check 直接运行。

@4242labs/design-system 支持 TypeScript 吗?

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

@4242labs/design-system 支持 ESM 还是 CommonJS?

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

@4242labs/design-system 需要什么版本的 Node.js?

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

@4242labs/design-system 可以商用吗?

@4242labs/design-system 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@4242labs/design-system 的下载量有多少?

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

@4242labs/design-system 还在维护吗?

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