@adyen/adyen-shared-web

中文文档
0.4.3发布于 2026/10/30MITES Module近 30 天下载 5131
原始使用文档

adyen-shared-web

Shared utilities for the Adyen npm libraries.

Usage

Install the package and create a ThemeGenerator to generate and inject semantic CSS color variables for your application:

import { ThemeGenerator } from "@adyen/adyen-shared-web";

const themeGenerator = new ThemeGenerator();

themeGenerator.create({
  primary: "#0066ff",
  background: "#ffffff",
  neutral: "#f2f4f7",
  label: "#101828",
  outline: "#98a2b3",
  roundness: "medium",
});

Set roundness to "small", "medium", or "large" to apply a 4px, 8px, or 12px radius to Bento's xs through xl radius tokens. Pass dark: true when generating a dark theme. Call themeGenerator.destroy() when the theme is no longer needed to remove the generated styles.

To generate CSS without accessing or modifying the DOM, use generateCSS(). It targets :root by default and accepts a custom selector for scoped themes:

const css = themeGenerator.generateCSS(
  {
    primary: "#0066ff",
    dark: true,
  },
  {
    selector: "[data-adyen-pe-theme-root='core-id']",
  },
);

generateCSS() returns null when no supplied theme input produces CSS variables.

Publishing a new release on npm

  1. Tag the main branch with the new semantic version: git tag vX.Y.Z and git push origin vX.Y.Z
  2. Create a new release on GitHub (GitHub will automatically populate this with a changelog based on merged PRs).
  3. (Optional) If you want this to be a pre-release, check the "Set as pre-release" option.
  4. Publish the release!

Staged publishing is intentionally disabled at the moment.

版本与发布记录

@adyen/adyen-shared-web 共发布 6 个版本,首次发布于 2026/08/03;过去 12 个月发布了 6 个版本。

版本发布日期距今
0.4.3latest2026/10/306 天前
0.4.02026/09/171 个月前
0.3.02026/09/081 个月前
0.2.02026/08/053 个月前
0.1.42026/08/033 个月前
0.0.02026/08/033 个月前

关于 @adyen/adyen-shared-web 的常见问题

如何安装 @adyen/adyen-shared-web?

在项目目录运行 npm install @adyen/adyen-shared-web,或使用 pnpm add / yarn add / bun add。

@adyen/adyen-shared-web 支持 TypeScript 吗?

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

@adyen/adyen-shared-web 支持 ESM 还是 CommonJS?

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

@adyen/adyen-shared-web 需要什么版本的 Node.js?

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

@adyen/adyen-shared-web 可以商用吗?

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

@adyen/adyen-shared-web 的下载量有多少?

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

@adyen/adyen-shared-web 还在维护吗?

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