@directededges/specs-from-figma 0.21.0 → 0.22.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.
Files changed (126) hide show
  1. package/dist/Adapters/RestApi/NodeIndexer.d.ts +118 -0
  2. package/dist/Adapters/RestApi/RestBaseNode.d.ts +271 -0
  3. package/dist/Adapters/RestApi/RestComponentNode.d.ts +30 -0
  4. package/dist/Adapters/RestApi/RestInstanceNode.d.ts +50 -0
  5. package/dist/Adapters/RestApi/RestLibraryFile.d.ts +51 -0
  6. package/dist/Adapters/RestApi/RestTextNode.d.ts +41 -0
  7. package/dist/Component/Anatomy/Anatomy.d.ts +97 -0
  8. package/dist/Component/Anatomy/AnatomyElement.d.ts +24 -0
  9. package/dist/Component/Children/Children.d.ts +96 -0
  10. package/dist/Component/Color/Color.d.ts +63 -0
  11. package/dist/Component/Component.d.ts +71 -0
  12. package/dist/Component/Effects/Blur.d.ts +41 -0
  13. package/dist/Component/Effects/Effects.d.ts +51 -0
  14. package/dist/Component/Effects/EffectsProcessor.d.ts +15 -0
  15. package/dist/Component/Effects/Shadow.d.ts +51 -0
  16. package/dist/Component/Effects/index.d.ts +4 -0
  17. package/dist/Component/Elements/BaseElement.d.ts +87 -0
  18. package/dist/Component/Elements/ElementFactory.d.ts +7 -0
  19. package/dist/Component/Elements/ElementFactoryRegistry.d.ts +21 -0
  20. package/dist/Component/Elements/Elements.d.ts +86 -0
  21. package/dist/Component/Elements/Primitives/ComponentElement.d.ts +8 -0
  22. package/dist/Component/Elements/Primitives/EllipseElement.d.ts +8 -0
  23. package/dist/Component/Elements/Primitives/FrameElement.d.ts +8 -0
  24. package/dist/Component/Elements/Primitives/GlyphElement.d.ts +21 -0
  25. package/dist/Component/Elements/Primitives/InstanceElement.d.ts +24 -0
  26. package/dist/Component/Elements/Primitives/LineElement.d.ts +8 -0
  27. package/dist/Component/Elements/Primitives/PolygonElement.d.ts +8 -0
  28. package/dist/Component/Elements/Primitives/RectangleElement.d.ts +8 -0
  29. package/dist/Component/Elements/Primitives/SlotElement.d.ts +8 -0
  30. package/dist/Component/Elements/Primitives/StarElement.d.ts +8 -0
  31. package/dist/Component/Elements/Primitives/TextElement.d.ts +8 -0
  32. package/dist/Component/Elements/Primitives/VectorElement.d.ts +8 -0
  33. package/dist/Component/Elements/index.d.ts +12 -0
  34. package/dist/Component/Gradient/Gradient.d.ts +73 -0
  35. package/dist/Component/Gradient/GradientProcessor.d.ts +18 -0
  36. package/dist/Component/Gradient/index.d.ts +2 -0
  37. package/dist/Component/InstanceExamples/InstanceExample.d.ts +35 -0
  38. package/dist/Component/InstanceExamples/InstanceExamples.d.ts +49 -0
  39. package/dist/Component/Layout/Layout.d.ts +26 -0
  40. package/dist/Component/Layout/types.d.ts +61 -0
  41. package/dist/Component/Metadata/Metadata.d.ts +13 -0
  42. package/dist/Component/Metadata/constants.d.ts +8 -0
  43. package/dist/Component/Nodes/types.d.ts +4 -0
  44. package/dist/Component/PropConfigurations/PropConfiguration.d.ts +15 -0
  45. package/dist/Component/PropConfigurations/PropConfigurations.d.ts +55 -0
  46. package/dist/Component/Props/CodeOnlyProps/BooleanCodeOnlyProp.d.ts +11 -0
  47. package/dist/Component/Props/CodeOnlyProps/CodeOnlyProps.d.ts +36 -0
  48. package/dist/Component/Props/CodeOnlyProps/InstanceCodeOnlyProp.d.ts +19 -0
  49. package/dist/Component/Props/CodeOnlyProps/TextCodeOnlyProp.d.ts +18 -0
  50. package/dist/Component/Props/CodeOnlyProps/index.d.ts +4 -0
  51. package/dist/Component/Props/PropBinding.d.ts +69 -0
  52. package/dist/Component/Props/PropPair.d.ts +16 -0
  53. package/dist/Component/Props/PropPairings.d.ts +89 -0
  54. package/dist/Component/Props/Props.d.ts +93 -0
  55. package/dist/Component/Props/SlotConstraints.d.ts +37 -0
  56. package/dist/Component/SlotContent/SlotCandidate.d.ts +42 -0
  57. package/dist/Component/SlotContent/SlotContent.d.ts +84 -0
  58. package/dist/Component/SlotContent/SlotDetector.d.ts +85 -0
  59. package/dist/Component/SlotContent/SlotItem.d.ts +44 -0
  60. package/dist/Component/SlotContent/SlotRegistry.d.ts +61 -0
  61. package/dist/Component/Styles/Composites/BiaxialComposite.d.ts +64 -0
  62. package/dist/Component/Styles/Composites/QuadComposite.d.ts +80 -0
  63. package/dist/Component/Styles/Composites/index.d.ts +4 -0
  64. package/dist/Component/Styles/Primitives/AspectRatioStyle.d.ts +34 -0
  65. package/dist/Component/Styles/Primitives/BooleanStyle.d.ts +6 -0
  66. package/dist/Component/Styles/Primitives/ColorStyle.d.ts +29 -0
  67. package/dist/Component/Styles/Primitives/ConditionalStyle.d.ts +30 -0
  68. package/dist/Component/Styles/Primitives/CornerStyle.d.ts +12 -0
  69. package/dist/Component/Styles/Primitives/EffectsStyle.d.ts +13 -0
  70. package/dist/Component/Styles/Primitives/IconFillStyle.d.ts +40 -0
  71. package/dist/Component/Styles/Primitives/MixedStyle.d.ts +5 -0
  72. package/dist/Component/Styles/Primitives/NumberStyle.d.ts +7 -0
  73. package/dist/Component/Styles/Primitives/PaddingStyle.d.ts +13 -0
  74. package/dist/Component/Styles/Primitives/StringStyle.d.ts +5 -0
  75. package/dist/Component/Styles/Primitives/StrokeStyle.d.ts +12 -0
  76. package/dist/Component/Styles/Primitives/TypographyStyle.d.ts +21 -0
  77. package/dist/Component/Styles/Primitives/index.d.ts +13 -0
  78. package/dist/Component/Styles/Primitives/mapping.d.ts +85 -0
  79. package/dist/Component/Styles/References/FigmaStyleReference.d.ts +45 -0
  80. package/dist/Component/Styles/References/FigmaVariableReference.d.ts +61 -0
  81. package/dist/Component/Styles/References/index.d.ts +24 -0
  82. package/dist/Component/Styles/Style.d.ts +88 -0
  83. package/dist/Component/Styles/Styles.d.ts +108 -0
  84. package/dist/Component/Styles/StylesProcessor.d.ts +96 -0
  85. package/dist/Component/Styles/defaults.d.ts +2 -0
  86. package/dist/Component/Styles/figmaKeyMap.d.ts +12 -0
  87. package/dist/Component/Styles/keys.d.ts +20 -0
  88. package/dist/Component/Subcomponents/Subcomponent.d.ts +20 -0
  89. package/dist/Component/Subcomponents/Subcomponents.d.ts +83 -0
  90. package/dist/Component/Typography/FontStyle.d.ts +6 -0
  91. package/dist/Component/Typography/LetterSpacingStyle.d.ts +4 -0
  92. package/dist/Component/Typography/LineHeightStyle.d.ts +4 -0
  93. package/dist/Component/Typography/Typography.d.ts +105 -0
  94. package/dist/Component/Typography/TypographyProcessor.d.ts +33 -0
  95. package/dist/Component/Typography/constants.d.ts +20 -0
  96. package/dist/Component/Typography/defaults.d.ts +30 -0
  97. package/dist/Component/Typography/keys.d.ts +12 -0
  98. package/dist/Component/Variants/Differencer.d.ts +47 -0
  99. package/dist/Component/Variants/Variant.d.ts +55 -0
  100. package/dist/Component/Variants/Variants.d.ts +91 -0
  101. package/dist/Components/Components.d.ts +68 -0
  102. package/dist/Config/types.Settings.d.ts +30 -0
  103. package/dist/Constants/ApiMappings.d.ts +31 -0
  104. package/dist/Constants/BindingKeys.d.ts +2 -0
  105. package/dist/Constants/DevSettings.d.ts +4 -0
  106. package/dist/Constants/Nodes.d.ts +1 -0
  107. package/dist/License/LicenseManager.d.ts +43 -0
  108. package/dist/License/ProxyClient.d.ts +25 -0
  109. package/dist/License/constants.d.ts +41 -0
  110. package/dist/License/types.d.ts +83 -0
  111. package/dist/Progress/PhaseConfiguration.d.ts +20 -0
  112. package/dist/Progress/Progress.d.ts +107 -0
  113. package/dist/Progress/ProgressCoordinator.d.ts +33 -0
  114. package/dist/Runtime/Context/interfaces.d.ts +73 -0
  115. package/dist/Runtime/Foundations/FigmaPluginFoundations.d.ts +37 -0
  116. package/dist/Runtime/Foundations/FigmaRESTFoundations.d.ts +72 -0
  117. package/dist/Runtime/Foundations/FigmaRESTMaps.d.ts +55 -0
  118. package/dist/Runtime/Foundations/interfaces.d.ts +72 -0
  119. package/dist/Runtime/Nodes/FigmaPluginNodes.d.ts +45 -0
  120. package/dist/Runtime/Nodes/FigmaRestNodes.d.ts +43 -0
  121. package/dist/Runtime/Nodes/NodeAccess.d.ts +23 -0
  122. package/dist/Runtime/Nodes/interfaces.d.ts +60 -0
  123. package/dist/Utilities/Utilities.d.ts +44 -0
  124. package/dist/Utilities/types.ReferenceValue.d.ts +16 -0
  125. package/dist/index.js +1 -1
  126. package/package.json +5 -5
