@morphql/language-definitions

中文文档
0.1.47发布于 2026/11/02MITTypeScriptESM + CJS零依赖构建来源已验证

Shared language definitions for MorphQL across VSCode, Monaco, and documentation

原始使用文档
文档目录6 节
  1. Purpose
  2. Installation
  3. Basic Usage
  4. Maintenance
  5. Learn More
  6. License

MorphQL

npm version License: MIT

@morphql/language-definitions

The single source of truth for MorphQL language definitions (keywords, functions, operators) across all platforms. This package ensures consistency between the engine, IDE extensions, and documentation.

Purpose

This shared package centralizes the MorphQL grammar for reuse in:

  • VSCode Extension: TextMate grammar and hover providers.
  • Monaco Editor (Playground): Language configuration and Monarch tokens.
  • Documentation: Automatic generation of function and keyword references.
  • Type Safety: TypeScript interfaces for language features.

Installation

npm install @morphql/language-definitions

Basic Usage

import {
  KEYWORDS,
  FUNCTIONS,
  getKeywordNames,
  getFunctionNames,
} from "@morphql/language-definitions";

// Get all keyword names for a lexer
const keywords = getKeywordNames();

// Get documentation for hover providers
import { getKeywordDoc } from "@morphql/language-definitions";
const doc = getKeywordDoc("set");
// { signature: "set <target> = <expression>", description: "..." }

Maintenance

To add a new language feature (keyword, function, or operator), you should:

  1. Update the appropriate file in src/ (e.g., src/functions.ts).
  2. Run npm run build.
  3. Changes will propagate to the VS Code extension and Playground on their next build.

Learn More

License

MIT

版本与发布记录

@morphql/language-definitions 共发布 44 个版本,首次发布于 2026/01/25;过去 12 个月发布了 44 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.47latest2026/11/021 天前
0.1.462026/07/283 个月前
0.1.452026/05/275 个月前
0.1.442026/05/275 个月前
0.1.432026/05/215 个月前
0.1.422026/05/195 个月前

关于 @morphql/language-definitions 的常见问题

@morphql/language-definitions 是什么?

在VSCode、Monaco和文档中共享MorphQL的语言定义

如何安装 @morphql/language-definitions?

在项目目录运行 npm install @morphql/language-definitions,或使用 pnpm add / yarn add / bun add。

@morphql/language-definitions 支持 TypeScript 吗?

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

@morphql/language-definitions 支持 ESM 还是 CommonJS?

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

@morphql/language-definitions 可以商用吗?

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

@morphql/language-definitions 还在维护吗?

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