@camunda/feel-playground

中文文档
1.1.1发布于 2026/10/30MITTypeScriptES Module近 30 天下载 9126

Playground for editing and evaluating FEEL expressions

原始使用文档
文档目录5 节
  1. Features
  2. Usage
  3. API
  4. FeelPlayground
  5. Run locally with c8run

@camunda/feel-playground

CI

A React component for editing and remotely evaluating FEEL expressions with a JSON context.

Features

  • FEEL expression and unary-tests editing
  • Autocomplete and diagnostics
  • JSON context editing and prefill
  • Detection and completion of missing context variables
  • Remote evaluation with result, warning, loading, and error states
  • Host-provided variables and FEEL language configuration

Usage

Import the component and its stylesheet:

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

PropTypeRequiredDescription
expressionstringYesCurrent FEEL expression or unary tests.
onExpressionChange(expression: string) => voidYesCalled when the expression changes.
contextstringNoSerialized JSON evaluation context. Omit to prefill it from the initial expression.
onContextChange(context: string) => voidYesCalled when the context changes.
dialect'expression' | 'unaryTests'YesFEEL syntax accepted by the editor.
feelLanguageContextFeelLanguageContextNoBuilt-ins, parser dialect, and engine compatibility configuration.
variablesFeelVariable[]NoVariables available for autocomplete and context generation.
onEvaluateEvaluateNoEvaluates the expression remotely.
evaluationUnavailablestring | EvaluationUnavailableNoExplains why evaluation is unavailable when no evaluator is provided. Supports a title, message, and optional action.

When onEvaluate is absent, evaluationUnavailable accepts plain text or { title, message, action?: { label, onClick } }. The optional action renders after the message and calls the host's onClick handler. Omitting the prop shows "Evaluation is unavailable."

The package is distributed as ESM and requires React 19 and Camunda Design System 0.76 or newer. Evaluation, authentication, and connectivity are provided by the host.

Run locally with c8run

Start a Camunda 8.9+ c8run instance on http://localhost:8080, then:

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

Open the URL printed by Vite. The example configuration uses c8run Basic authentication with username demo and password demo.

The Unavailable preview showcases the title, message, and action API. Click Use demo connection to switch to a simulated successful evaluation, without a running cluster.

版本与发布记录

@camunda/feel-playground 共发布 12 个版本,首次发布于 2026/08/31;过去 12 个月发布了 12 个版本。

版本发布日期距今
1.1.1latest2026/10/309 天前
1.1.02026/10/309 天前
1.0.32026/10/2118 天前
1.0.22026/10/1525 天前
1.0.12026/10/0930 天前
1.0.02026/09/101 个月前

其他发布通道:alpha → 1.0.0-alpha.3。

关于 @camunda/feel-playground 的常见问题

@camunda/feel-playground 是什么?

Playground for editing and evaluating FEEL expressions

如何安装 @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 和提交记录判断。