@directededges/specs-from-figma 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +96 -0
- package/README.md +140 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# PolyForm Internal Use License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/internal-use/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the software
|
|
14
|
+
to do everything you might do with the software that would
|
|
15
|
+
otherwise infringe the licensor's copyright in it for any
|
|
16
|
+
permitted purpose. However, you may only make changes or
|
|
17
|
+
new works based on the software according to [Changes and New
|
|
18
|
+
Works License](#changes-and-new-works-license), and you may
|
|
19
|
+
not distribute the software.
|
|
20
|
+
|
|
21
|
+
## Changes and New Works License
|
|
22
|
+
|
|
23
|
+
The licensor grants you an additional copyright license to
|
|
24
|
+
make changes and new works based on the software for any
|
|
25
|
+
permitted purpose.
|
|
26
|
+
|
|
27
|
+
## Patent License
|
|
28
|
+
|
|
29
|
+
The licensor grants you a patent license for the software that
|
|
30
|
+
covers patent claims the licensor can license, or becomes able
|
|
31
|
+
to license, that you would infringe by using the software.
|
|
32
|
+
|
|
33
|
+
## Fair Use
|
|
34
|
+
|
|
35
|
+
You may have "fair use" rights for the software under the
|
|
36
|
+
law. These terms do not limit them.
|
|
37
|
+
|
|
38
|
+
## Internal Business Use
|
|
39
|
+
|
|
40
|
+
Use of the software for the internal business operations of
|
|
41
|
+
you and your company is use for a permitted purpose.
|
|
42
|
+
|
|
43
|
+
## No Other Rights
|
|
44
|
+
|
|
45
|
+
These terms do not allow you to sublicense or transfer any of
|
|
46
|
+
your licenses to anyone else, or prevent the licensor from
|
|
47
|
+
granting licenses to anyone else. These terms do not imply
|
|
48
|
+
any other licenses.
|
|
49
|
+
|
|
50
|
+
## Patent Defense
|
|
51
|
+
|
|
52
|
+
If you make any written claim that the software infringes or
|
|
53
|
+
contributes to infringement of any patent, your patent license
|
|
54
|
+
for the software granted under these terms ends immediately. If
|
|
55
|
+
your company makes such a claim, your patent license ends
|
|
56
|
+
immediately for work on behalf of your company.
|
|
57
|
+
|
|
58
|
+
## Violations
|
|
59
|
+
|
|
60
|
+
The first time you are notified in writing that you have
|
|
61
|
+
violated any of these terms, or done anything with the software
|
|
62
|
+
not covered by your licenses, your licenses can nonetheless
|
|
63
|
+
continue if you come into full compliance with these terms,
|
|
64
|
+
and take practical steps to correct past violations, within
|
|
65
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
66
|
+
end immediately.
|
|
67
|
+
|
|
68
|
+
## No Liability
|
|
69
|
+
|
|
70
|
+
***As far as the law allows, the software comes as is, without
|
|
71
|
+
any warranty or condition, and the licensor will not be liable
|
|
72
|
+
to you for any damages arising out of these terms or the use
|
|
73
|
+
or nature of the software, under any kind of legal claim.***
|
|
74
|
+
|
|
75
|
+
## Definitions
|
|
76
|
+
|
|
77
|
+
The **licensor** is the individual or entity offering these
|
|
78
|
+
terms, and the **software** is the software the licensor makes
|
|
79
|
+
available under these terms.
|
|
80
|
+
|
|
81
|
+
**You** refers to the individual or entity agreeing to these
|
|
82
|
+
terms.
|
|
83
|
+
|
|
84
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
85
|
+
or other kind of organization that you work for, plus all
|
|
86
|
+
organizations that have control over, are under the control of,
|
|
87
|
+
or are under common control with that organization. **Control**
|
|
88
|
+
means ownership of substantially all the assets of an entity,
|
|
89
|
+
or the power to direct its management and policies by vote,
|
|
90
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
91
|
+
|
|
92
|
+
**Your licenses** are all the licenses granted to you for the
|
|
93
|
+
software under these terms.
|
|
94
|
+
|
|
95
|
+
**Use** means anything you do with the software requiring one
|
|
96
|
+
of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# @directededges/anova-transformer
|
|
2
|
+
|
|
3
|
+
Core data transformation model for Anova design specification tools. This package extracts the Model and Runtime layers from anova-plugin, enabling independent development and reusability across CLI, MCP, and plugin environments.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@directededges/anova-transformer` provides:
|
|
8
|
+
- **Component Processing**: Transform Figma design components into structured specifications
|
|
9
|
+
- **Runtime Abstractions**: Platform-agnostic data loading and node resolution
|
|
10
|
+
- **Cross-Platform Support**: Works in both Node.js (CLI/MCP) and Browser (Figma Plugin) environments
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
### From GitHub Packages
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Configure npm to use GitHub Packages for @directededges scope
|
|
18
|
+
npm config set @directededges:registry https://npm.pkg.github.com
|
|
19
|
+
|
|
20
|
+
# Install the package
|
|
21
|
+
npm install @directededges/anova-transformer
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Authentication Required**: You must configure a GitHub Personal Access Token with `read:packages` scope:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Add to ~/.npmrc
|
|
28
|
+
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Plugin environment
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { Component } from '@directededges/anova-transformer';
|
|
37
|
+
|
|
38
|
+
const component = await Component.fromPlugin(figmaNode, config);
|
|
39
|
+
console.log(component.yaml());
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
An optional `coordinator` and `author` can be passed as a third argument.
|
|
43
|
+
|
|
44
|
+
### CLI / REST API environment
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { Component } from '@directededges/anova-transformer';
|
|
48
|
+
import type { StylesMap, VariablesMap, CollectionsMap } from '@directededges/anova-transformer';
|
|
49
|
+
|
|
50
|
+
const component = await Component.fromRestApi(
|
|
51
|
+
libraryJson, // raw REST API JSON
|
|
52
|
+
componentId, // component name or ID
|
|
53
|
+
config,
|
|
54
|
+
{ styles, variables, collections }
|
|
55
|
+
);
|
|
56
|
+
console.log(component.yaml());
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Both factory methods return a fully-processed `Component`. Call `.yaml()` for a YAML string or `.json()` for a plain object.
|
|
60
|
+
|
|
61
|
+
## Public API
|
|
62
|
+
|
|
63
|
+
The public surface is intentionally minimal. All internal runtime and processing code is bundled and not re-exported.
|
|
64
|
+
|
|
65
|
+
### `Component`
|
|
66
|
+
|
|
67
|
+
Main transformation class. Use the static factory methods — do not call `new Component()` directly.
|
|
68
|
+
|
|
69
|
+
| Method | Description |
|
|
70
|
+
|--------|-------------|
|
|
71
|
+
| `Component.fromPlugin(node, config, options?)` | Process a Figma Plugin API node |
|
|
72
|
+
| `Component.fromRestApi(json, id, config, options)` | Process a component from REST API JSON |
|
|
73
|
+
| `component.yaml()` | Returns a YAML string of the component specification |
|
|
74
|
+
| `component.json()` | Returns a plain JavaScript object |
|
|
75
|
+
|
|
76
|
+
### Foundations map types
|
|
77
|
+
|
|
78
|
+
Used as the `options` payload for `fromRestApi`:
|
|
79
|
+
|
|
80
|
+
- `StylesMap` — map of style IDs to style data
|
|
81
|
+
- `VariablesMap` — map of variable IDs to variable data
|
|
82
|
+
- `CollectionsMap` — map of collection IDs to collection data
|
|
83
|
+
|
|
84
|
+
Output schema types (e.g. `Component` from `@directededges/anova`) are provided by the `anova` package.
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
### Building
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Install dependencies
|
|
92
|
+
npm install
|
|
93
|
+
|
|
94
|
+
# Build the package
|
|
95
|
+
npm run build
|
|
96
|
+
|
|
97
|
+
# Build types only
|
|
98
|
+
npm run build:types
|
|
99
|
+
|
|
100
|
+
# Build JavaScript only
|
|
101
|
+
npm run build:js
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Testing
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Run tests
|
|
108
|
+
npm test
|
|
109
|
+
|
|
110
|
+
# Run tests in watch mode
|
|
111
|
+
npm run test:watch
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Publishing
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Publish to GitHub Packages (runs build + test automatically)
|
|
118
|
+
npm publish
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
|
|
122
|
+
|
|
123
|
+
## Architecture
|
|
124
|
+
|
|
125
|
+
See [ARCHITECTURE.md](ARCHITECTURE.md) for a system diagram, component hierarchy, runtime model, and design principles.
|
|
126
|
+
|
|
127
|
+
## Version & Compatibility
|
|
128
|
+
|
|
129
|
+
- **Version**: 0.6.0 (Pre-1.0 — breaking changes may occur in minor versions)
|
|
130
|
+
- **Node.js**: 20+ required
|
|
131
|
+
- **Target**: ES2020
|
|
132
|
+
- **Module Format**: ESM only
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
[PolyForm Internal Use License 1.0.0](LICENSE)
|
|
137
|
+
|
|
138
|
+
## Repository
|
|
139
|
+
|
|
140
|
+
https://github.com/directededges/anova-transformer
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @directededges/specs-from-figma
|
|
3
|
+
*
|
|
4
|
+
* Core data transformation model for Anova design specification tools.
|
|
5
|
+
*
|
|
6
|
+
* PUBLIC API
|
|
7
|
+
* - Components class — sole entry point for REST/CLI runtime
|
|
8
|
+
* - ComponentsData type — return type for fromRestApi()
|
|
9
|
+
* - StylesMap, VariablesMap, CollectionsMap types — foundations data contracts
|
|
10
|
+
* - ProgressEvent type — callback event shape for fromRestApi()
|
|
11
|
+
* - RestLicenseInput type — license parameter shape for fromRestApi()
|
|
12
|
+
*
|
|
13
|
+
* Deep imports are restricted via package.json exports field.
|
|
14
|
+
* Output type definitions (Component schema) are provided by @directededges/specs-schema package.
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Components — entry point for REST/CLI runtime
|
|
20
|
+
*
|
|
21
|
+
* Factory method:
|
|
22
|
+
* - Components.fromRestApi(ids, json, config, foundations, onProgress, license?)
|
|
23
|
+
*
|
|
24
|
+
* Returns `ComponentsData[]`. Callers discriminate results inline:
|
|
25
|
+
* - `'component' in result` → success
|
|
26
|
+
* - `'error' in result` → error
|
|
27
|
+
*/
|
|
28
|
+
export { Components } from './Components/Components.js';
|
|
29
|
+
export type { ComponentsData } from './Components/Components.js';
|
|
30
|
+
/**
|
|
31
|
+
* Map types for external foundations data
|
|
32
|
+
*
|
|
33
|
+
* These types define the contract for passing styles, variables, and collections
|
|
34
|
+
* data from CLI/external environments to Components.fromRestApi().
|
|
35
|
+
*/
|
|
36
|
+
export type { StylesMap, VariablesMap, CollectionsMap } from './Runtime/Foundations/FigmaRESTMaps.js';
|
|
37
|
+
/** Progress event shape received by the `onProgress` callback in `fromRestApi()` */
|
|
38
|
+
export type { ProgressEvent } from './Components/Components.js';
|
|
39
|
+
/** License input shape for `fromRestApi()` — callers pass `{ key: string }` */
|
|
40
|
+
export type { RestLicenseInput } from './License/types.js';
|