@contentful/experiences-sdk-core

中文文档
0.13.13发布于 2026/11/07MITTypeScriptESM + CJS零依赖近 30 天下载 5782

Runtime-neutral types + experience resolution for Contentful Experiences

原始使用文档
文档目录4 节
  1. What lives here
  2. Delivery diagnostics
  3. Why a separate package?
  4. License

@contentful/experiences-sdk-core

⚠️ Internal package. You don't install this directly — the framework adapter (e.g. @contentful/experiences-react) re-exports everything you need.

Dependency-free, runtime-neutral primitives shared across all framework adapters. This package has no runtime dependencies.

What lives here

  • Types — PortableRenderPlan, PortableRenderNode, PortableRegistration, ExperiencePayload, ExperienceNode, the discriminated DesignPropValue union (ManualDesignValue / DesignToken), ExperienceContext, ResolveContext.
  • resolveExperience(payload, config, opts) — single async entry that walks an XDA payload, classifies content vs. design properties, resolves design values and tokens, captures slots, runs any component-declared resolveData hooks in parallel, and emits a runtime-neutral PortableRenderPlan ready for any framework adapter to render. Every node in the payload becomes a PortableRenderNode; registration.kind records whether the adapter should resolve its id against config.components or config.experienceTemplates. A coded Experience Template is an ordinary node — payload.sys.experienceTemplate is never read.
  • Diagnostics and design support — createDebugLogger, resolveDesignProperties, and applyTokenResolver.

Delivery transport belongs to Client and event construction belongs to Runtime, keeping this package usable in any runtime without pulling in a delivery client or framework.

Delivery diagnostics

resolveExperience projects recognized payload.errors into the optional plan.deliveryDiagnostics: readonly ExperienceDeliveryDiagnostic[]. Each fresh record contains only readonly string fieldPath and message; input order is preserved, and originalError, extra fields, and input references are omitted. Missing, non-array, or unrecognized errors leave the field absent. The same normalization serves raw resolve calls and the existing Client/Runtime/leaf fetch paths, including destinations; Core imports no generated Delivery types.

These are upstream field-resolution diagnostics, distinct from the existing local plan.diagnostics: Error[]. They preserve renderable content and serialize as ordinary records. The projection is intentionally partial: absence never certifies personalization success or the absence of all upstream errors. Upstream strings may contain private information. Prefer a generic visitor warning/count, inspect fields explicitly for diagnosis, and exclude them from public bootstrap/handoff payloads and logs. The whitelist is not a privacy filter.

Why a separate package?

Future Angular, Svelte, Vue, SwiftUI, and Compose adapters consume the same plan. Sharing core means each adapter has zero plan-building or prop-classification logic to duplicate — the seam is the PortableRenderPlan contract.

See ../../AGENTS.md for the full architecture and design decisions.

License

MIT. See the repository LICENSE and NOTICE for full attribution.

版本与发布记录

@contentful/experiences-sdk-core 共发布 54 个版本,首次发布于 2026/07/21;过去 12 个月发布了 54 个版本。

版本发布日期距今
0.13.13latest2026/11/074 天前
0.13.122026/11/055 天前
0.13.112026/11/056 天前
0.13.102026/11/046 天前
0.13.92026/10/3111 天前
0.13.82026/10/3011 天前

关于 @contentful/experiences-sdk-core 的常见问题

@contentful/experiences-sdk-core 是什么?

Runtime-neutral types + experience resolution for Contentful Experiences

如何安装 @contentful/experiences-sdk-core?

在项目目录运行 npm install @contentful/experiences-sdk-core,或使用 pnpm add / yarn add / bun add。

@contentful/experiences-sdk-core 支持 TypeScript 吗?

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

@contentful/experiences-sdk-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@contentful/experiences-sdk-core 可以商用吗?

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

@contentful/experiences-sdk-core 的下载量有多少?

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

@contentful/experiences-sdk-core 还在维护吗?

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