@moondraft/import 0.2.0 → 0.3.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/CHANGELOG.md +15 -0
- package/SOURCE.md +115 -1
- package/dist/adapter/convert.d.ts +2 -0
- package/dist/adapter/convert.js +175 -84
- package/dist/adapter/figma-handoff.d.ts +24 -2
- package/dist/adapter/figma-handoff.js +39 -18
- package/dist/adapter/figma.js +2 -1
- package/dist/adapter/file-components.d.ts +2 -1
- package/dist/adapter/file-components.js +5 -2
- package/dist/adapter/file-resources.js +234 -25
- package/dist/adapter/file-typography.d.ts +6 -0
- package/dist/adapter/file-typography.js +44 -0
- package/dist/adapter/link.d.ts +7 -0
- package/dist/adapter/link.js +87 -24
- package/dist/adapter/payload.js +2 -2
- package/dist/adapter/variables.d.ts +1 -1
- package/dist/figma-file.d.ts +1 -0
- package/dist/figma-file.js +1 -0
- package/dist/figma.d.ts +1 -0
- package/dist/figma.js +41 -19
- package/dist/report.d.ts +37 -6
- package/dist/report.js +91 -18
- package/dist/taco/figma-import/figFile.js +3 -0
- package/dist/taco/figma-import/import/converters/effects.d.ts +3 -13
- package/dist/taco/figma-import/import/converters/effects.js +4 -34
- package/dist/taco/figma-import/import/converters/exportSettings.js +26 -0
- package/dist/taco/figma-import/import/converters/frame.d.ts +1 -1
- package/dist/taco/figma-import/import/converters/frame.js +8 -7
- package/dist/taco/figma-import/import/converters/grid.d.ts +12 -0
- package/dist/taco/figma-import/import/converters/grid.js +97 -0
- package/dist/taco/figma-import/import/converters/image.d.ts +1 -0
- package/dist/taco/figma-import/import/converters/image.js +38 -5
- package/dist/taco/figma-import/import/converters/layout.d.ts +5 -3
- package/dist/taco/figma-import/import/converters/layout.js +26 -16
- package/dist/taco/figma-import/import/converters/rectangle.js +2 -2
- package/dist/taco/figma-import/import/converters/section.js +2 -2
- package/dist/taco/figma-import/import/converters/shared.d.ts +2 -1
- package/dist/taco/figma-import/import/converters/shared.js +8 -5
- package/dist/taco/figma-import/import/converters/text.d.ts +24 -0
- package/dist/taco/figma-import/import/converters/text.js +114 -29
- package/dist/taco/figma-import/import/instances.d.ts +9 -3
- package/dist/taco/figma-import/import/instances.js +319 -43
- package/dist/taco/figma-import/import/types.d.ts +8 -0
- package/dist/taco/figma-import/import/variables.d.ts +2 -0
- package/dist/taco/figma-import/import/variables.js +28 -1
- package/dist/taco/figma-import/import/variantTrees.js +2 -0
- package/dist/taco/figma-import/import/walk.d.ts +9 -2
- package/dist/taco/figma-import/import/walk.js +69 -30
- package/dist/taco/figma-import/kiwi/message.js +52 -10
- package/dist/taco/model/codec.d.ts +1 -1
- package/dist/taco/model/codec.js +40 -6
- package/dist/taco/model/instance-resolver.js +3 -1
- package/dist/taco/model/types.d.ts +36 -6
- package/dist/taco/model/types.js +4 -0
- package/dist/taco/svg-import/style/computed.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 0.3.0 — 2026-11-27
|
|
6
|
+
|
|
7
|
+
- The peer dependency on `@moondraft/editor` is now `>=0.5.0 <0.6.0`. Install the editor 0.5.0 or later in the
|
|
8
|
+
0.5 line.
|
|
9
|
+
|
|
10
|
+
- The import report says why each Figma instance stays expanded into plain layers ("expanded instance: its content draws outside its box" and so on), one entry per reason.
|
|
11
|
+
- Figma variant choices bound to a variable (`RESOLVE_VARIANT` expressions) stay bound on instances and in instance overrides, so imported instances switch variant with the mode; a visibility bound through `IS_TRUTHY` keeps its boolean variable. A variant binding on a layer that is not an instance, or one naming a property its set lacks, is still reported.
|
|
12
|
+
- Saved Figma files import with less memory again: equal decoded GUIDs, vectors, matrices and colors share one object, the derived pass skips the editing index of component occurrences, and the derived document hands over its records instead of copying them. Output is unchanged.
|
|
13
|
+
- Saved Figma files use less memory and time to import: decoded node records are compact, each vector network is converted once for every layer that shows it, and the derived document is handed over without a second copy. Output is unchanged.
|
|
14
|
+
- Figma truncation: a linked instance keeps its own line limit and ellipsis as overrides, a derived line limit counts Figma's laid-out lines (the instance's own where it stores them), auto-height text with a maximum height gets a derived limit, an outer instance's truncation override reads against the inner instance's, and an override's unknown truncation is reported
|
|
15
|
+
- Figma export presets: an instance override that names its component by override key sets that instance's presets, a pasted variant's main takes the selected variant's presets, and every preset field the import cannot keep (SVG text outlines and ids, colour profile, JPEG quality, rows past 32 and the rest) is reported by field.
|
|
16
|
+
- Figma fill and stroke paints keep their blend modes, linear dodge and linear burn included, instead of dropping them.
|
|
17
|
+
|
|
3
18
|
## 0.2.0 — 2026-11-27
|
|
4
19
|
|
|
5
20
|
### Highlights
|
package/SOURCE.md
CHANGED
|
@@ -178,7 +178,7 @@ groups of those; regions not painted apart) becomes a frame holding its operands
|
|
|
178
178
|
frame carries its operation and the `fillGeometry` outline (in its own space) in `metadata.figma.boolean`, which also
|
|
179
179
|
splits clipboard variants (`variantTrees.ts`);
|
|
180
180
|
the adapter (`src/adapter/convert.ts`) makes it a boolean group whose first result is that outline. "In an auto layout
|
|
181
|
-
flow" means placed by a
|
|
181
|
+
flow" means placed by a stack or grid the walk imported, and a nested
|
|
182
182
|
boolean operation counts with its operands' box, as the adapter fits it. One with no outline is kept live anyway (the
|
|
183
183
|
renderer cuts its result); in a flow where its operands do not fill its box it carries `fixedBox`, and the adapter puts
|
|
184
184
|
it in a plain frame of its own box. Any other is
|
|
@@ -368,6 +368,15 @@ single binding. The literal reader retains its existing handling.
|
|
|
368
368
|
The Figma reader keeps per-instance clipping, corner smoothing and stack settings on the affected
|
|
369
369
|
component layer or root. The vendored resolver composes the layout members across nested instances.
|
|
370
370
|
|
|
371
|
+
### `patches/0038-grid-auto-layout.patch`
|
|
372
|
+
|
|
373
|
+
The reader joins grid track sizing to Figma's ordered row and column IDs. It keeps the tracks,
|
|
374
|
+
gaps and instance layout overrides in the frame layout, and carries child anchors, spans and
|
|
375
|
+
alignment in `metadata.figma.gridCell` for the editor layout engine. An unsupported sizing
|
|
376
|
+
function or unresolved anchor produces a diagnostic naming the affected field. Instance sizing
|
|
377
|
+
uses the inherited track IDs, and a reordered axis remaps the child anchors that still inherit
|
|
378
|
+
their GUIDs. If a visible flow child is missing, the frame keeps the remaining source positions.
|
|
379
|
+
|
|
371
380
|
## Code and data from elsewhere
|
|
372
381
|
|
|
373
382
|
- **VS Code themes (MIT).** taco's model adapts the Code - OSS `2026-dark` / `2026-light` colour themes in `code.ts`.
|
|
@@ -392,3 +401,108 @@ component layer or root. The vendored resolver composes the layout members acros
|
|
|
392
401
|
type-checked: they need Node's types, which this repo does not install.
|
|
393
402
|
- `npm run test:import` runs the copied tests (svg-import 1,418 and figma-import 755, about 25 s). It is not part of
|
|
394
403
|
`npm test`.
|
|
404
|
+
|
|
405
|
+
### `patches/0039-figma-video-fills.patch`
|
|
406
|
+
|
|
407
|
+
The reader resolves a VIDEO paint’s video hash from the archive and carries its poster through the existing image placement conversion. When the media is missing, it retains the available image and reports the substitution. An embedded thumbnail takes precedence over a clipboard placeholder. A poster supplied by a later fill is shared by every use of that clip.
|
|
408
|
+
|
|
409
|
+
### `patches/0040-text-typography-variables.patch`
|
|
410
|
+
|
|
411
|
+
The saved-file reader tracks the source of each typography field through shared styles, text ranges and instance
|
|
412
|
+
overrides. A nested instance applies its inner text bindings before the enclosing instance’s overrides.
|
|
413
|
+
The adapter writes supported bindings into the native text palette, preserving percentage tracking
|
|
414
|
+
and pixel leading. Older editor peers keep the resolved literals for unsupported bindings. A saved instance
|
|
415
|
+
keeps its stored line height when it differs from the main’s, and resolved leading sizes fixed-text line limits and auto-height line counts.
|
|
416
|
+
|
|
417
|
+
A layer's typography binding stored beside a linked text style is stale (Figma detaches the style when a field is
|
|
418
|
+
bound), so the style's binding or literal wins unless an instance override sets or binds that field itself. An
|
|
419
|
+
instance that binds its own line height or font size draws at the token rather than its stored line height.
|
|
420
|
+
The bindings an instance override authors itself (its own variable map, or its own range table) are marked on each
|
|
421
|
+
run (`fileOwnTypography`), so an override that binds the main's own variable stays the occurrence's own binding.
|
|
422
|
+
|
|
423
|
+
### `patches/0041-linear-blend-modes.patch`
|
|
424
|
+
|
|
425
|
+
The model's `BLEND_MODES` gains `plus-lighter` and `plus-darker` (codes 16 and 17, after luminosity, so the list
|
|
426
|
+
still follows the renderer's codes). A layer in Figma's `LINEAR_DODGE` or `LINEAR_BURN` takes them instead of a
|
|
427
|
+
"has no Taco equivalent" report; a paint or shadow in those modes is still reported, as before.
|
|
428
|
+
The SVG reader accepts `mix-blend-mode: plus-lighter` and `plus-darker` on an element the same way.
|
|
429
|
+
|
|
430
|
+
### `patches/0042-figma-export-preset-fields.patch`
|
|
431
|
+
|
|
432
|
+
An instance override path of one step names the component's root by its guid or by its `overrideKey`; either way
|
|
433
|
+
its export presets are the instance's own (a path by override key still overrides the root's other fields). Export row fields a Taco row has no counterpart for
|
|
434
|
+
(`svgOutlineText`, `svgDataName`, `svgForceStrokeMasks`, `useAbsoluteBounds`, `colorProfile`, `quality`,
|
|
435
|
+
`useBicubicSampler`, `pdfPrint`) are reported by field when they hold a value that changes the row's format's file,
|
|
436
|
+
for the first 32 rows only: the adapter reports each later row whole.
|
|
437
|
+
|
|
438
|
+
### `patches/0043-figma-text-case.patch`
|
|
439
|
+
|
|
440
|
+
Read Figma's `textCase` into each run's `textCase` (`upper`, `lower`, `title`, `smallCaps`, `smallCapsForced`) instead
|
|
441
|
+
of reporting it as left out. A layer or range case beats its shared typography's, and a run linked to a cased style
|
|
442
|
+
that draws as typed overrides it with `original`. The characters stay as typed; the editor adapter keeps the case on
|
|
443
|
+
the native text style, which the renderer applies to the drawn glyphs. An unknown case is still reported.
|
|
444
|
+
|
|
445
|
+
### `patches/0044-negative-shadow-spread.patch`
|
|
446
|
+
|
|
447
|
+
The renderer now shrinks drop shadows and grows inner shadows' holes by a negative spread on every shape, so the
|
|
448
|
+
reader keeps a negative spread on every drop and inner shadow instead of writing 0 and reporting it.
|
|
449
|
+
`drawnAsPlainRectangle` and the `plainRectangle` argument of `nodeEffects` are gone with that rule.
|
|
450
|
+
|
|
451
|
+
### `patches/0045-paint-blend-modes.patch`
|
|
452
|
+
|
|
453
|
+
A fill or stroke paint in Figma's `LINEAR_DODGE` or `LINEAR_BURN` takes `plus-lighter` or `plus-darker`, as a layer
|
|
454
|
+
does, instead of a "has no Taco equivalent" report; a shadow in those modes is still reported. The model's paint
|
|
455
|
+
`blendMode` is documented as blending with the layers behind too, as Figma draws it.
|
|
456
|
+
|
|
457
|
+
### `patches/0046-truncation-overrides.patch`
|
|
458
|
+
|
|
459
|
+
The line limit derived for a fixed-size text box, or for auto-height text with a maximum height, counts the lines that
|
|
460
|
+
fit that height from Figma's laid-out lines (each at its own `lineY` and `lineHeight`, so uneven line heights and
|
|
461
|
+
paragraph spacing count), then lines of the last one's height below them; without laid-out lines every line is the
|
|
462
|
+
first run's height, as before. An instance text counts the lines its own `derivedSymbolData` entry stores, or its
|
|
463
|
+
own first line where an override sets its lines otherwise (line height, size, style, characters) and stores none.
|
|
464
|
+
An outer instance's truncation override is read against what the inner instance it goes through shows (its
|
|
465
|
+
`textTruncation` and `maxLines` join the inner fields), so the model's `mergeOverrides` (outer on top) resolves it.
|
|
466
|
+
An override's truncation other than `DISABLED` or `ENDING` is reported and left out, so the layer keeps its component's.
|
|
467
|
+
|
|
468
|
+
### `patches/0047-figma-report-counts.patch`
|
|
469
|
+
|
|
470
|
+
A reason the reader says once with a count keeps its plain wording and carries the count in the entry's new `count`
|
|
471
|
+
field, instead of ending in "(N times, first here)", so the editor adapter reads the number without parsing the text.
|
|
472
|
+
Instance overrides' Dev Mode annotations and measurements are skipped without a report: the editor adapter reports them
|
|
473
|
+
on the instance with the layer's own annotations (`figmaHandoff`), not as unimported override fields.
|
|
474
|
+
|
|
475
|
+
### `patches/0048-kiwi-fast-messages.patch`
|
|
476
|
+
|
|
477
|
+
The kiwi decoder returns a copy of each decoded message. It writes a message's fields by computed name, and V8 stores
|
|
478
|
+
an object written that way with more than a few fields as a hash table; the copy has fast properties. A node change
|
|
479
|
+
takes about a fifth of the memory, which cuts the decoded tree of a layer-heavy file by about 100 MB. Values are
|
|
480
|
+
unchanged.
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
### `patches/0050-kiwi-shared-structs.patch`
|
|
484
|
+
|
|
485
|
+
The kiwi decoder shares one frozen object between equal structs made only of numbers (`GUID`, `Vector`, `Matrix`,
|
|
486
|
+
`Color`, `Rect` and the like), keyed by their field values in order (a varfloat never decodes to -0, so map keys lose nothing). A layer-heavy file
|
|
487
|
+
repeats a few thousand such values hundreds of thousands of times; sharing them cuts the decoded tree of the
|
|
488
|
+
~50,000-layer file from about 270 MB to about 190 MB. Values are unchanged; nothing downstream writes to a decoded struct.
|
|
489
|
+
|
|
490
|
+
### `patches/0051-derived-text-sizes.patch`
|
|
491
|
+
|
|
492
|
+
An instance keeps, for the editor adapter, the box Figma measured each self-sizing text at (`fileLayout`'s `texts`, from
|
|
493
|
+
the instance's `derivedSymbolData`), so a document loads at Figma's text sizes without the document's fonts. An entry
|
|
494
|
+
with the text's glyphs (`derivedTextData`) and no size is a text Figma measured at the size a nested instance, else its
|
|
495
|
+
component, gives it (`inner`): the adapter takes an inner level's stored box over it.
|
|
496
|
+
|
|
497
|
+
### `patches/0052-nested-override-paths.patch`
|
|
498
|
+
|
|
499
|
+
Override paths resolve through nested and swapped instances in three more cases. A layer whose `overrideKey` is Figma's
|
|
500
|
+
no-key marker (both halves `0xFFFFFFFF`) is named by its guid, as override paths name it; before, every such layer of a
|
|
501
|
+
component shared the marker as its key, so paths through them missed or reached the first one. An instance's own
|
|
502
|
+
instance swap property value on a nested instance outranks a swap that a nested instance authored below it, as Figma
|
|
503
|
+
draws it; where the two differ, the value is also written as the instance's swap override, since the model's
|
|
504
|
+
`mergeOverrides` lets a swap override win over a property value. This holds for every swap-bound layer the value
|
|
505
|
+
reaches, whether or not a deeper override path goes through it. A property value that names a property the shown
|
|
506
|
+
component does not declare goes to the shallowest nested instances whose shown component (after swaps) declares it,
|
|
507
|
+
read against that component, but only where the instance's `derivedSymbolData` lays out a layer bound to that property
|
|
508
|
+
inside the nested instance (Figma ignores a stale value); any other such value is still reported.
|
|
@@ -133,6 +133,8 @@ export declare function figmaClipboardPage(doc: TacoDocument, instanceSources: M
|
|
|
133
133
|
*/
|
|
134
134
|
export declare function allPages(doc: TacoDocument, options: ConvertOptions): {
|
|
135
135
|
omittedLinks: Map<string, Set<string>>;
|
|
136
|
+
/** Per instance left expanded, by its layer ID: why linking could not keep it an instance (link.ts tryLink). */
|
|
137
|
+
expandedReasons: Map<string, string>;
|
|
136
138
|
expanded: Map<string, any>;
|
|
137
139
|
nestedBooleans: Map<string, NestedBooleanAssignments>;
|
|
138
140
|
doc: DocumentJSON;
|