# @camunda/feel-playground 中文文档

规范地址：https://npmcn.com/package/%40camunda/feel-playground/

版本：1\.1\.1
npm 元数据更新时间：2026-10-30T15:26:15.965Z
中文译文更新时间：2026-11-09T00:51:29.300Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40camunda/feel-playground
原文对照：https://npmcn.com/package/%40camunda/feel-playground/?lang=original
项目主页：https://github.com/camunda/feel-playground#readme
源码仓库：https://github.com/camunda/feel-playground

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：182 kB，6 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=24\.15\.0
- 运行依赖：9 个
- peer 依赖：react \>=19\.0\.0 \<20，react-dom \>=19\.0\.0 \<20，@camunda/design-system \>=0\.76\.0
- 首次发布：2026-08-31T13:21:03.517Z
- 最新版本发布：2026-10-30T13:44:23.020Z
- 近 30 天下载量：9126（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：12（近 12 个月 12 个）

## 中文简介

编辑和评价感觉表达式的游戏场

## 安装

```sh
npm install @camunda/feel-playground
```

也可以使用：`pnpm add @camunda/feel-playground`、`yarn add @camunda/feel-playground`、`bun add @camunda/feel-playground`

## README

# @camunda/ feel-游戏场

[![CI](https://github.com/camunda/feel-playground/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/camunda/feel-playground/actions/workflows/CI.yml)

用于编辑和远程评价带有JSON语境的感受表达式的反应组件.

## 特征

-   感觉表达式和无线测试编辑
-   自动完成和诊断
-   JSON 上下文编辑和预填
-   检测并完成缺失上下文变量
-   远程评价,结果、警告、装入和出错状态
-   主机提供的变量和感觉语言配置

## 使用量

导入组件及其样式表 :

```tsx
import { useState } from 'react';

import {
  FeelPlayground,
  type Evaluate
} from '@camunda/feel-playground';
import '@camunda/design-system/styles.css';
import '@camunda/feel-playground/style.css';

const evaluate: Evaluate = async (input, { signal }) => {
  const response = await fetch('/api/evaluate', {
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    },
    body: JSON.stringify(input),
    signal
  });

  const { result, warnings = [] } = await response.json();

  return { result, warnings };
};

export function Playground() {
  const [expression, setExpression] = useState('x + y');
  const [context, setContext] = useState<string>();

  return <FeelPlayground
    expression={expression}
    onExpressionChange={setExpression}
    context={context}
    onContextChange={setContext}
    dialect="expression"
    variables={[ { name: 'x' }, { name: 'y' } ]}
    onEvaluate={evaluate}
  />;
}
```

## API 密码

### `FeelPlayground`

| Prop | 类型 | 需求 | 说明 |
| --- | --- | --- | --- |
| `expression` | `string` | 对 | 当前感觉表达式或无常测试. |
| `onExpressionChange` | `(expression: string) => void` | 对 | 当表达式改变时调用 . |
| `context` | `string` | 没有 | 串行JSON评价上下文. 关闭从初始表达式预填. |
| `onContextChange` | `(context: string) => void` | 对 | 上下文变化时调用 . |
| `dialect` | `'expression' | 'unaryTests'` | 对 | 被编辑接受的感觉语法. |
| `feelLanguageContext` | `FeelLanguageContext` | 没有 | 内置,剖析方言,和引擎相容配置. |
| `variables` | `FeelVariable[]` | 没有 | 用于自动完整和上下文生成的变量 . |
| `onEvaluate` | `Evaluate` | 没有 | 远程评价表达式. |
| `evaluationUnavailable` | `string | EvaluationUnavailable` | 没有 | 解释为何在未提供评价人员的情况下无法进行评价。 支持标题、消息和可选动作. |

何时 `onEvaluate` 缺席, `evaluationUnavailable` 接受纯文本或 `{ title, message, action?: { label, onClick } }`可选行动使 留言后,给主机打电话 `onClick` 处理者。 显示道具 "评价是没有根据的"

该套件作为无害环境管理分发,并需要React 19和Camunda Design System 0.76或更新. 评价、认证和连通性由东道方提供.

## 用 C8run 本地运行

启动 Camunda 8.9+ c8run 实例 `http://localhost:8080`,则:

```sh
git clone https://github.com/camunda/feel-playground.git
cd feel-playground
cp cluster.config.example.json cluster.config.json
npm install
npm start
```

打开由 Vite 打印的 URL 。 示例配置使用 c8run 基本认证, 并使用用户名 `demo` 密码 `demo`。 。 。 .

这个 **无法获取** 预览显示标题、消息和动作 API. 点击 **使用演示连接** 切换到模拟成功评价, 没有运行中的集群.

## 常见问题

### @camunda/feel-playground 是什么？

编辑和评价感觉表达式的游戏场

### 如何安装 @camunda/feel-playground？

在项目目录运行 npm install @camunda/feel-playground，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\>=19\.0\.0 \<20）、react-dom（\>=19\.0\.0 \<20）、@camunda/design-system（\>=0\.76\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @camunda/feel-playground 支持 TypeScript 吗？

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

### @camunda/feel-playground 支持 ESM 还是 CommonJS？

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

### @camunda/feel-playground 需要什么版本的 Node\.js？

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

### @camunda/feel-playground 可以商用吗？

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

### @camunda/feel-playground 的下载量有多少？

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

### @camunda/feel-playground 还在维护吗？

最新版本 1\.1\.1 发布于 2026/10/30（9 天前）；至今共发布 12 个版本，其中过去 12 个月发布了 12 个；首次发布于 2026/08/31。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