@@ -0,0 +1,108 @@
1
+ import type { Styles as AnovaStyles } from "@directededges/specs-schema";
2
+ import { FigmaElementNode } from '../Nodes/types.js';
3
+ import { StyleKey } from './keys.js';
4
+ import { Style } from './Style.js';
5
+ import { ResolvedConfig } from '@directededges/specs-schema';
6
+ import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
7
+ export declare class Styles {
8
+ private _items;
9
+ private _node;
10
+ private _context?;
11
+ constructor(node: FigmaElementNode, context?: ProcessingContext);
12
+ /**
13
+ * Get the source Figma node
14
+ * Used by Output classes to access node properties (e.g., fills, strokes for color swatches)
15
+ */
16
+ get node(): FigmaElementNode;
17
+ get context(): ProcessingContext | undefined;
18
+ evaluate(context?: ProcessingContext, keys?: readonly string[]): void;
19
+ /**
20
+ * Merge another Styles instance onto this one.
21
+ * Layer styles take precedence over base styles.
22
+ * Performs property-level merge: base styles are preserved unless layer overrides them.
23
+ *
24
+ * @param layer - The Styles to merge onto this one
25
+ * @returns A new Styles instance with merged values
26
+ */
27
+ merge(layer: Styles): Styles;
28
+ /**
29
+ * Compare this Styles against a baseline to identify differences.
30
+ * Returns a new Styles instance containing only styles that differ.
31
+ * For composite values (Sides/Corners), produces sparse diffs with only changed fields.
32
+ *
33
+ * @param baseline - The Styles to compare against
34
+ * @returns A new Styles instance with differences, or empty if no differences
35
+ */
36
+ compare(baseline: Styles): Styles;
37
+ /**
38
+ * Relates raw Figma properties into semantic spec properties.
39
+ * Runs after evaluate() and before compare()/layer().
40
+ */
41
+ postEvaluate(): void;
42
+ postProcess(removeDefaults: boolean, fullStyles: Styles | undefined, context?: ProcessingContext): Promise<void>;
43
+ data(config: ResolvedConfig): AnovaStyles | undefined;
44
+ /**
45
+ * Removes a style by its key.
46
+ * @param key The key of the style to remove.
47
+ */
48
+ remove(key: string): void;
49
+ /**
50
+ * Copy styles from another Styles instance
51
+ * @param source Source Styles instance to copy from
52
+ * @param keys Optional set of keys to copy. If omitted, copies all styles.
53
+ */
54
+ copy(source: Styles, keys?: Set<string> | string[]): void;
55
+ /**
56
+ * Create a deep clone of this Styles instance.
57
+ *
58
+ * @returns A new Styles instance with cloned style objects
59
+ */
60
+ clone(): Styles;
61
+ get(key: StyleKey): Style | undefined;
62
+ set(key: StyleKey, style: Style): void;
63
+ has(key: StyleKey): boolean;
64
+ /**
65
+ * Returns an iterator over [styleKey, style] entries.
66
+ * @example
67
+ * for (const [key, style] of styles.entries()) {
68
+ * console.log(key, style);
69
+ * }
70
+ */
71
+ entries(): IterableIterator<[StyleKey, Style]>;
72
+ /**
73
+ * Returns an iterator over style values.
74
+ * @example
75
+ * for (const style of styles.values()) {
76
+ * await style.process();
77
+ * }
78
+ */
79
+ values(): IterableIterator<Style>;
80
+ /**
81
+ * Returns an iterator over style keys.
82
+ * @example
83
+ * for (const key of styles.keys()) {
84
+ * console.log(key);
85
+ * }
86
+ */
87
+ keys(): IterableIterator<StyleKey>;
88
+ /**
89
+ * Makes Styles directly iterable (defaults to entries).
90
+ * @example
91
+ * for (const [key, style] of styles) {
92
+ * console.log(key, style);
93
+ * }
94
+ */
95
+ [Symbol.iterator](): IterableIterator<[StyleKey, Style]>;
96
+ /**
97
+ * Returns the number of styles in the collection.
98
+ */
99
+ get size(): number;
100
+ /**
101
+ * Checks if the collection is empty.
102
+ * @example
103
+ * if (styles.isEmpty()) {
104
+ * return;
105
+ * }
106
+ */
107
+ isEmpty(): boolean;
108
+ }
@@ -0,0 +1,96 @@
1
+ import { Styles } from './Styles';
2
+ import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
3
+ export declare class StylesProcessor {
4
+ /**
5
+ * Relates raw Figma properties into semantic spec properties.
6
+ * Runs after evaluate() and before layer() so computed values
7
+ * are available for variant differencing.
8
+ */
9
+ static postEvaluate(styles: Styles): void;
10
+ /**
11
+ * Performs all post-processing steps on the given Styles instance.
12
+ * Runs after layer() — handles name resolution, defaults removal,
13
+ * and text-style/typography relationships.
14
+ * @param styles The Styles object to process.
15
+ * @param removeDefaults Whether to remove default styles.
16
+ * @param fullStyles The full styles for comparison.
17
+ * @param context Optional processing context with dataLoader
18
+ */
19
+ static postProcess(styles: Styles, removeDefaults: boolean, fullStyles: Styles | undefined, context?: ProcessingContext): Promise<void>;
20
+ /**
21
+ * Removes default styles from the given Styles object.
22
+ * @param styles The Styles object to process.
23
+ */
24
+ private static removeDefaults;
25
+ /**
26
+ * Resolves variable names within SidesQuadComposite and CornersQuadComposite values.
27
+ * @param styles The Styles object to process.
28
+ * @param context Optional processing context
29
+ */
30
+ private static lookupQuadCompositeVariables;
31
+ /**
32
+ * Resolves variable names within BiaxialComposite values.
33
+ * @param styles The Styles object to process.
34
+ * @param context Optional processing context
35
+ */
36
+ private static lookupBiaxialCompositeVariables;
37
+ /**
38
+ *
39
+ * Relates layout sizing and auto-layout styles.
40
+ * @param styles The Styles object to process.
41
+ */
42
+ private static relateLayoutSizingAndAutoLayout;
43
+ /**
44
+ * Maps Figma constraints to directional positioning properties (ADR-041).
45
+ *
46
+ * Reads the parent's layout mode and the child's positioning context to determine
47
+ * which offset properties to emit. Each axis is mapped independently (FR-013).
48
+ *
49
+ * Context rules (FR-012):
50
+ * - Parent layoutMode NONE (regular frame): offsets + position null
51
+ * - Auto-layout + ABSOLUTE child: offsets + position "ABSOLUTE"
52
+ * - Auto-layout + AUTO child: position "AUTO", no offsets
53
+ * - Top-level (no parent) or COMPONENT root: position null, no offsets
54
+ */
55
+ private static relateAutoVsAbsoluteLayout;
56
+ /**
57
+ * Maps a single-axis constraint to the appropriate offset property/properties.
58
+ */
59
+ private static mapAxisConstraint;
60
+ /**
61
+ * Creates a Style for an offset key and sets a computed value on it.
62
+ * Accepts null to explicitly mark a key as "no value" (needed for variant differencing).
63
+ */
64
+ private static setOffsetStyle;
65
+ /**
66
+ * Removes wrapAlignment when wrap is not active — it's a dead property otherwise.
67
+ */
68
+ private static relateWrapAndWrapAlignment;
69
+ private static relateTextStyleAndTextProperties;
70
+ /**
71
+ * Looks up and updates a Figma style name (text or effect) for the given Styles instance.
72
+ * @param styles The Styles object to process.
73
+ * @param styleKey The style key to look up ('textStyleId').
74
+ * @param context Optional processing context
75
+ */
76
+ private static lookupFigmaStyleName;
77
+ /**
78
+ * Looks up and updates color style names for fills and strokes.
79
+ * Only performs lookup if the style type is 'STYLE'.
80
+ * @param styles The Styles object to process.
81
+ * @param context Optional processing context
82
+ */
83
+ private static lookupColorStyleNames;
84
+ /**
85
+ * Looks up and updates variables for the given Styles instance.
86
+ * @param styles The Styles object to process.
87
+ * @param context Optional processing context
88
+ */
89
+ private static lookupVariables;
90
+ /**
91
+ * Looks up and updates gradient stop variables for any gradient styles.
92
+ * @param styles The Styles object to process.
93
+ * @param context Optional processing context
94
+ */
95
+ private static lookupGradientVariables;
96
+ }
@@ -0,0 +1,2 @@
1
+ import { StyleKey } from "./keys.js";
2
+ export declare const STYLE_DEFAULTS: Record<StyleKey, string | number | boolean | null>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Maps transformer spec output keys to their corresponding Figma node property keys.
3
+ * Only keys that differ need an entry — all others fall through to identity.
4
+ *
5
+ * This is the single source of truth for any transformer output key that diverges
6
+ * from its Figma node property name. Add new entries here as more semantic renames land.
7
+ */
8
+ export declare const SPEC_TO_FIGMA_KEY_MAP: Readonly<Record<string, string>>;
9
+ /** Resolve a spec-layer output key to the Figma node property key to read from. */
10
+ export declare function toFigmaKey(specKey: string): string;
11
+ /** All spec keys that map to `node.fills`. */
12
+ export declare const FILL_SPEC_KEYS: ReadonlyArray<string>;
@@ -0,0 +1,20 @@
1
+ export declare const STYLE_KEYS: {
2
+ ALL: string[];
3
+ STROKE_SIDES: string[];
4
+ CORNERS: string[];
5
+ PADDING_SIDES: string[];
6
+ COMPONENT: string[];
7
+ FRAME: string[];
8
+ SLOT: string[];
9
+ INSTANCE: string[];
10
+ GLYPH: string[];
11
+ TEXT: string[];
12
+ VECTOR: string[];
13
+ RECTANGLE: string[];
14
+ LINE: string[];
15
+ STAR: string[];
16
+ POLYGON: string[];
17
+ ELLIPSE: string[];
18
+ };
19
+ export type StyleKey = typeof STYLE_KEYS.ALL[number];
20
+ export type Side = 'TOP' | 'BOTTOM' | 'LEFT' | 'RIGHT';
@@ -0,0 +1,20 @@
1
+ import { Component } from "../Component.js";
2
+ import { SpecableNode } from '../Nodes/types.js';
3
+ import { ResolvedConfig } from '@directededges/specs-schema';
4
+ import { Subcomponent as AnovaSubcomponent } from '@directededges/specs-schema';
5
+ import { Anatomy } from '../Anatomy/Anatomy.js';
6
+ import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
7
+ export declare class Subcomponent extends Component {
8
+ private _parentComponentName?;
9
+ private _subcomponentKey?;
10
+ constructor(node: SpecableNode, config: ResolvedConfig);
11
+ /** Called by Subcomponents before process() to set path context for $extensions pointers. */
12
+ setPathContext(parentComponentName: string, subcomponentKey: string): void;
13
+ process(context?: ProcessingContext): Promise<void>;
14
+ protected _slotBasePath(): string;
15
+ /**
16
+ * Get the anatomy for this subcomponent (internal use only)
17
+ */
18
+ getAnatomy(): Anatomy;
19
+ data(): AnovaSubcomponent;
20
+ }
@@ -0,0 +1,83 @@
1
+ import { ResolvedConfig, Subcomponents as AnovaSubcomponents } from "@directededges/specs-schema";
2
+ import { Anatomy } from '../Anatomy/Anatomy.js';
3
+ import type { Subcomponent } from './Subcomponent.js';
4
+ import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
5
+ export declare class Subcomponents {
6
+ private _items;
7
+ private _refMap;
8
+ private config;
9
+ constructor(config: ResolvedConfig);
10
+ private createSubcomponent;
11
+ /**
12
+ * Check if a name matches any of the given template patterns.
13
+ * Patterns use {C} (component name) and {S} (subcomponent name) placeholders.
14
+ * Short-circuits on first match, returning the captured subcomponent name or null.
15
+ */
16
+ static matchesPatterns(name: string, patterns: string[], componentName: string): string | null;
17
+ /**
18
+ * Check if a name matches any exclude pattern.
19
+ * Returns true if the name should be excluded.
20
+ */
21
+ private matchesExclude;
22
+ private evaluateAnatomy;
23
+ /**
24
+ * Scan page-level COMPONENT/COMPONENT_SET nodes for additional subcomponents.
25
+ * Only called when scope is PAGE. Additive — never replaces anatomy-detected subcomponents.
26
+ */
27
+ private evaluatePage;
28
+ evaluate(componentName: string, anatomy: Anatomy, context?: ProcessingContext, rootNodeId?: string): Promise<void>;
29
+ data(_config: ResolvedConfig, _removeExcludedMembers?: boolean, _defaultVariant?: boolean): AnovaSubcomponents | undefined;
30
+ /**
31
+ * Build a formatted ref map: formatted instanceOf → formatted subcomponent key.
32
+ * Used by data serialization to emit `{ $ref: '#/subcomponents/{key}' }`.
33
+ */
34
+ refMap(keyFormat: ResolvedConfig['format']['keys']): Map<string, string>;
35
+ get(name: string): Subcomponent | undefined;
36
+ set(name: string, subcomponent: Subcomponent): void;
37
+ has(name: string): boolean;
38
+ delete(name: string): void;
39
+ /**
40
+ * Returns an iterator over [name, subcomponent] entries.
41
+ * @example
42
+ * for (const [name, subcomponent] of subcomponents.entries()) {
43
+ * console.log(name, subcomponent);
44
+ * }
45
+ */
46
+ entries(): IterableIterator<[string, Subcomponent]>;
47
+ /**
48
+ * Returns an iterator over subcomponent values.
49
+ * @example
50
+ * for (const subcomponent of subcomponents.values()) {
51
+ * await subcomponent.process();
52
+ * }
53
+ */
54
+ values(): IterableIterator<Subcomponent>;
55
+ /**
56
+ * Returns an iterator over subcomponent names.
57
+ * @example
58
+ * for (const name of subcomponents.keys()) {
59
+ * console.log(name);
60
+ * }
61
+ */
62
+ keys(): IterableIterator<string>;
63
+ /**
64
+ * Makes Subcomponents directly iterable (defaults to entries).
65
+ * @example
66
+ * for (const [name, subcomponent] of subcomponents) {
67
+ * console.log(name, subcomponent);
68
+ * }
69
+ */
70
+ [Symbol.iterator](): IterableIterator<[string, Subcomponent]>;
71
+ /**
72
+ * Returns the number of subcomponents in the collection.
73
+ */
74
+ get size(): number;
75
+ /**
76
+ * Checks if the collection is empty.
77
+ * @example
78
+ * if (subcomponents.isEmpty()) {
79
+ * return;
80
+ * }
81
+ */
82
+ isEmpty(): boolean;
83
+ }
@@ -0,0 +1,6 @@
1
+ import { StyleKey } from '../Styles/keys.js';
2
+ import { RawStyle } from '../Styles/Style.js';
3
+ import { FigmaElementNode } from '../Nodes/types.js';
4
+ export declare class FontStyle {
5
+ static value(node: FigmaElementNode, key: StyleKey): RawStyle | null;
6
+ }
@@ -0,0 +1,4 @@
1
+ import { RawStyle } from '../Styles/Style.js';
2
+ export declare class LetterSpacingStyle {
3
+ static value(node: TextNode): RawStyle | null;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { RawStyle } from '../Styles/Style.js';
2
+ export declare class LineHeightStyle {
3
+ static value(node: TextNode): RawStyle | null;
4
+ }
@@ -0,0 +1,105 @@
1
+ import type { Typography as AnovaTypography, ResolvedConfig } from '@directededges/specs-schema';
2
+ import { FigmaVariableReference } from '../Styles/References/index.js';
3
+ import { type ProcessingContext } from '../../Runtime/Context/interfaces.js';
4
+ /**
5
+ * Typography - First-class component representing all typography-related properties.
6
+ *
7
+ * Consolidates 13 individual typography properties into a single composite entity,
8
+ * matching the Effects and Gradient pattern. Typography instances can represent:
9
+ * - Inline typography (13 individual properties evaluated from node)
10
+ * - Mixed values (when text runs have different values)
11
+ * - Variable bindings (fontSize, lineHeight, letterSpacing, paragraphSpacing)
12
+ * - Explicit null (property removed/unset in variant)
13
+ *
14
+ * @see Effects for similar pattern (composite component with property-level diffing)
15
+ */
16
+ export declare class Typography {
17
+ fontSize?: number | FigmaVariableReference | 'Figma mixed' | null;
18
+ fontFamily?: string | FigmaVariableReference | 'Figma mixed' | null;
19
+ fontStyle?: string | FigmaVariableReference | 'Figma mixed' | null;
20
+ lineHeight?: number | FigmaVariableReference | 'Figma mixed' | null;
21
+ letterSpacing?: number | FigmaVariableReference | 'Figma mixed' | null;
22
+ textCase?: string | 'Figma mixed' | null;
23
+ textDecoration?: string | 'Figma mixed' | null;
24
+ paragraphIndent?: number | FigmaVariableReference | 'Figma mixed' | null;
25
+ paragraphSpacing?: number | FigmaVariableReference | 'Figma mixed' | null;
26
+ leadingTrim?: string | 'Figma mixed' | null;
27
+ listSpacing?: number | 'Figma mixed' | null;
28
+ hangingPunctuation?: boolean | 'Figma mixed' | null;
29
+ hangingList?: boolean | 'Figma mixed' | null;
30
+ /**
31
+ * Evaluate typography properties from a TextNode.
32
+ *
33
+ * Delegates to existing style primitives (FontStyle, NumberStyle, LineHeightStyle,
34
+ * MixedStyle, BooleanStyle) to evaluate each property. Checks for variable bindings
35
+ * on VARIABLE_PROPERTIES before calling primitives. Returns null if all properties
36
+ * are undefined (no typography data present).
37
+ *
38
+ * @param node - Figma TextNode to evaluate
39
+ * @returns Typography instance or null if empty
40
+ */
41
+ static evaluate(node: TextNode, context?: ProcessingContext): Typography | null;
42
+ /**
43
+ * Returns true when no typography property has been set.
44
+ * Used to determine if Typography key should be omitted from output.
45
+ */
46
+ isEmpty(): boolean;
47
+ /**
48
+ * Serialize Typography to output format.
49
+ *
50
+ * - Omits undefined properties
51
+ * - Includes null properties explicitly as null
52
+ * - Calls instance.data(config) for FigmaVariableReference properties
53
+ * - Returns partial object (only includes defined properties)
54
+ *
55
+ * @param config - Transformation configuration
56
+ * @returns Typography object (using AnovaTypography from @directededges/specs-schema)
57
+ */
58
+ data(config: ResolvedConfig): AnovaTypography;
59
+ /**
60
+ * Serialize a property value, calling instance.data(config) for FigmaVariableReference.
61
+ *
62
+ * @param value - Property value to serialize
63
+ * @param config - Transformation configuration
64
+ * @returns Serialized value
65
+ */
66
+ private serializeProperty;
67
+ /**
68
+ * Create a deep copy of this Typography instance.
69
+ *
70
+ * - Calls instance.clone() for FigmaVariableReference instances
71
+ * - Preserves null vs undefined distinction
72
+ *
73
+ * @returns New Typography instance
74
+ */
75
+ clone(): Typography;
76
+ /**
77
+ * Clone a field value, calling instance.clone() for FigmaVariableReference.
78
+ */
79
+ private cloneField;
80
+ /**
81
+ * Property-level comparison with base Typography.
82
+ *
83
+ * Returns true if ANY property differs. Compares:
84
+ * - Existence first (!!this.prop !== !!base.prop)
85
+ * - Calls instance.difference() for FigmaVariableReference instances
86
+ * - null ≠ undefined, null ≠ any value, undefined ≠ any defined value
87
+ *
88
+ * @param base - Base Typography to compare against
89
+ * @returns true if any property differs
90
+ */
91
+ difference(base: Typography): boolean;
92
+ /**
93
+ * Compare two field values for difference.
94
+ * Handles existence, primitives, FigmaVariableReference instances, 'Figma mixed', and null.
95
+ */
96
+ private differField;
97
+ /**
98
+ * Whole-group replacement: returns typography.clone().
99
+ * When merging two Typography objects, the typography completely replaces the base with no property inheritance.
100
+ *
101
+ * @param typography - The Typography instance to merge onto this one
102
+ * @returns A cloned copy of the typography Typography
103
+ */
104
+ merge(typography: Typography): Typography;
105
+ }
@@ -0,0 +1,33 @@
1
+ import { Style } from '../Styles/Style.js';
2
+ import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
3
+ /**
4
+ * Post-processes a `typography` Style after initial evaluation.
5
+ *
6
+ * Handles two paths:
7
+ * 1. FigmaStyleReference: resolves the `.name` field via resolveName().
8
+ * 2. Typography: resolves FigmaVariableReference fields and optionally removes defaults.
9
+ *
10
+ * Called from `StylesProcessor.postProcess()` for the `typography` style key.
11
+ */
12
+ export declare class TypographyProcessor {
13
+ /**
14
+ * Performs all post-processing steps on a typography Style.
15
+ * @param style The typography Style to process
16
+ * @param context Optional processing context with foundations
17
+ * @param removeDefaults Whether to remove default values
18
+ */
19
+ static postProcess(style: Style | undefined, context?: ProcessingContext, removeDefaults?: boolean): Promise<void>;
20
+ /**
21
+ * Resolves FigmaVariableReference fields to named variables.
22
+ * Processes fontSize, lineHeight, letterSpacing, paragraphSpacing.
23
+ * @param typography The Typography instance to process
24
+ * @param context Optional processing context with foundations
25
+ */
26
+ private static lookupVariables;
27
+ /**
28
+ * Removes typography properties that match their default values.
29
+ * Properties matching TYPOGRAPHY_DEFAULTS are set to undefined.
30
+ * @param typography The Typography instance to process
31
+ */
32
+ private static removeDefaults;
33
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Typography properties that support variable bindings.
3
+ *
4
+ * These properties can be bound to Figma variables:
5
+ * - fontSize - Font size in pixels (number variable)
6
+ * - fontFamily - Font family name (string variable)
7
+ * - fontStyle - Font style/weight (string variable)
8
+ * - lineHeight - Line height (pixels or %) (number variable)
9
+ * - letterSpacing - Letter spacing (pixels or %) (number variable)
10
+ * - paragraphIndent - First line indent in pixels (number variable)
11
+ * - paragraphSpacing - Space between paragraphs in pixels (number variable)
12
+ * - listSpacing - Space between list items in pixels (number variable)
13
+ *
14
+ * Used by TypographyProcessor.postProcess() to resolve FigmaVariableReference.id
15
+ * to FigmaVariableReference.name via instance.resolveName().
16
+ *
17
+ * @see TypographyProcessor for variable name resolution
18
+ * @see Typography for property types (string|number | FigmaVariableReference | 'Figma mixed' | null)
19
+ */
20
+ export declare const VARIABLE_PROPERTIES: readonly ["fontSize", "fontFamily", "fontStyle", "lineHeight", "letterSpacing", "paragraphIndent", "paragraphSpacing"];
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Default values for Typography properties.
3
+ *
4
+ * Used for default removal logic during evaluation of the default variant.
5
+ * When a property's evaluated value matches its default, it's omitted from
6
+ * output to keep the base component minimal (existing transformer behavior).
7
+ *
8
+ * Note: textStyleId (now handled as FigmaStyleReferenceData reference) is not included here.
9
+ * TypographyStyle.value() checks for textStyleId separately before delegating
10
+ * to Typography.evaluate().
11
+ *
12
+ * @see Typography.evaluate() for default removal implementation
13
+ * @see data-model.md for null vs undefined semantics
14
+ */
15
+ export declare const TYPOGRAPHY_DEFAULTS: {
16
+ readonly fontSize: 16;
17
+ readonly fontFamily: null;
18
+ readonly fontStyle: null;
19
+ readonly textCase: "ORIGINAL";
20
+ readonly textDecoration: "NONE";
21
+ readonly letterSpacing: 0;
22
+ readonly lineHeight: "AUTO";
23
+ readonly paragraphIndent: 0;
24
+ readonly paragraphSpacing: 0;
25
+ readonly leadingTrim: "NONE";
26
+ readonly listSpacing: 0;
27
+ readonly hangingPunctuation: false;
28
+ readonly hangingList: false;
29
+ };
30
+ export type TypographyProperty = keyof typeof TYPOGRAPHY_DEFAULTS;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Typography property keys (internal to Typography component).
3
+ *
4
+ * This constant lists all 13 typography properties for iteration in:
5
+ * - Typography.isEmpty() - checking if all properties are undefined
6
+ * - Typography.data() - serializing defined properties
7
+ * - Typography.difference() - comparing properties with base
8
+ *
9
+ * These are internal to the Typography component and separate from the
10
+ * central STYLE_KEYS (which contains 'typography' as a single key).
11
+ */
12
+ export declare const TYPOGRAPHY_KEYS: readonly ["fontSize", "fontFamily", "fontStyle", "lineHeight", "letterSpacing", "textCase", "textDecoration", "paragraphIndent", "paragraphSpacing", "leadingTrim", "listSpacing", "hangingPunctuation", "hangingList"];
@@ -0,0 +1,47 @@
1
+ import { Variant } from './Variant.js';
2
+ import { Elements } from '../Elements/Elements.js';
3
+ import { BaseElement } from '../Elements/BaseElement.js';
4
+ import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
5
+ /**
6
+ * Utility class for establishing element parity between variants during the difference operation.
7
+ * Ensures that baseline and current variants have matching element sets before comparison.
8
+ */
9
+ export declare class Differencer {
10
+ constructor();
11
+ /**
12
+ * Ensures the baseline variant has all elements present in the current variant.
13
+ * For any element in the current variant missing from the baseline, adds a fallback
14
+ * element to the baseline to enable proper comparison.
15
+ *
16
+ * @param baseVariantFull - The baseline variant's full element collection to modify
17
+ * @param currentVariant - The current variant being differenced
18
+ * @param layeredMatches - Array of layeredMatches to search for fallback elements (DEFAULT is [0])
19
+ * @param context - Processing context for license-aware evaluation
20
+ * @returns Promise that resolves when all missing elements have been added
21
+ */
22
+ static establishBaselineParity(baseVariantFull: Elements, currentVariant: Variant, layeredMatches: Variant[], context?: ProcessingContext): Promise<void>;
23
+ /**
24
+ * Finds a fallback element for baseline parity by searching layeredMatches.
25
+ * Instead of traversing baseline chain, searches through all provided layeredMatches.
26
+ * If not found in any layeredMatch, adds to default variant (layeredMatches[0]).
27
+ *
28
+ * @param currentVariant - The current variant needing the fallback element
29
+ * @param elementName - The name of the element to find
30
+ * @param layeredMatches - Array of layeredMatches to search (DEFAULT is [0])
31
+ * @param context - Processing context for license-aware evaluation
32
+ * @returns Promise resolving to the fallback BaseElement
33
+ */
34
+ static baseFallbackElement(currentVariant: Variant, elementName: string, layeredMatches: Variant[], context?: ProcessingContext): Promise<BaseElement>;
35
+ /**
36
+ * Adds an element to the default variant's element collection.
37
+ * Used when an element doesn't exist in any baseline variant and must be
38
+ * added to the default variant to maintain parity.
39
+ *
40
+ * @param variant - The variant containing the element to add
41
+ * @param elementName - The name of the element to add to default
42
+ * @param defaultVariant - The default variant to receive the new element
43
+ * @param context - Processing context for license-aware evaluation
44
+ * @returns Promise resolving to the newly created BaseElement
45
+ */
46
+ static addElementToDefault(variant: Variant, elementName: string, defaultVariant: Variant, context?: ProcessingContext): Promise<BaseElement>;
47
+ }