# @directededges/specs-from-figma 中文文档

规范地址：https://npmcn.com/package/%40directededges/specs-from-figma/

版本：0\.38\.0
npm 元数据更新时间：2026-10-29T18:08:37.683Z
中文译文更新时间：2026-11-12T10:45:12.303Z
软件包许可：PolyForm-Internal-Use-1\.0\.0

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

原始 npm 页面：https://www.npmjs.com/package/%40directededges/specs-from-figma
原文对照：https://npmcn.com/package/%40directededges/specs-from-figma/?lang=original
项目主页：https://github.com/DirectedEdges/specs-transforms#readme
源码仓库：https://github.com/DirectedEdges/specs-transforms

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

- 包体积（解压后）：802 kB，5 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：3 个
- 首次发布：2026-04-06T01:07:55.139Z
- 最新版本发布：2026-10-29T18:08:37.520Z
- 近 30 天下载量：20141（2026-10-13 至 2026-11-11，npm 官方下载统计）
- 已发布版本数：31（近 12 个月 31 个）

## 中文简介

光谱设计规格工具的核心数据转换模型

## 安装

```sh
npm install @directededges/specs-from-figma
```

也可以使用：`pnpm add @directededges/specs-from-figma`、`yarn add @directededges/specs-from-figma`、`bun add @directededges/specs-from-figma`

## README

# @ directededges/ specs- from-figma (英语)

**(原始内容存档于2017-10-21). Figma – spec.** Spectacular设计规格工具的核心数据转换模型:将原始的Figma设计数据转换为结构化的,决定性的组件规格(YAML/JSON). 跨越CLI,MCP,和插件环境使用.

## 概览

`@directededges/specs-from-figma` 规定:

-   **构成部分处理**: 将图像设计组件转化为结构化规格
-   **运行时间摘要**: 平台不可知数据加载和节点分辨率
-   **跨平台支持**: 在Node.js(CLI/MCP)和浏览器(Figma插件)环境中工作

## 安装

```bash
npm install @directededges/specs-from-figma
```

## 使用量

### 插件环境

```typescript
import { Component } from '@directededges/specs-from-figma';

const component = await Component.fromPlugin(figmaNode, config);
console.log(component.yaml());
```

可选 `coordinator` 财务报告和审定财务报表 `author` 可以作为第三个论点通过.

### CLI / REST API 环境

```typescript
import { Component } from '@directededges/specs-from-figma';
import type { StylesMap, VariablesMap, CollectionsMap } from '@directededges/specs-from-figma';

const component = await Component.fromRestApi(
  libraryJson,   // raw REST API JSON
  componentId,   // component name or ID
  config,
  { styles, variables, collections }
);
console.log(component.yaml());
```

两种工厂方法都经过处理后返回 `Component`调用 `.yaml()` 用于 YAML 字符串或 `.json()` 对于普通物体.

## 公共 API

公众的表面是故意最小的。 所有内部运行时间和处理代码被捆绑而不再再出口.

### `Component`

主变相课. 使用静态工厂方法——不调用 `new Component()` 直接说.

| 方法 | 说明 |
| --- | --- |
| `Component.fromPlugin(node, config, options?)` | 处理一个图像插件 API 节点 |
| `Component.fromRestApi(json, id, config, options)` | 从 REST API JSON 处理一个组件 |
| `component.yaml()` | 返回组件规格的 YAML 字符串 |
| `component.json()` | 返回纯 JavaScript 对象 |

### 基础地图类型

用作 `options` 有效载荷 `fromRestApi`数字 :

-   `StylesMap` ——样式ID地图到样式数据
-   `VariablesMap` ——可变ID到可变数据的地图
-   `CollectionsMap` ——收集标识地图以收集数据

输出计划类型(例如:. `Component` 从 `@directededges/specs-schema`) 由 `specs-schema` 软件包.

## 发展

### 大楼

```bash
# Install dependencies
npm install

# Build the package
npm run build

# Build types only
npm run build:types

# Build JavaScript only
npm run build:js
```

### 测试

```bash
# Run tests
npm test

# Run tests in watch mode
npm run test:watch
```

## 版本兼容性( C)

-   前1.0——小版本可能出现断裂变化
-   **节点.js**: 20岁以上
-   **目标**页:1
-   **模块格式**仅限无害环境管理

## 许可证

[PolyForm 内部使用许可证 1.0.0](https://npmcn.com/package/%40directededges/specs-from-figma/LICENSE)

## 仓库

[https://github.com/ DirectedEdges/ specs-transforms 互联网档案馆的存檔,存档日期2014-12-22](https://github.com/DirectedEdges/specs-transforms)

## 常见问题

### @directededges/specs-from-figma 是什么？

光谱设计规格工具的核心数据转换模型

### 如何安装 @directededges/specs-from-figma？

在项目目录运行 npm install @directededges/specs-from-figma，或使用 pnpm add / yarn add / bun add。

### @directededges/specs-from-figma 支持 TypeScript 吗？

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

### @directededges/specs-from-figma 支持 ESM 还是 CommonJS？

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

### @directededges/specs-from-figma 可以商用吗？

@directededges/specs-from-figma 使用 PolyForm-Internal-Use-1\.0\.0 许可。声明的许可为 PolyForm-Internal-Use-1\.0\.0，请阅读许可原文确认使用条件。以上为概括，不构成法律意见，请以许可原文为准。

### @directededges/specs-from-figma 的下载量有多少？

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

### @directededges/specs-from-figma 还在维护吗？

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

