@ directededges/ specs- from-figma (英语)
(原始内容存档于2017-10-21). Figma – spec. Spectacular设计规格工具的核心数据转换模型:将原始的Figma设计数据转换为结构化的,决定性的组件规格(YAML/JSON). 跨越CLI,MCP,和插件环境使用.
概览
@directededges/specs-from-figma 规定:
- 构成部分处理: 将图像设计组件转化为结构化规格
- 运行时间摘要: 平台不可知数据加载和节点分辨率
- 跨平台支持: 在Node.js(CLI/MCP)和浏览器(Figma插件)环境中工作
安装
npm install @directededges/specs-from-figma
使用量
插件环境
import { Component } from '@directededges/specs-from-figma';
const component = await Component.fromPlugin(figmaNode, config);
console.log(component.yaml());
可选 coordinator 财务报告和审定财务报表 author 可以作为第三个论点通过.
CLI / REST API 环境
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 软件包.
发展
大楼
# Install dependencies
npm install
# Build the package
npm run build
# Build types only
npm run build:types
# Build JavaScript only
npm run build:js
测试
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
版本兼容性( C)
- 前1.0——小版本可能出现断裂变化
- 节点.js: 20岁以上
- 目标页:1
- 模块格式仅限无害环境管理
许可证
仓库
https://github.com/ DirectedEdges/ specs-transforms 互联网档案馆的存檔,存档日期2014-12-22