@moondraft/import 0.2.0 → 0.4.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 +26 -0
- package/SOURCE.md +138 -1
- package/dist/adapter/convert.d.ts +2 -0
- package/dist/adapter/convert.js +192 -85
- 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 +20 -1
- package/dist/adapter/file-components.js +91 -12
- package/dist/adapter/file-resources.d.ts +5 -0
- package/dist/adapter/file-resources.js +286 -40
- package/dist/adapter/file-typography.d.ts +6 -0
- package/dist/adapter/file-typography.js +44 -0
- package/dist/adapter/link.d.ts +8 -1
- package/dist/adapter/link.js +219 -105
- 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/carry.d.ts +11 -1
- package/dist/taco/figma-import/import/carry.js +8 -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/group.d.ts +1 -0
- package/dist/taco/figma-import/import/converters/group.js +5 -2
- 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 +121 -31
- package/dist/taco/figma-import/import/instances.d.ts +19 -3
- package/dist/taco/figma-import/import/instances.js +337 -60
- 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 +3 -3
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { field, guidText, isObject } from "../fields.js";
|
|
2
2
|
import { isDetachedStyle, styleBackedList } from "../styles.js";
|
|
3
|
+
import { carryEffects } from "../carry.js";
|
|
4
|
+
import { nodeEffects } from "./effects.js";
|
|
3
5
|
import { framedBase, hexColor, readNumbers } from "./shared.js";
|
|
6
|
+
import { sizeLimitsOf } from "./layout.js";
|
|
4
7
|
const ALIGN = { LEFT: "left", CENTER: "center", RIGHT: "right", JUSTIFIED: "justify" };
|
|
5
8
|
const VERTICAL_ALIGN = { TOP: "top", CENTER: "middle", BOTTOM: "bottom" };
|
|
6
9
|
const AUTO_RESIZE = { NONE: "none", HEIGHT: "height", WIDTH_AND_HEIGHT: "width-and-height" };
|
|
@@ -44,9 +47,12 @@ export const KEPT_LINE_HEIGHT_FIELD = "tacoKeptLineHeight";
|
|
|
44
47
|
export const convertText = (node, walk) => {
|
|
45
48
|
const where = `node ${node.id}`;
|
|
46
49
|
const change = node.change;
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
50
|
+
const framed = framedBase(node, walk, "Text", true);
|
|
51
|
+
if (framed === null)
|
|
49
52
|
return null;
|
|
53
|
+
// Moondraft patch: the layer's shadows and blurs are carried in its metadata (`carryEffects`); the renderer casts
|
|
54
|
+
// them from the glyphs.
|
|
55
|
+
const base = carryEffects(framed, nodeEffects(node, walk));
|
|
50
56
|
// Taco text has no strokes yet, so a text stroke is reported rather than dropped.
|
|
51
57
|
if ((styleBackedList(change, "strokePaints", walk.styleList, where)?.length ?? 0) > 0)
|
|
52
58
|
walk.report("property-left-out", "text strokes are not imported yet");
|
|
@@ -106,8 +112,15 @@ export const convertText = (node, walk) => {
|
|
|
106
112
|
if (id !== 0 && override === undefined)
|
|
107
113
|
missingIds += 1;
|
|
108
114
|
const textStyle = textStyleOfEntry(override);
|
|
109
|
-
const
|
|
110
|
-
|
|
115
|
+
const instance = override?.["styleIdForText"] === undefined ? walk.instanceTypography : undefined;
|
|
116
|
+
let under = textStyle?.change;
|
|
117
|
+
if (under && instance) {
|
|
118
|
+
const local = Object.fromEntries(Object.values(TEXT_VARIABLE_FIELDS).filter(([, name]) => name in instance)
|
|
119
|
+
.map(([, name]) => [name, instance[name]]));
|
|
120
|
+
under = { ...under, ...local };
|
|
121
|
+
}
|
|
122
|
+
const fields = styleFields(filled, entryFilled(override), under);
|
|
123
|
+
const boundLineHeight = keptLineHeight ?? boundLineHeightOf(change, override, textStyle?.change, where, walk.typographyVariable ? undefined : walk.variableNumber);
|
|
111
124
|
const said = [];
|
|
112
125
|
const own = runStyle(fields, lookups, (kind, reason) => said.push([kind, reason]), where, boundLineHeight);
|
|
113
126
|
sizes.set(id, { fontSize: own.fontSize ?? 12, lineHeight: own.lineHeight ?? AUTO_LINE_HEIGHT });
|
|
@@ -143,14 +156,40 @@ export const convertText = (node, walk) => {
|
|
|
143
156
|
if (variable && opacity !== 1 && !walk.copiedPaintAlpha?.(paint, opacity))
|
|
144
157
|
Object.assign(style, { filePaintOpacity: opacity });
|
|
145
158
|
}
|
|
146
|
-
if (walk.
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
if (walk.typographyVariable) {
|
|
160
|
+
const bindings = {};
|
|
161
|
+
// The bindings an instance override makes itself, even to the main's variable: Figma keeps them as overrides.
|
|
162
|
+
const authored = walk.instanceTypography?.[OWN_TYPOGRAPHY];
|
|
163
|
+
const ownBindings = {};
|
|
164
|
+
for (const [field, [key, name]] of Object.entries(TEXT_VARIABLE_FIELDS)) {
|
|
165
|
+
if (key === "lineHeight" && keptLineHeight !== undefined)
|
|
166
|
+
continue;
|
|
167
|
+
const data = runBinding(change, override, textStyle?.change, where, field, name, instance, true);
|
|
168
|
+
if (data === undefined)
|
|
169
|
+
continue;
|
|
170
|
+
const variable = walk.typographyVariable(field, data);
|
|
171
|
+
if (variable && key === "lineHeight") {
|
|
172
|
+
const pixels = walk.variableNumber?.(data);
|
|
173
|
+
const fontSize = own.fontSize ?? 12;
|
|
174
|
+
if (pixels !== undefined) {
|
|
175
|
+
sizes.set(id, { fontSize, lineHeight: pixels / fontSize });
|
|
176
|
+
// The stored frame was measured with this leading in the source layer's mode.
|
|
177
|
+
Object.assign(style, { fileLineHeightPx: pixels });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (variable && key === "letterSpacing" && isObject(fields["letterSpacing"]) && fields["letterSpacing"]["units"] === "PERCENT")
|
|
181
|
+
Object.assign(style, { filePercentTracking: true });
|
|
182
|
+
// A failed style alias is reported once on its definition.
|
|
183
|
+
if (variable || !textStyle?.shared || data !== bindingIn(textStyle.change, field, where))
|
|
184
|
+
bindings[key] = variable;
|
|
185
|
+
if (variable && isObject(authored) && (bindingIn(authored, field, where) !== undefined
|
|
186
|
+
|| authored["textData"] === true && override !== undefined && bindingIn(override, field, where) !== undefined))
|
|
187
|
+
ownBindings[key] = variable;
|
|
153
188
|
}
|
|
189
|
+
if (Object.keys(bindings).length)
|
|
190
|
+
Object.assign(style, { fileTypography: bindings });
|
|
191
|
+
if (Object.keys(ownBindings).length)
|
|
192
|
+
Object.assign(style, { fileOwnTypography: ownBindings });
|
|
154
193
|
}
|
|
155
194
|
// A run that keeps its style's auto line height has the style's, which may come from another layer's font metadata.
|
|
156
195
|
const keepsStyleLineHeight = bothAuto && textStyle.shared !== undefined && style.overrides?.lineHeight === undefined;
|
|
@@ -223,7 +262,7 @@ export const convertText = (node, walk) => {
|
|
|
223
262
|
if (missingIds > 0) {
|
|
224
263
|
report("approximated", `${String(missingIds)} style id${missingIds === 1 ? " is" : "s are"} not in the style override table; their characters use the node's style`);
|
|
225
264
|
}
|
|
226
|
-
reportLeftOut(change,
|
|
265
|
+
reportLeftOut(change, report, where);
|
|
227
266
|
const firstLineHeight = (paragraph) => {
|
|
228
267
|
const id = paragraph?.runs[0] === undefined ? undefined : runIds.get(paragraph.runs[0]);
|
|
229
268
|
const size = sizes.get(id ?? 0) ?? { fontSize: 12, lineHeight: AUTO_LINE_HEIGHT };
|
|
@@ -268,7 +307,16 @@ export const convertText = (node, walk) => {
|
|
|
268
307
|
};
|
|
269
308
|
/** Most distinct report reasons one text node adds; the rest are counted in one closing line. */
|
|
270
309
|
const MAX_REPORTS = 20;
|
|
271
|
-
/**
|
|
310
|
+
/** Native palette key and authored Figma field for each typography binding. */
|
|
311
|
+
export const TEXT_VARIABLE_FIELDS = {
|
|
312
|
+
FONT_SIZE: ["size", "fontSize"], FONT_FAMILY: ["family", "fontName"], FONT_STYLE: ["style", "fontName"],
|
|
313
|
+
FONT_WEIGHT: ["weight", "fontName"], LINE_HEIGHT: ["lineHeight", "lineHeight"], LETTER_SPACING: ["letterSpacing", "letterSpacing"],
|
|
314
|
+
};
|
|
315
|
+
/** Figma's text cases, as Taco's. */
|
|
316
|
+
const TEXT_CASES = {
|
|
317
|
+
UPPER: "upper", LOWER: "lower", TITLE: "title", SMALL_CAPS: "smallCaps", SMALL_CAPS_FORCED: "smallCapsForced",
|
|
318
|
+
};
|
|
319
|
+
/** The fields read by runStyle. */
|
|
272
320
|
const STYLE_FIELDS = ["fontName", "fontSize", "lineHeight", "letterSpacing", "textDecoration", "fontVariations", "fillPaints"];
|
|
273
321
|
const FEATURE_SWITCHES = {
|
|
274
322
|
fontVariantCommonLigatures: ["liga", "clig"],
|
|
@@ -328,7 +376,8 @@ function styleFields(change, override, under) {
|
|
|
328
376
|
if (value !== undefined)
|
|
329
377
|
style[name] = value;
|
|
330
378
|
}
|
|
331
|
-
|
|
379
|
+
// The layer's case beats its text style's, as for the feature switches.
|
|
380
|
+
for (const name of [...FEATURE_VARIANTS, "textCase"]) {
|
|
332
381
|
const value = override?.[name] ?? change[name] ?? under?.[name];
|
|
333
382
|
if (value !== undefined)
|
|
334
383
|
style[name] = value;
|
|
@@ -342,21 +391,32 @@ function styleFields(change, override, under) {
|
|
|
342
391
|
* the field it binds (`name`): an override entry's own binding, or none when the entry sets its own value; else the text
|
|
343
392
|
* style's (`under`), else the node's.
|
|
344
393
|
*/
|
|
345
|
-
|
|
394
|
+
/** Override field naming the typography sources an instance override authors itself: its own variable map, and
|
|
395
|
+
* `textData: true` when its range table is its own. Set by `instances.ts`, read when the text converts. */
|
|
396
|
+
export const OWN_TYPOGRAPHY = "ownTypography";
|
|
397
|
+
function runBinding(change, override, under, where, variableField, name, instance, native = false) {
|
|
346
398
|
const bound = (fields) => bindingIn(fields, variableField, where);
|
|
347
399
|
if (override !== undefined) {
|
|
348
400
|
const own = bound(override);
|
|
349
401
|
if (own !== undefined || Object.hasOwn(override, name))
|
|
350
402
|
return own;
|
|
351
403
|
}
|
|
352
|
-
|
|
404
|
+
// Figma detaches a text style when a layer field is bound, so a layer binding stored beside a linked style is stale.
|
|
405
|
+
// Only an instance override that sets or binds the field itself replaces the style's source.
|
|
406
|
+
const claimed = instance !== undefined && (instance[name] !== undefined || bound(instance) !== undefined);
|
|
407
|
+
if (native && override?.["styleIdForText"] === undefined && (claimed || under === undefined)) {
|
|
408
|
+
const local = bound(change);
|
|
409
|
+
if (local !== undefined || claimed)
|
|
410
|
+
return local;
|
|
411
|
+
}
|
|
412
|
+
return under && (under[name] !== undefined || bound(under) !== undefined) ? bound(under) : bound(change);
|
|
353
413
|
}
|
|
354
414
|
/** The variable data Figma fields bind `variableField` to, or `undefined`. */
|
|
355
415
|
function bindingIn(fields, variableField, where) {
|
|
356
416
|
const map = field(fields, "variableConsumptionMap", "object", where);
|
|
357
417
|
const entry = (map && field(map, "entries", "list", `${where} variableConsumptionMap`) || [])
|
|
358
418
|
.find((item) => isObject(item) && item["variableField"] === variableField);
|
|
359
|
-
return isObject(entry) ? entry["variableData"] : undefined;
|
|
419
|
+
return isObject(entry) ? entry["variableData"] ?? null : undefined;
|
|
360
420
|
}
|
|
361
421
|
/** A run's line height in pixels from the variable it is bound to (`runBinding`), or `undefined` without one. */
|
|
362
422
|
function boundLineHeightOf(change, override, under, where, variableNumber) {
|
|
@@ -380,7 +440,7 @@ export function hyperlinkOf(value, report) {
|
|
|
380
440
|
return undefined;
|
|
381
441
|
}
|
|
382
442
|
/** The fields a style has that turn off when a run leaves them out, with the value that turns each off. */
|
|
383
|
-
const STYLE_OFF = [["italic", false], ["underline", false], ["strikethrough", false], ["letterSpacing", 0], ["fontVariations", {}], ["openTypeFeatures", {}]];
|
|
443
|
+
const STYLE_OFF = [["italic", false], ["underline", false], ["strikethrough", false], ["letterSpacing", 0], ["fontVariations", {}], ["openTypeFeatures", {}], ["textCase", "original"]];
|
|
384
444
|
/**
|
|
385
445
|
* A run linked to its shared style, with the fields of `own` that differ from
|
|
386
446
|
* the style's as its overrides. With `bothAuto` (the run's line height and the
|
|
@@ -500,6 +560,13 @@ function runStyle(style, lookups, report, where, boundLineHeight) {
|
|
|
500
560
|
const features = openTypeFeatures(style, report, where);
|
|
501
561
|
if (features !== undefined)
|
|
502
562
|
out.openTypeFeatures = features;
|
|
563
|
+
const textCase = field(style, "textCase", "string", where);
|
|
564
|
+
if (textCase !== undefined && textCase !== "ORIGINAL") {
|
|
565
|
+
if (Object.hasOwn(TEXT_CASES, textCase))
|
|
566
|
+
out.textCase = TEXT_CASES[textCase];
|
|
567
|
+
else
|
|
568
|
+
report("property-left-out", `text case ${textCase} is not imported; the characters are kept as typed`);
|
|
569
|
+
}
|
|
503
570
|
const axes = field(style, "fontVariations", "list", where) ?? [];
|
|
504
571
|
let variations = lookups.variations.get(axes);
|
|
505
572
|
if (variations === undefined) {
|
|
@@ -633,30 +700,53 @@ function bulletAdvancesOf(change, characters) {
|
|
|
633
700
|
}
|
|
634
701
|
return advances;
|
|
635
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* A field the importer adds to a text layer's Figma fields, never one Figma writes: the lines Figma laid this layer out
|
|
705
|
+
* in for an instance (its `derivedSymbolData` entry's `derivedTextData.baselines`), which replace the component's stored
|
|
706
|
+
* lines when the line limit a box holds is counted; an empty list where the instance changes how its lines are set but
|
|
707
|
+
* stores none, so the count follows the instance's own first line.
|
|
708
|
+
*/
|
|
709
|
+
export const LAID_OUT_LINES_FIELD = "tacoLaidOutLines";
|
|
636
710
|
/**
|
|
637
711
|
* Figma's ending truncation as `truncate` and `maxLines`. Figma reads `maxLines` only while truncation is on. A
|
|
638
|
-
* fixed-size box
|
|
639
|
-
* least one line), or `maxLines` where that is fewer.
|
|
640
|
-
* text out, else the first run's.
|
|
712
|
+
* fixed-size box ends at its last whole line, and so does auto-height text at its maximum height, so the line count is
|
|
713
|
+
* the lines that fit that height (at least one line), or `maxLines` where that is fewer.
|
|
641
714
|
*/
|
|
642
715
|
function truncationOf(change, height, autoResize, firstLineHeight, where) {
|
|
643
716
|
if (field(change, "textTruncation", "string", where) !== "ENDING")
|
|
644
717
|
return {};
|
|
645
718
|
const stored = Math.floor(field(change, "maxLines", "number", where) ?? 0);
|
|
646
|
-
const
|
|
647
|
-
const
|
|
648
|
-
const lineHeight = derived !== undefined && derived > 0 ? derived : firstLineHeight;
|
|
649
|
-
const fitting = autoResize === "none" && Number.isFinite(height / lineHeight) && lineHeight > 0 ? Math.max(1, Math.floor((height + 0.01) / lineHeight)) : undefined;
|
|
719
|
+
const limit = autoResize === "none" ? height : autoResize === "height" ? sizeLimitsOf(change).maxHeight : undefined;
|
|
720
|
+
const fitting = limit === undefined ? undefined : linesWithin(change, limit, firstLineHeight);
|
|
650
721
|
const maxLines = stored > 0 ? Math.min(stored, fitting ?? stored) : fitting;
|
|
651
722
|
return { ...(maxLines !== undefined ? { maxLines } : {}), truncate: "ellipsis" };
|
|
652
723
|
}
|
|
724
|
+
/**
|
|
725
|
+
* How many lines fit `height`, at least one: Figma's laid-out lines (each at its own top and height, so uneven line
|
|
726
|
+
* heights and paragraph spacing count) that end within it, then lines of the last one's height in the space below
|
|
727
|
+
* them. Without laid-out lines, every line is `firstLineHeight` tall.
|
|
728
|
+
*/
|
|
729
|
+
function linesWithin(change, height, firstLineHeight) {
|
|
730
|
+
const own = change[LAID_OUT_LINES_FIELD];
|
|
731
|
+
const derived = isObject(change["derivedTextData"]) ? change["derivedTextData"]["baselines"] : undefined;
|
|
732
|
+
const lines = Array.isArray(own) ? own : Array.isArray(derived) ? derived : [];
|
|
733
|
+
let count = 0, bottom = 0, last = firstLineHeight;
|
|
734
|
+
for (const line of lines) {
|
|
735
|
+
const lineHeight = isObject(line) ? line["lineHeight"] : undefined;
|
|
736
|
+
if (typeof lineHeight !== "number" || !(lineHeight > 0))
|
|
737
|
+
break;
|
|
738
|
+
const top = isObject(line) && typeof line["lineY"] === "number" ? line["lineY"] : bottom;
|
|
739
|
+
if (top + lineHeight > height + 0.01)
|
|
740
|
+
return Math.max(1, count);
|
|
741
|
+
count += 1;
|
|
742
|
+
bottom = top + lineHeight;
|
|
743
|
+
last = lineHeight;
|
|
744
|
+
}
|
|
745
|
+
const more = (height - bottom + 0.01) / last;
|
|
746
|
+
return Number.isFinite(more) && last > 0 ? Math.max(1, count + Math.max(0, Math.floor(more))) : undefined;
|
|
747
|
+
}
|
|
653
748
|
/** Reports the text fields Taco does not import yet, one entry for each field. */
|
|
654
|
-
function reportLeftOut(change,
|
|
655
|
-
// The text style's case applies where the node has none of its own.
|
|
656
|
-
const styles = [change, ...table.values(), ...(textStyle !== undefined && change["textCase"] === undefined ? [textStyle] : [])];
|
|
657
|
-
const textCase = styles.map((style) => field(style, "textCase", "string", where)).find((value) => value !== undefined && value !== "ORIGINAL");
|
|
658
|
-
if (textCase !== undefined)
|
|
659
|
-
report("property-left-out", `text case ${textCase} is not imported; the characters are kept as typed`);
|
|
749
|
+
function reportLeftOut(change, report, where) {
|
|
660
750
|
const truncation = field(change, "textTruncation", "string", where);
|
|
661
751
|
if (truncation !== undefined && truncation !== "DISABLED" && truncation !== "ENDING")
|
|
662
752
|
report("property-left-out", `text truncation ${truncation} is not imported`);
|
|
@@ -31,16 +31,29 @@ export interface StoredFigmaBox {
|
|
|
31
31
|
readonly transform: TransformMatrix;
|
|
32
32
|
/** Scale the component's path vertices from its Figma size to the size at this occurrence. */
|
|
33
33
|
readonly pathScale?: readonly [number, number];
|
|
34
|
+
/** A text Figma measured at the size a nested instance gives it (an entry without a size): that size, if one is
|
|
35
|
+
* stored, wins over this box, the component's. Only its size is Figma's: its constraints place it. */
|
|
36
|
+
readonly inner?: true;
|
|
34
37
|
}
|
|
35
38
|
/** The component bindings the model drops from a layer the override is applied to, so the override must write each again. */
|
|
36
39
|
export declare function bindingsDroppedBy(override: Readonly<Record<string, unknown>>): Set<string>;
|
|
40
|
+
/**
|
|
41
|
+
* `change` with the `overridden` fields merged in and without the component's bindings of the fields they change:
|
|
42
|
+
* Figma unbinds a field that an override sets, so the instance takes the override's value, not the component's variable.
|
|
43
|
+
*/
|
|
44
|
+
export declare function withOverrides(change: FigmaObject, overridden: Readonly<Record<string, unknown>>, replacesTextStyle: boolean): FigmaObject;
|
|
45
|
+
/**
|
|
46
|
+
* A `variableConsumptionMap` with the entries of an override's own map (`over`) in place of those of the same field in
|
|
47
|
+
* `map`, the component layer's.
|
|
48
|
+
*/
|
|
49
|
+
export declare function withBindingEntries(map: unknown, over: unknown): FigmaObject;
|
|
37
50
|
/**
|
|
38
51
|
* Writes `null` in each override for a binding the model would keep from a nested instance's own override (`mergeOverrides`
|
|
39
52
|
* in the model) of a field the override sets plainly. Runs once every instance has its overrides, since the nested instances
|
|
40
53
|
* along a path are finished in file order.
|
|
41
54
|
*/
|
|
42
55
|
export declare function unbindInnerBindings(overrides: Record<string, LayerOverride> | undefined, nested: ReadonlyMap<string, readonly Through[]>): void;
|
|
43
|
-
/** The key an override path step names a layer by: its `overrideKey`, else its guid. */
|
|
56
|
+
/** The key an override path step names a layer by: its `overrideKey`, else (none, or the no-key marker) its guid. */
|
|
44
57
|
export declare function overrideKeyOf(node: FigmaTreeNode): string;
|
|
45
58
|
/** A slot an instance fills, with the host frame the walk made from the content frame's children. */
|
|
46
59
|
export interface HostedSlotFill {
|
|
@@ -59,14 +72,17 @@ export interface NestedSwaps {
|
|
|
59
72
|
}
|
|
60
73
|
/** What finishing an instance needs from the walk. */
|
|
61
74
|
export interface InstanceContext {
|
|
62
|
-
/** Keeps the derived boxes for the native file adapter
|
|
63
|
-
|
|
75
|
+
/** Keeps the derived boxes for the native file adapter: `boxes` (only fill sizes when `fillOnly`), and `texts`, the
|
|
76
|
+
* boxes Figma measured for self-sizing texts outside `boxes`. */
|
|
77
|
+
fileLayout?(boxes: Map<string, StoredFigmaBox>, fillOnly: boolean, texts: Map<string, StoredFigmaBox>): void;
|
|
64
78
|
/** Captures an authored override before conversion to literal differences.
|
|
65
79
|
* @param path - Resolved reader layer path.
|
|
66
80
|
* @param change - Fields authored at this occurrence.
|
|
67
81
|
* @returns Nothing.
|
|
68
82
|
*/
|
|
69
83
|
fileOverride?(path: string, change: FigmaObject): void;
|
|
84
|
+
/** Authored fields at a resolved path inside a nested instance in a saved file. */
|
|
85
|
+
nestedTextFields?(instance: SceneNode, path: string): FigmaObject | undefined;
|
|
70
86
|
/** The enclosing instance's swaps at this reader path ("" for its own assignments). */
|
|
71
87
|
nestedSwaps(instance: SceneNode, path: string): NestedSwaps | undefined;
|
|
72
88
|
/** Whether a path segment occurs as a node GUID or override key in the source. */
|