@directededges/specs-from-figma 0.20.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.
- package/dist/Adapters/RestApi/NodeIndexer.d.ts +118 -0
- package/dist/Adapters/RestApi/RestBaseNode.d.ts +271 -0
- package/dist/Adapters/RestApi/RestComponentNode.d.ts +30 -0
- package/dist/Adapters/RestApi/RestInstanceNode.d.ts +50 -0
- package/dist/Adapters/RestApi/RestLibraryFile.d.ts +51 -0
- package/dist/Adapters/RestApi/RestTextNode.d.ts +41 -0
- package/dist/Component/Anatomy/Anatomy.d.ts +97 -0
- package/dist/Component/Anatomy/AnatomyElement.d.ts +24 -0
- package/dist/Component/Children/Children.d.ts +96 -0
- package/dist/Component/Color/Color.d.ts +63 -0
- package/dist/Component/Component.d.ts +71 -0
- package/dist/Component/Effects/Blur.d.ts +41 -0
- package/dist/Component/Effects/Effects.d.ts +51 -0
- package/dist/Component/Effects/EffectsProcessor.d.ts +15 -0
- package/dist/Component/Effects/Shadow.d.ts +51 -0
- package/dist/Component/Effects/index.d.ts +4 -0
- package/dist/Component/Elements/BaseElement.d.ts +87 -0
- package/dist/Component/Elements/ElementFactory.d.ts +7 -0
- package/dist/Component/Elements/ElementFactoryRegistry.d.ts +21 -0
- package/dist/Component/Elements/Elements.d.ts +86 -0
- package/dist/Component/Elements/Primitives/ComponentElement.d.ts +8 -0
- package/dist/Component/Elements/Primitives/EllipseElement.d.ts +8 -0
- package/dist/Component/Elements/Primitives/FrameElement.d.ts +8 -0
- package/dist/Component/Elements/Primitives/GlyphElement.d.ts +21 -0
- package/dist/Component/Elements/Primitives/InstanceElement.d.ts +24 -0
- package/dist/Component/Elements/Primitives/LineElement.d.ts +8 -0
- package/dist/Component/Elements/Primitives/PolygonElement.d.ts +8 -0
- package/dist/Component/Elements/Primitives/RectangleElement.d.ts +8 -0
- package/dist/Component/Elements/Primitives/SlotElement.d.ts +8 -0
- package/dist/Component/Elements/Primitives/StarElement.d.ts +8 -0
- package/dist/Component/Elements/Primitives/TextElement.d.ts +8 -0
- package/dist/Component/Elements/Primitives/VectorElement.d.ts +8 -0
- package/dist/Component/Elements/index.d.ts +12 -0
- package/dist/Component/Gradient/Gradient.d.ts +73 -0
- package/dist/Component/Gradient/GradientProcessor.d.ts +18 -0
- package/dist/Component/Gradient/index.d.ts +2 -0
- package/dist/Component/InstanceExamples/InstanceExample.d.ts +35 -0
- package/dist/Component/InstanceExamples/InstanceExamples.d.ts +49 -0
- package/dist/Component/Layout/Layout.d.ts +26 -0
- package/dist/Component/Layout/types.d.ts +61 -0
- package/dist/Component/Metadata/Metadata.d.ts +13 -0
- package/dist/Component/Metadata/constants.d.ts +8 -0
- package/dist/Component/Nodes/types.d.ts +4 -0
- package/dist/Component/PropConfigurations/PropConfiguration.d.ts +15 -0
- package/dist/Component/PropConfigurations/PropConfigurations.d.ts +55 -0
- package/dist/Component/Props/CodeOnlyProps/BooleanCodeOnlyProp.d.ts +11 -0
- package/dist/Component/Props/CodeOnlyProps/CodeOnlyProps.d.ts +36 -0
- package/dist/Component/Props/CodeOnlyProps/InstanceCodeOnlyProp.d.ts +19 -0
- package/dist/Component/Props/CodeOnlyProps/TextCodeOnlyProp.d.ts +18 -0
- package/dist/Component/Props/CodeOnlyProps/index.d.ts +4 -0
- package/dist/Component/Props/PropBinding.d.ts +69 -0
- package/dist/Component/Props/PropPair.d.ts +16 -0
- package/dist/Component/Props/PropPairings.d.ts +89 -0
- package/dist/Component/Props/Props.d.ts +93 -0
- package/dist/Component/Props/SlotConstraints.d.ts +37 -0
- package/dist/Component/SlotContent/SlotCandidate.d.ts +42 -0
- package/dist/Component/SlotContent/SlotContent.d.ts +84 -0
- package/dist/Component/SlotContent/SlotDetector.d.ts +85 -0
- package/dist/Component/SlotContent/SlotItem.d.ts +44 -0
- package/dist/Component/SlotContent/SlotRegistry.d.ts +61 -0
- package/dist/Component/Styles/Composites/BiaxialComposite.d.ts +64 -0
- package/dist/Component/Styles/Composites/QuadComposite.d.ts +80 -0
- package/dist/Component/Styles/Composites/index.d.ts +4 -0
- package/dist/Component/Styles/Primitives/AspectRatioStyle.d.ts +34 -0
- package/dist/Component/Styles/Primitives/BooleanStyle.d.ts +6 -0
- package/dist/Component/Styles/Primitives/ColorStyle.d.ts +29 -0
- package/dist/Component/Styles/Primitives/ConditionalStyle.d.ts +30 -0
- package/dist/Component/Styles/Primitives/CornerStyle.d.ts +12 -0
- package/dist/Component/Styles/Primitives/EffectsStyle.d.ts +13 -0
- package/dist/Component/Styles/Primitives/IconFillStyle.d.ts +40 -0
- package/dist/Component/Styles/Primitives/MixedStyle.d.ts +5 -0
- package/dist/Component/Styles/Primitives/NumberStyle.d.ts +7 -0
- package/dist/Component/Styles/Primitives/PaddingStyle.d.ts +13 -0
- package/dist/Component/Styles/Primitives/StringStyle.d.ts +5 -0
- package/dist/Component/Styles/Primitives/StrokeStyle.d.ts +12 -0
- package/dist/Component/Styles/Primitives/TypographyStyle.d.ts +21 -0
- package/dist/Component/Styles/Primitives/index.d.ts +13 -0
- package/dist/Component/Styles/Primitives/mapping.d.ts +85 -0
- package/dist/Component/Styles/References/FigmaStyleReference.d.ts +45 -0
- package/dist/Component/Styles/References/FigmaVariableReference.d.ts +61 -0
- package/dist/Component/Styles/References/index.d.ts +24 -0
- package/dist/Component/Styles/Style.d.ts +88 -0
- package/dist/Component/Styles/Styles.d.ts +108 -0
- package/dist/Component/Styles/StylesProcessor.d.ts +96 -0
- package/dist/Component/Styles/defaults.d.ts +2 -0
- package/dist/Component/Styles/figmaKeyMap.d.ts +12 -0
- package/dist/Component/Styles/keys.d.ts +20 -0
- package/dist/Component/Subcomponents/Subcomponent.d.ts +20 -0
- package/dist/Component/Subcomponents/Subcomponents.d.ts +83 -0
- package/dist/Component/Typography/FontStyle.d.ts +6 -0
- package/dist/Component/Typography/LetterSpacingStyle.d.ts +4 -0
- package/dist/Component/Typography/LineHeightStyle.d.ts +4 -0
- package/dist/Component/Typography/Typography.d.ts +105 -0
- package/dist/Component/Typography/TypographyProcessor.d.ts +33 -0
- package/dist/Component/Typography/constants.d.ts +20 -0
- package/dist/Component/Typography/defaults.d.ts +30 -0
- package/dist/Component/Typography/keys.d.ts +12 -0
- package/dist/Component/Variants/Differencer.d.ts +47 -0
- package/dist/Component/Variants/Variant.d.ts +55 -0
- package/dist/Component/Variants/Variants.d.ts +91 -0
- package/dist/Components/Components.d.ts +68 -0
- package/dist/Config/types.Settings.d.ts +30 -0
- package/dist/Constants/ApiMappings.d.ts +31 -0
- package/dist/Constants/BindingKeys.d.ts +2 -0
- package/dist/Constants/DevSettings.d.ts +4 -0
- package/dist/Constants/Nodes.d.ts +1 -0
- package/dist/License/LicenseManager.d.ts +43 -0
- package/dist/License/ProxyClient.d.ts +25 -0
- package/dist/License/constants.d.ts +41 -0
- package/dist/License/types.d.ts +83 -0
- package/dist/Progress/PhaseConfiguration.d.ts +20 -0
- package/dist/Progress/Progress.d.ts +107 -0
- package/dist/Progress/ProgressCoordinator.d.ts +33 -0
- package/dist/Runtime/Context/interfaces.d.ts +73 -0
- package/dist/Runtime/Foundations/FigmaPluginFoundations.d.ts +37 -0
- package/dist/Runtime/Foundations/FigmaRESTFoundations.d.ts +72 -0
- package/dist/Runtime/Foundations/FigmaRESTMaps.d.ts +55 -0
- package/dist/Runtime/Foundations/interfaces.d.ts +72 -0
- package/dist/Runtime/Nodes/FigmaPluginNodes.d.ts +45 -0
- package/dist/Runtime/Nodes/FigmaRestNodes.d.ts +43 -0
- package/dist/Runtime/Nodes/NodeAccess.d.ts +23 -0
- package/dist/Runtime/Nodes/interfaces.d.ts +60 -0
- package/dist/Utilities/Utilities.d.ts +44 -0
- package/dist/Utilities/types.ReferenceValue.d.ts +16 -0
- package/dist/index.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
2
|
+
import { Children as AnovaChildren, PropBinding as AnovaPropBinding } from "@directededges/specs-schema";
|
|
3
|
+
import { FigmaElementNode } from "../Nodes/types.js";
|
|
4
|
+
import { type ProcessingContext } from '../../Runtime/Context/interfaces.js';
|
|
5
|
+
export declare class Children {
|
|
6
|
+
private _items;
|
|
7
|
+
private _binding;
|
|
8
|
+
private _examples;
|
|
9
|
+
private config;
|
|
10
|
+
constructor(config: ResolvedConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Populate children from a Figma node's children or slot reference.
|
|
13
|
+
* Clears any binding reference since items and binding are mutually exclusive.
|
|
14
|
+
* @param node A Figma node to extract children from
|
|
15
|
+
*/
|
|
16
|
+
evaluate(node: FigmaElementNode, propRefs?: Record<string, string>, context?: ProcessingContext): void;
|
|
17
|
+
/**
|
|
18
|
+
* Set the children value - either items array or binding reference.
|
|
19
|
+
* Items and binding are mutually exclusive; setting one clears the other.
|
|
20
|
+
* @param value Array of child names or a AnovaPropBinding binding
|
|
21
|
+
*/
|
|
22
|
+
set(value: string[] | AnovaPropBinding): void;
|
|
23
|
+
/**
|
|
24
|
+
* Check if this children property is bound to a prop.
|
|
25
|
+
* @returns true if bound, false otherwise
|
|
26
|
+
*/
|
|
27
|
+
isBound(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if children is empty (no items, not bound, no example fills).
|
|
30
|
+
* An example reference alone is a meaningful difference and is not empty.
|
|
31
|
+
* @returns true if empty, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
empty(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* @param layer - The Children to merge onto this one
|
|
36
|
+
* @returns A new Children instance with merged values
|
|
37
|
+
*/
|
|
38
|
+
merge(layer: Children): Children;
|
|
39
|
+
/**
|
|
40
|
+
* @param baseline - The Children to compare against
|
|
41
|
+
* @returns A new Children instance with differences, or empty if no differences
|
|
42
|
+
*/
|
|
43
|
+
compare(baseline: Children): Children;
|
|
44
|
+
private static _examplesEqual;
|
|
45
|
+
/**
|
|
46
|
+
* Set the slot fill example reference (ADR-047) for this slot binding.
|
|
47
|
+
* Called before data() is invoked; data() emits `examples` when set.
|
|
48
|
+
* Currently a single reference — Figma's default fill for the slot layer.
|
|
49
|
+
*/
|
|
50
|
+
setExample(pointer: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Get the children data formatted according to settings.
|
|
53
|
+
* Returns a SlotBinding (with optional `examples`) if bound,
|
|
54
|
+
* otherwise formatted children array.
|
|
55
|
+
*/
|
|
56
|
+
data(): AnovaChildren | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Get the children value - binding, items array, or null if empty.
|
|
59
|
+
* @returns AnovaPropBinding if bound, array if items exist, null if empty
|
|
60
|
+
*/
|
|
61
|
+
get(): string[] | AnovaPropBinding | null;
|
|
62
|
+
/**
|
|
63
|
+
* Returns an iterator over child names.
|
|
64
|
+
* @example
|
|
65
|
+
* for (const childName of children.values()) {
|
|
66
|
+
* console.log(childName);
|
|
67
|
+
* }
|
|
68
|
+
*/
|
|
69
|
+
values(): IterableIterator<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Makes Children directly iterable.
|
|
72
|
+
* @example
|
|
73
|
+
* for (const childName of children) {
|
|
74
|
+
* console.log(childName);
|
|
75
|
+
* }
|
|
76
|
+
*/
|
|
77
|
+
[Symbol.iterator](): IterableIterator<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the number of children.
|
|
80
|
+
*/
|
|
81
|
+
get size(): number;
|
|
82
|
+
/**
|
|
83
|
+
* Checks if there are no children.
|
|
84
|
+
* @example
|
|
85
|
+
* if (children.isEmpty()) {
|
|
86
|
+
* return;
|
|
87
|
+
* }
|
|
88
|
+
*/
|
|
89
|
+
isEmpty(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Create a deep clone of this Children instance.
|
|
92
|
+
*
|
|
93
|
+
* @returns A new Children instance with copied child names and binding
|
|
94
|
+
*/
|
|
95
|
+
clone(): Children;
|
|
96
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ColorObject, ColorFormat } from '@directededges/specs-schema';
|
|
2
|
+
/**
|
|
3
|
+
* Color — first-class wrapper for DTCG ColorObject objects.
|
|
4
|
+
*
|
|
5
|
+
* Provides lifecycle methods (difference, clone, data) consistent with
|
|
6
|
+
* peer value types (Gradient, Shadow, Effects, Typography).
|
|
7
|
+
* Public readonly fields preserve `toMatchObject` compatibility in tests.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Color {
|
|
10
|
+
readonly colorSpace: string;
|
|
11
|
+
readonly components: (number | 'none')[];
|
|
12
|
+
readonly alpha?: number;
|
|
13
|
+
readonly hex: string;
|
|
14
|
+
constructor(value: ColorObject);
|
|
15
|
+
/**
|
|
16
|
+
* Returns true if this Color differs from base.
|
|
17
|
+
* Compares hex (encodes all three RGB channels) and alpha.
|
|
18
|
+
*/
|
|
19
|
+
difference(base: Color): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Deep copy returning a new independent instance.
|
|
22
|
+
*/
|
|
23
|
+
clone(): Color;
|
|
24
|
+
/**
|
|
25
|
+
* Serialize to the specs-schema ColorObject interface, or to a formatted
|
|
26
|
+
* color string when a non-OBJECT ColorFormat is specified.
|
|
27
|
+
*/
|
|
28
|
+
data(format?: ColorFormat): ColorObject | string;
|
|
29
|
+
/** 6-digit sRGB hex: `#FF6600` */
|
|
30
|
+
toHex(): string;
|
|
31
|
+
/** 8-digit sRGB hex with alpha: `#FF6600FF` */
|
|
32
|
+
toHexa(): string;
|
|
33
|
+
/** CSS `rgb()` functional notation: `rgb(255, 102, 0)` */
|
|
34
|
+
toRgb(): string;
|
|
35
|
+
/** CSS `rgba()` functional notation: `rgba(255, 102, 0, 1)` */
|
|
36
|
+
toRgba(): string;
|
|
37
|
+
/** CSS `hsla()` functional notation: `hsla(24, 100%, 50%, 1)` */
|
|
38
|
+
toHsla(): string;
|
|
39
|
+
/** Figma HSB/HSV notation: `hsb(24, 100%, 100%)` */
|
|
40
|
+
toHsb(): string;
|
|
41
|
+
/** CSS Color Level 4 `oklch()`: `oklch(0.7 0.15 50 / 1)` */
|
|
42
|
+
toOklch(): string;
|
|
43
|
+
/** CSS Color Level 4 `oklab()`: `oklab(0.7 0.1 0.1 / 1)` */
|
|
44
|
+
toOklab(): string;
|
|
45
|
+
/** Resolved alpha rounded to 4dp: 1 when omitted. */
|
|
46
|
+
private alphaValue;
|
|
47
|
+
/** sRGB components as 0–255 integers. */
|
|
48
|
+
private rgb255;
|
|
49
|
+
/** sRGB 0–1 components, coercing 'none' to 0. */
|
|
50
|
+
private srgbComponents;
|
|
51
|
+
/** sRGB → HSL. Returns [h (0–360), s (0–100), l (0–100)] rounded. */
|
|
52
|
+
private hsl;
|
|
53
|
+
/** sRGB → HSB/HSV. Returns [h (0–360), s (0–100), b (0–100)] rounded. */
|
|
54
|
+
private hsb;
|
|
55
|
+
/** sRGB → OKLab. Returns [L, a, b] rounded to 4 decimal places. */
|
|
56
|
+
private oklab;
|
|
57
|
+
/** sRGB → OKLCh. Returns [L, C, h] with L/C rounded to 4dp, h to 2dp. */
|
|
58
|
+
private oklch;
|
|
59
|
+
/** sRGB gamma → linear. */
|
|
60
|
+
private static srgbToLinear;
|
|
61
|
+
/** Round to 4 decimal places. */
|
|
62
|
+
private static round4;
|
|
63
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Anatomy } from './Anatomy/Anatomy.js';
|
|
2
|
+
import type { Component as AnovaComponent } from '@directededges/specs-schema';
|
|
3
|
+
import { SpecableNode } from './Nodes/types.js';
|
|
4
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
5
|
+
import { ProgressCoordinator } from '../Progress/ProgressCoordinator.js';
|
|
6
|
+
import type { ProcessingContext } from '../Runtime/Context/interfaces.js';
|
|
7
|
+
import type { StylesMap, VariablesMap, CollectionsMap } from '../Runtime/Foundations/FigmaRESTMaps.js';
|
|
8
|
+
import type { RestLicenseInput } from '../License/types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Options for REST/CLI environment
|
|
11
|
+
* Internal interface - not exported
|
|
12
|
+
*/
|
|
13
|
+
interface RestOptions {
|
|
14
|
+
coordinator?: ProgressCoordinator;
|
|
15
|
+
styles: StylesMap;
|
|
16
|
+
variables: VariablesMap;
|
|
17
|
+
collections: CollectionsMap;
|
|
18
|
+
author?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class Component {
|
|
21
|
+
private _anatomy;
|
|
22
|
+
private props;
|
|
23
|
+
private variants;
|
|
24
|
+
private subcomponents;
|
|
25
|
+
private instanceExamples;
|
|
26
|
+
private _slotContent?;
|
|
27
|
+
/** Shared slot-fill registry: component's own fills AND instanceExamples' fills dedup here. */
|
|
28
|
+
private _slotRegistry;
|
|
29
|
+
protected config: ResolvedConfig;
|
|
30
|
+
private context?;
|
|
31
|
+
private node;
|
|
32
|
+
private _name;
|
|
33
|
+
private options?;
|
|
34
|
+
get name(): () => string;
|
|
35
|
+
protected get anatomy(): Anatomy;
|
|
36
|
+
/**
|
|
37
|
+
* Create Component from REST API JSON
|
|
38
|
+
* Returns fully-processed Component ready for .yaml() output
|
|
39
|
+
*
|
|
40
|
+
* @param libraryJson - Raw REST API JSON data
|
|
41
|
+
* @param componentId - Component name or ID to extract
|
|
42
|
+
* @param config - Component configuration
|
|
43
|
+
* @param options - Required: styles, variables, collections Maps; Optional: coordinator, author
|
|
44
|
+
* @throws Error if JSON is invalid or component not found
|
|
45
|
+
*/
|
|
46
|
+
static fromRestApi(libraryJson: any, componentId: string, config: ResolvedConfig, options: RestOptions, licenseInput?: RestLicenseInput): Promise<Component>;
|
|
47
|
+
constructor(node: SpecableNode, config: ResolvedConfig, options?: RestOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Internal processing method
|
|
50
|
+
* Called by factory methods and subclasses
|
|
51
|
+
*/
|
|
52
|
+
protected _process(coordinator?: ProgressCoordinator, context?: ProcessingContext): Promise<void>;
|
|
53
|
+
/** JSON Pointer base for this host's slot content references. Overridden by Subcomponent. */
|
|
54
|
+
protected _slotBasePath(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Component ids an instance example may resolve to — used to confirm a candidate
|
|
57
|
+
* is genuinely an instance of THIS component before treating it as an example
|
|
58
|
+
* (ADR-048). Computed by node kind, since a COMPONENT may or may not live inside
|
|
59
|
+
* a COMPONENT_SET:
|
|
60
|
+
* - COMPONENT_SET → its variant child COMPONENT ids (a variant instance's
|
|
61
|
+
* mainComponent points at a child variant, never at the set itself).
|
|
62
|
+
* - standalone COMPONENT → its own id (instances point directly at it).
|
|
63
|
+
*/
|
|
64
|
+
protected _acceptableComponentIds(): Set<string>;
|
|
65
|
+
protected _processSlots(context?: ProcessingContext): Promise<void>;
|
|
66
|
+
protected data(): AnovaComponent;
|
|
67
|
+
yaml(): string;
|
|
68
|
+
json(): AnovaComponent;
|
|
69
|
+
static componentRootNode(node: SpecableNode, variantName: string): ComponentNode | undefined;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Blur as AnovaBlur } from '@directededges/specs-schema';
|
|
2
|
+
import type { ResolvedConfig } from '@directededges/specs-schema';
|
|
3
|
+
import { FigmaVariableReference } from '../Styles/Style.js';
|
|
4
|
+
/**
|
|
5
|
+
* Represents one evaluated LAYER_BLUR or BACKGROUND_BLUR effect item.
|
|
6
|
+
* Singular per role — the containing `Effects` key (`layerBlur` vs
|
|
7
|
+
* `backgroundBlur`) determines render role.
|
|
8
|
+
* Peer to `Shadow` in the Effects class hierarchy.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Blur {
|
|
11
|
+
visible: boolean;
|
|
12
|
+
radius: number | FigmaVariableReference;
|
|
13
|
+
/**
|
|
14
|
+
* Populate fields from a Figma LAYER_BLUR or BACKGROUND_BLUR effect object.
|
|
15
|
+
* `boundVariables.radius` carries variable binding when the radius field is
|
|
16
|
+
* bound to a Figma variable.
|
|
17
|
+
*/
|
|
18
|
+
evaluate(effect: BlurEffect): void;
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if any field differs from the base Blur.
|
|
21
|
+
* Type-mismatch rule: primitive vs FigmaVariableReference is always different.
|
|
22
|
+
*/
|
|
23
|
+
difference(base: Blur): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Deep clone: primitive fields by value, FigmaVariableReference instances cloned.
|
|
26
|
+
*/
|
|
27
|
+
clone(): Blur;
|
|
28
|
+
/**
|
|
29
|
+
* Returns null if identical to baseline, otherwise returns this.clone().
|
|
30
|
+
*/
|
|
31
|
+
compare(baseline: Blur): Blur | null;
|
|
32
|
+
/**
|
|
33
|
+
* Blur merge is whole-object replacement: returns layer.clone().
|
|
34
|
+
*/
|
|
35
|
+
merge(layer: Blur): Blur;
|
|
36
|
+
/**
|
|
37
|
+
* Serialize to the anova output shape, applying config.format settings.
|
|
38
|
+
* Returns a shape compatible with the `Blur` interface from `@directededges/specs-schema`.
|
|
39
|
+
*/
|
|
40
|
+
data(config: ResolvedConfig): AnovaBlur;
|
|
41
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Effects as AnovaEffects } from '@directededges/specs-schema';
|
|
2
|
+
import type { ResolvedConfig } from '@directededges/specs-schema';
|
|
3
|
+
import { Shadow } from './Shadow.js';
|
|
4
|
+
import { Blur } from './Blur.js';
|
|
5
|
+
/**
|
|
6
|
+
* Named-key container for all four Figma effect roles.
|
|
7
|
+
*
|
|
8
|
+
* Each key is optional; a key is omitted when no effects of that type are
|
|
9
|
+
* present on the node. `Shadow` is used for both drop and inner shadows —
|
|
10
|
+
* `Shadow.inset` distinguishes them (absent/false = drop, true = inner).
|
|
11
|
+
*
|
|
12
|
+
* Maps directly to platform properties:
|
|
13
|
+
* - `shadows` (inset=false/absent) → `box-shadow` / `.shadow()`
|
|
14
|
+
* - `shadows` (inset=true) → `inset box-shadow`
|
|
15
|
+
* - `layerBlur` → `filter: blur()`
|
|
16
|
+
* - `backgroundBlur` → `backdrop-filter: blur()`
|
|
17
|
+
*/
|
|
18
|
+
export declare class Effects {
|
|
19
|
+
shadows?: Shadow[];
|
|
20
|
+
layerBlur?: Blur;
|
|
21
|
+
backgroundBlur?: Blur;
|
|
22
|
+
pushShadow(shadow: Shadow): void;
|
|
23
|
+
/**
|
|
24
|
+
* Returns true when no effect of any type has been set.
|
|
25
|
+
*/
|
|
26
|
+
isEmpty(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Returns true if this Effects instance differs from base.
|
|
29
|
+
* Shadow arrays are compared positionally within each key (independent groups).
|
|
30
|
+
* Blur fields differ when one is present and the other absent, or when their
|
|
31
|
+
* values differ.
|
|
32
|
+
*/
|
|
33
|
+
difference(base: Effects): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Deep clone: each Shadow copied via Shadow.clone(); each Blur via Blur.clone().
|
|
36
|
+
*/
|
|
37
|
+
clone(): Effects;
|
|
38
|
+
/**
|
|
39
|
+
* Returns null if identical to baseline, otherwise returns this.clone().
|
|
40
|
+
*/
|
|
41
|
+
compare(baseline: Effects): Effects | null;
|
|
42
|
+
/**
|
|
43
|
+
* Whole-group replacement: returns layer.clone().
|
|
44
|
+
*/
|
|
45
|
+
merge(layer: Effects): Effects;
|
|
46
|
+
/**
|
|
47
|
+
* Serialize to the anova output shape.
|
|
48
|
+
* Only keys with values are included in the result.
|
|
49
|
+
*/
|
|
50
|
+
data(config: ResolvedConfig): AnovaEffects;
|
|
51
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Style } from '../Styles/Style.js';
|
|
2
|
+
import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Post-processes an `effects` Style after initial evaluation.
|
|
5
|
+
*
|
|
6
|
+
* Handles two paths:
|
|
7
|
+
* 1. FigmaStyleReference: resolves the `.name` field via resolveName().
|
|
8
|
+
* 2. Effects: iterates Shadow arrays and Blur fields; resolves any
|
|
9
|
+
* FigmaVariableReference instances to named variables.
|
|
10
|
+
*
|
|
11
|
+
* Called from `StylesProcessor.postProcess()` for the `effects` style key.
|
|
12
|
+
*/
|
|
13
|
+
export declare class EffectsProcessor {
|
|
14
|
+
static postProcess(style: Style | undefined, context?: ProcessingContext): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Shadow as AnovaShadow } from '@directededges/specs-schema';
|
|
2
|
+
import type { ResolvedConfig } from '@directededges/specs-schema';
|
|
3
|
+
import { FigmaVariableReference } from '../Styles/Style.js';
|
|
4
|
+
import { Color } from '../Color/Color.js';
|
|
5
|
+
import { type ProcessingContext } from '../../Runtime/Context/interfaces.js';
|
|
6
|
+
export type ShadowFieldValue = number | string | boolean | Color | FigmaVariableReference;
|
|
7
|
+
/**
|
|
8
|
+
* Represents one evaluated DROP_SHADOW effect item.
|
|
9
|
+
* Peer to `Style` in the class hierarchy.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Shadow {
|
|
12
|
+
visible: boolean;
|
|
13
|
+
inset?: boolean;
|
|
14
|
+
offsetX: number | FigmaVariableReference;
|
|
15
|
+
offsetY: number | FigmaVariableReference;
|
|
16
|
+
blur: number | FigmaVariableReference;
|
|
17
|
+
spread: number | FigmaVariableReference;
|
|
18
|
+
color: Color | FigmaVariableReference;
|
|
19
|
+
/**
|
|
20
|
+
* Populate fields from a Figma DROP_SHADOW effect object.
|
|
21
|
+
*
|
|
22
|
+
* ⚠️ boundVariables key names for numeric fields (`offsetX`, `offsetY`, `radius`, `spread`)
|
|
23
|
+
* are unconfirmed against live Plugin API data. `color` is confirmed. Verify in Plugin
|
|
24
|
+
* console before relying on variable binding for numeric fields (T008).
|
|
25
|
+
*/
|
|
26
|
+
evaluate(effect: DropShadowEffect, context?: ProcessingContext): void;
|
|
27
|
+
/**
|
|
28
|
+
* Returns true if any field differs from the base Shadow.
|
|
29
|
+
* Type-mismatch rule: primitive vs FigmaVariableReference is always different.
|
|
30
|
+
*/
|
|
31
|
+
difference(base: Shadow): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Deep clone: primitive fields by value, FigmaVariableReference instances cloned.
|
|
34
|
+
*/
|
|
35
|
+
clone(): Shadow;
|
|
36
|
+
/**
|
|
37
|
+
* Returns null if identical to baseline, otherwise returns this.clone().
|
|
38
|
+
*/
|
|
39
|
+
compare(baseline: Shadow): Shadow | null;
|
|
40
|
+
/**
|
|
41
|
+
* Shadow merge is whole-object replacement: returns layer.clone().
|
|
42
|
+
*/
|
|
43
|
+
merge(layer: Shadow): Shadow;
|
|
44
|
+
/**
|
|
45
|
+
* Serialize to the anova output shape, applying config.format settings.
|
|
46
|
+
*/
|
|
47
|
+
data(config: ResolvedConfig): AnovaShadow;
|
|
48
|
+
private static fieldDiffers;
|
|
49
|
+
private static cloneField;
|
|
50
|
+
private static serializeField;
|
|
51
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Element as AnovaElement } from '@directededges/specs-schema';
|
|
2
|
+
import { Styles } from "../Styles/Styles.js";
|
|
3
|
+
import { FigmaContainerNode, FigmaElementNode } from '../Nodes/types.js';
|
|
4
|
+
import { PropConfigurations } from "../PropConfigurations/PropConfigurations.js";
|
|
5
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
6
|
+
import { Children } from "../Children/Children.js";
|
|
7
|
+
import { PropBinding } from "../Props/PropBinding.js";
|
|
8
|
+
import type { ProcessingContext } from "../../Runtime/Context/interfaces.js";
|
|
9
|
+
export type ContainerElement = BaseElement & {
|
|
10
|
+
node: FigmaContainerNode;
|
|
11
|
+
};
|
|
12
|
+
export type ElementType = 'text' | 'glyph' | 'vector' | 'container' | 'slot' | 'instance' | 'line' | 'ellipse' | 'rectangle' | 'polygon' | 'star';
|
|
13
|
+
export declare abstract class BaseElement {
|
|
14
|
+
node: FigmaElementNode;
|
|
15
|
+
parent: string | null;
|
|
16
|
+
children: Children;
|
|
17
|
+
propConfigurations: PropConfigurations;
|
|
18
|
+
styles: Styles;
|
|
19
|
+
type: ElementType;
|
|
20
|
+
instanceOf: PropBinding | null;
|
|
21
|
+
content: PropBinding | null;
|
|
22
|
+
config: ResolvedConfig;
|
|
23
|
+
protected context?: ProcessingContext;
|
|
24
|
+
constructor(node: FigmaElementNode, config: ResolvedConfig);
|
|
25
|
+
/**
|
|
26
|
+
* Evaluate element attributes (Template Method Pattern)
|
|
27
|
+
* Delegates to subclass-specific logic for binding evaluation
|
|
28
|
+
*/
|
|
29
|
+
evaluate(context?: ProcessingContext): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Subclass-specific evaluation logic - to be implemented by subclasses
|
|
32
|
+
*/
|
|
33
|
+
protected abstract extendedEvaluate(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Get the element's name (computed from node)
|
|
36
|
+
*/
|
|
37
|
+
get name(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get the component property references from the node.
|
|
40
|
+
* Used by subclasses to detect property bindings.
|
|
41
|
+
*/
|
|
42
|
+
protected get propRefs(): Record<string, string> | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Relates raw Figma properties into semantic spec properties.
|
|
45
|
+
* Runs after evaluate() and before layer()/compare().
|
|
46
|
+
*/
|
|
47
|
+
postEvaluate(): void;
|
|
48
|
+
postProcess(removeDefaults: boolean, fullElement?: BaseElement | undefined, context?: ProcessingContext): Promise<void>;
|
|
49
|
+
protected abstract extendedPostProcess(context?: ProcessingContext): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Type guard to check if this element can be a layout parent (has auto-layout)
|
|
52
|
+
* Only ComponentNode and FrameNode support layoutMode
|
|
53
|
+
*/
|
|
54
|
+
isLayoutParent(): this is BaseElement & {
|
|
55
|
+
node: ComponentNode | FrameNode | InstanceNode;
|
|
56
|
+
};
|
|
57
|
+
data(config: ResolvedConfig, subcomponentRefs?: Map<string, string>): AnovaElement | undefined;
|
|
58
|
+
evaluateParent(node: FigmaElementNode): string | null;
|
|
59
|
+
empty(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Create a deep clone of this BaseElement.
|
|
62
|
+
* All nested properties (children, styles, props) are also cloned.
|
|
63
|
+
* Used to prevent shared references when compositing Elements.
|
|
64
|
+
*
|
|
65
|
+
* @returns A new BaseElement that is a deep copy of this one
|
|
66
|
+
*/
|
|
67
|
+
clone(): BaseElement;
|
|
68
|
+
/**
|
|
69
|
+
* Merge another BaseElement onto this one, with the layer's properties taking precedence.
|
|
70
|
+
* Used for accumulating predecessor .layered changes onto a baseline element.
|
|
71
|
+
* Performs deep property-level merging for styles, props, children.
|
|
72
|
+
* Does not mutate either input - returns a new BaseElement.
|
|
73
|
+
*
|
|
74
|
+
* @param layer - The BaseElement to merge onto this one
|
|
75
|
+
* @returns A new BaseElement with merged properties
|
|
76
|
+
*/
|
|
77
|
+
merge(layer: BaseElement): BaseElement;
|
|
78
|
+
/**
|
|
79
|
+
* Compare this BaseElement against a baseline to identify differences.
|
|
80
|
+
* Returns a new BaseElement containing only the properties that differ.
|
|
81
|
+
* Used for computing .layered output after accumulating predecessors.
|
|
82
|
+
*
|
|
83
|
+
* @param baseline - The BaseElement to compare against (or undefined if element is new)
|
|
84
|
+
* @returns A new BaseElement with only differences, or undefined if no differences
|
|
85
|
+
*/
|
|
86
|
+
compare(baseline: BaseElement | undefined): BaseElement | undefined;
|
|
87
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseElement } from "./BaseElement.js";
|
|
2
|
+
import { FigmaElementNode } from '../Nodes/types.js';
|
|
3
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
4
|
+
export declare class ElementFactory {
|
|
5
|
+
static create(node: FigmaElementNode, config: ResolvedConfig): BaseElement;
|
|
6
|
+
static createFrom(element: BaseElement): BaseElement;
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ResolvedConfig } from '@directededges/specs-schema';
|
|
2
|
+
import type { FigmaElementNode } from '../Nodes/types.js';
|
|
3
|
+
import type { BaseElement } from './BaseElement.js';
|
|
4
|
+
/**
|
|
5
|
+
* Indirection that breaks the `BaseElement` ↔ `ElementFactory` import cycle.
|
|
6
|
+
*
|
|
7
|
+
* `BaseElement.clone()/merge()/compare()` need `ElementFactory.create()`, but
|
|
8
|
+
* `ElementFactory` (transitively, via its concrete element subclasses) extends
|
|
9
|
+
* `BaseElement` — a static `BaseElement → ElementFactory` import makes the class
|
|
10
|
+
* a subclass-evaluates-before-base hazard ("Class extends value undefined").
|
|
11
|
+
*
|
|
12
|
+
* This module imports nothing at runtime (types only), so it is a graph leaf.
|
|
13
|
+
* `ElementFactory` registers its `create` on load; `BaseElement` calls through
|
|
14
|
+
* `createElement`, never importing `ElementFactory` directly.
|
|
15
|
+
*/
|
|
16
|
+
type ElementFactoryFn = (node: FigmaElementNode, config: ResolvedConfig) => BaseElement;
|
|
17
|
+
/** Called once by `ElementFactory` at module load. */
|
|
18
|
+
export declare function registerElementFactory(fn: ElementFactoryFn): void;
|
|
19
|
+
/** Create an element via the registered `ElementFactory`. */
|
|
20
|
+
export declare function createElement(node: FigmaElementNode, config: ResolvedConfig): BaseElement;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { BaseElement } from './BaseElement.js';
|
|
2
|
+
import { Elements as AnovaElements } from '@directededges/specs-schema';
|
|
3
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
4
|
+
import type { FigmaElementNode } from '../Nodes/types.js';
|
|
5
|
+
import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
|
|
6
|
+
import { PropPairings } from '../Props/PropPairings.js';
|
|
7
|
+
export declare class Elements {
|
|
8
|
+
private _items;
|
|
9
|
+
private config;
|
|
10
|
+
private _nodes;
|
|
11
|
+
constructor(config: ResolvedConfig, nodes?: FigmaElementNode[]);
|
|
12
|
+
/**
|
|
13
|
+
* Create element instances for all nodes. Resolves main component names
|
|
14
|
+
* for INSTANCE nodes and applies glyph detection when glyphNamePattern is configured.
|
|
15
|
+
*/
|
|
16
|
+
detect(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Evaluate properties for all previously-detected elements.
|
|
19
|
+
* When validatedPairs are provided, sets the active pair on Style
|
|
20
|
+
* before each element evaluates so the visible binding can emit a Conditional.
|
|
21
|
+
*/
|
|
22
|
+
evaluate(context?: ProcessingContext, pairings?: PropPairings): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Relates raw Figma properties into semantic spec properties for all elements.
|
|
25
|
+
* Runs after evaluate() and before layer()/compare().
|
|
26
|
+
*/
|
|
27
|
+
postEvaluate(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Apply (merge) another Elements tree onto this one.
|
|
30
|
+
*
|
|
31
|
+
* @param layer - The Elements tree to merge onto this one
|
|
32
|
+
* @returns A new Elements instance with the merged result
|
|
33
|
+
*/
|
|
34
|
+
applyLayer(layer: Elements): Elements;
|
|
35
|
+
/**
|
|
36
|
+
* Compare this Elements tree against a baseline to identify differences.
|
|
37
|
+
*
|
|
38
|
+
* @param baseline - The Elements tree to compare against
|
|
39
|
+
* @returns A new Elements instance containing only differences
|
|
40
|
+
*/
|
|
41
|
+
compare(baseline: Elements): Elements;
|
|
42
|
+
postProcess(removeDefaults?: boolean, fullElements?: Elements | null, context?: ProcessingContext): Promise<void>;
|
|
43
|
+
data(config: ResolvedConfig, subcomponentRefs?: Map<string, string>): AnovaElements | undefined;
|
|
44
|
+
get(name: string): BaseElement | undefined;
|
|
45
|
+
set(name: string, el: BaseElement): void;
|
|
46
|
+
has(name: string): boolean;
|
|
47
|
+
delete(name: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Makes Elements directly iterable (defaults to entries).
|
|
50
|
+
* @example
|
|
51
|
+
* for (const [name, element] of elements) { ... }
|
|
52
|
+
*/
|
|
53
|
+
[Symbol.iterator](): IterableIterator<[string, BaseElement]>;
|
|
54
|
+
/**
|
|
55
|
+
* Returns an iterator over [name, element] entries.
|
|
56
|
+
* @example
|
|
57
|
+
* for (const [name, element] of elements.entries()) { ... }
|
|
58
|
+
*/
|
|
59
|
+
entries(): IterableIterator<[string, BaseElement]>;
|
|
60
|
+
/**
|
|
61
|
+
* Returns an iterator over element values.
|
|
62
|
+
* @example
|
|
63
|
+
* for (const element of elements.values()) { ... }
|
|
64
|
+
*/
|
|
65
|
+
values(): IterableIterator<BaseElement>;
|
|
66
|
+
/**
|
|
67
|
+
* Returns an iterator over element names.
|
|
68
|
+
* @example
|
|
69
|
+
* for (const name of elements.keys()) {
|
|
70
|
+
* console.log(name);
|
|
71
|
+
* }
|
|
72
|
+
*/
|
|
73
|
+
keys(): IterableIterator<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the number of elements in the collection.
|
|
76
|
+
*/
|
|
77
|
+
get size(): number;
|
|
78
|
+
/**
|
|
79
|
+
* Checks if the collection is empty.
|
|
80
|
+
* @example
|
|
81
|
+
* if (elements.isEmpty()) {
|
|
82
|
+
* return new Elements(this._node, this.config);
|
|
83
|
+
* }
|
|
84
|
+
*/
|
|
85
|
+
isEmpty(): boolean;
|
|
86
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseElement } from "../BaseElement.js";
|
|
2
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
3
|
+
import type { ProcessingContext } from '../../../Runtime/Context/interfaces.js';
|
|
4
|
+
export declare class ComponentElement extends BaseElement {
|
|
5
|
+
constructor(node: ComponentNode, config: ResolvedConfig);
|
|
6
|
+
protected extendedEvaluate(): Promise<void>;
|
|
7
|
+
protected extendedPostProcess(_context?: ProcessingContext): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseElement } from "../BaseElement.js";
|
|
2
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
3
|
+
import type { ProcessingContext } from '../../../Runtime/Context/interfaces.js';
|
|
4
|
+
export declare class EllipseElement extends BaseElement {
|
|
5
|
+
constructor(node: EllipseNode, config: ResolvedConfig);
|
|
6
|
+
protected extendedEvaluate(): Promise<void>;
|
|
7
|
+
protected extendedPostProcess(_context?: ProcessingContext): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseElement } from "../BaseElement.js";
|
|
2
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
3
|
+
import type { ProcessingContext } from '../../../Runtime/Context/interfaces.js';
|
|
4
|
+
export declare class FrameElement extends BaseElement {
|
|
5
|
+
constructor(node: FrameNode, config: ResolvedConfig);
|
|
6
|
+
protected extendedEvaluate(): Promise<void>;
|
|
7
|
+
protected extendedPostProcess(_context?: ProcessingContext): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseElement } from "../BaseElement.js";
|
|
2
|
+
import { ResolvedConfig, Element as AnovaElement } from '@directededges/specs-schema';
|
|
3
|
+
import type { FigmaElementNode } from '../../Nodes/types.js';
|
|
4
|
+
import type { ProcessingContext } from '../../../Runtime/Context/interfaces.js';
|
|
5
|
+
export declare class GlyphElement extends BaseElement {
|
|
6
|
+
private _glyphName;
|
|
7
|
+
constructor(node: FigmaElementNode, config: ResolvedConfig, glyphName: string);
|
|
8
|
+
get glyphName(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Match a resolved component name against a glyph name pattern.
|
|
11
|
+
* Returns the extracted glyph name if matched, or null if no match.
|
|
12
|
+
* The pattern uses {i} as a placeholder for the glyph name portion.
|
|
13
|
+
*/
|
|
14
|
+
static patternMatch(resolvedName: string, pattern: string): string | null;
|
|
15
|
+
protected extendedEvaluate(): Promise<void>;
|
|
16
|
+
data(config: ResolvedConfig, subcomponentRefs?: Map<string, string>): AnovaElement | undefined;
|
|
17
|
+
protected extendedPostProcess(_context?: ProcessingContext): Promise<void>;
|
|
18
|
+
clone(): BaseElement;
|
|
19
|
+
merge(layer: BaseElement): BaseElement;
|
|
20
|
+
compare(baseline: BaseElement | undefined): BaseElement | undefined;
|
|
21
|
+
}
|