openfig-cli 0.3.30 → 0.3.32
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/README.md +1 -1
- package/lib/core/fig-deck.mjs +11 -38
- package/lib/core/node-helpers.mjs +2 -4
- package/package.json +2 -6
- package/manifest.json +0 -21
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ await deck.save('output.deck');
|
|
|
88
88
|
| High-level API | [docs/api-spec.md](docs/api-spec.md) |
|
|
89
89
|
| Low-level FigDeck API | [docs/library.md](docs/library.md) |
|
|
90
90
|
| Template workflows | [docs/template-workflows.md](docs/template-workflows.md) |
|
|
91
|
-
| File format internals | [docs/format/](docs/format/) |
|
|
91
|
+
| File format internals | [docs/format/](docs/format/) ([canonical source](https://github.com/OpenFig-org/openfig-core/tree/main/docs)) |
|
|
92
92
|
|
|
93
93
|
## License
|
|
94
94
|
|
package/lib/core/fig-deck.mjs
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* - Chunk 1 = message data (MUST be zstd compressed — Figma rejects deflateRaw)
|
|
10
10
|
* - Chunk 2+ = optional additional data (pass through as-is)
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { parseFigBinary } from 'openfig-core';
|
|
13
|
+
import { encodeBinarySchema } from 'kiwi-schema';
|
|
14
|
+
import { deflateRaw } from 'pako';
|
|
15
15
|
import { ZstdCodec } from 'zstd-codec';
|
|
16
16
|
import yazl from 'yazl';
|
|
17
17
|
import { readFileSync, createWriteStream, existsSync, mkdtempSync, readdirSync, copyFileSync, mkdirSync } from 'fs';
|
|
@@ -92,41 +92,14 @@ export class FigDeck {
|
|
|
92
92
|
* Known preludes: "fig-kiwi", "fig-deck", "fig-jam."
|
|
93
93
|
*/
|
|
94
94
|
_parseFig(buf) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.
|
|
102
|
-
|
|
103
|
-
// Read length-prefixed chunks
|
|
104
|
-
const files = [];
|
|
105
|
-
let off = 12;
|
|
106
|
-
while (off < data.byteLength) {
|
|
107
|
-
const len = view.getUint32(off, true);
|
|
108
|
-
off += 4;
|
|
109
|
-
files.push(data.subarray(off, off + len));
|
|
110
|
-
off += len;
|
|
111
|
-
}
|
|
112
|
-
this.rawFiles = files;
|
|
113
|
-
|
|
114
|
-
// Chunk 0: schema (always deflateRaw)
|
|
115
|
-
const schemaData = inflateRaw(files[0]);
|
|
116
|
-
this.schema = decodeBinarySchema(schemaData);
|
|
117
|
-
this.compiledSchema = compileSchema(this.schema);
|
|
118
|
-
|
|
119
|
-
// Chunk 1: message (zstd or deflateRaw — auto-detect)
|
|
120
|
-
let msgData;
|
|
121
|
-
if (files[1][0] === 0x28 && files[1][1] === 0xb5 &&
|
|
122
|
-
files[1][2] === 0x2f && files[1][3] === 0xfd) {
|
|
123
|
-
msgData = decompress(files[1]); // zstd
|
|
124
|
-
} else {
|
|
125
|
-
msgData = inflateRaw(files[1]); // deflateRaw fallback
|
|
126
|
-
}
|
|
127
|
-
this.message = this.compiledSchema.decodeMessage(msgData);
|
|
128
|
-
|
|
129
|
-
this.rebuildMaps();
|
|
95
|
+
const doc = parseFigBinary(new Uint8Array(buf.buffer ?? buf));
|
|
96
|
+
this.header = doc.header;
|
|
97
|
+
this.schema = doc.schema;
|
|
98
|
+
this.compiledSchema = doc.compiledSchema;
|
|
99
|
+
this.message = doc.message;
|
|
100
|
+
this.rawFiles = doc.rawChunks;
|
|
101
|
+
this.nodeMap = doc.nodeMap;
|
|
102
|
+
this.childrenMap = doc.childrenMap;
|
|
130
103
|
}
|
|
131
104
|
|
|
132
105
|
/**
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/** Format a node's guid as "sessionID:localID" */
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return `${node.guid.sessionID}:${node.guid.localID}`;
|
|
9
|
-
}
|
|
6
|
+
import { nodeId as nid } from 'openfig-core';
|
|
7
|
+
export { nid };
|
|
10
8
|
|
|
11
9
|
/** Parse "57:48" → { sessionID: 57, localID: 48 } */
|
|
12
10
|
export function parseId(str) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openfig-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"description": "OpenFig — Open-source tools for Figma file parsing and rendering",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,16 +19,13 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"bin/",
|
|
21
21
|
"mcp-server.mjs",
|
|
22
|
-
"manifest.json",
|
|
23
22
|
"lib/",
|
|
24
23
|
"LICENSE",
|
|
25
24
|
"README.md"
|
|
26
25
|
],
|
|
27
26
|
"scripts": {
|
|
28
27
|
"start": "node bin/cli.mjs",
|
|
29
|
-
"pack": "node scripts/pack.mjs",
|
|
30
28
|
"release": "node scripts/release-npm.mjs",
|
|
31
|
-
"validate:extension": "mcpb validate manifest.json",
|
|
32
29
|
"test": "vitest run",
|
|
33
30
|
"test:watch": "vitest"
|
|
34
31
|
},
|
|
@@ -47,8 +44,8 @@
|
|
|
47
44
|
"dependencies": {
|
|
48
45
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
49
46
|
"@resvg/resvg-wasm": "^2.6.2",
|
|
50
|
-
"fzstd": "^0.1.1",
|
|
51
47
|
"kiwi-schema": "^0.5.0",
|
|
48
|
+
"openfig-core": "^0.3.0",
|
|
52
49
|
"pako": "^2.1.0",
|
|
53
50
|
"pdf-lib": "^1.17.1",
|
|
54
51
|
"sharp": "^0.34.5",
|
|
@@ -57,7 +54,6 @@
|
|
|
57
54
|
"zstd-codec": "^0.1.5"
|
|
58
55
|
},
|
|
59
56
|
"devDependencies": {
|
|
60
|
-
"@anthropic-ai/mcpb": "^2.1.2",
|
|
61
57
|
"@fontsource/darker-grotesque": "^5.2.8",
|
|
62
58
|
"@fontsource/inter": "^5.2.8",
|
|
63
59
|
"@fontsource/irish-grover": "^5.2.7",
|
package/manifest.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"manifest_version": "0.2",
|
|
3
|
-
"name": "openfig",
|
|
4
|
-
"version": "0.3.30",
|
|
5
|
-
"description": "Open-source tools for Figma file parsing and rendering",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "OpenFig Contributors"
|
|
8
|
-
},
|
|
9
|
-
"server": {
|
|
10
|
-
"type": "node",
|
|
11
|
-
"entry_point": "mcp-server.mjs",
|
|
12
|
-
"mcp_config": {
|
|
13
|
-
"command": "node",
|
|
14
|
-
"args": [
|
|
15
|
-
"${__dirname}/mcp-server.mjs"
|
|
16
|
-
],
|
|
17
|
-
"env": {}
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"license": "MIT"
|
|
21
|
-
}
|