@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.
- 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,24 @@
|
|
|
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 InstanceElement extends BaseElement {
|
|
5
|
+
resolvedInstanceName?: string;
|
|
6
|
+
constructor(node: InstanceNode, config: ResolvedConfig);
|
|
7
|
+
protected extendedEvaluate(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the main component name for an instance node.
|
|
10
|
+
* Returns the component set name if the main component belongs to a set,
|
|
11
|
+
* otherwise returns the component name directly.
|
|
12
|
+
*/
|
|
13
|
+
static resolveMainComponentName(node: InstanceNode): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Determine the main component reference asynchronously.
|
|
16
|
+
* Uses cached resolvedInstanceName from detect() if available.
|
|
17
|
+
*/
|
|
18
|
+
private instanceName;
|
|
19
|
+
/**
|
|
20
|
+
* Post-process for InstanceElement.
|
|
21
|
+
* With unified bindings, instanceOf already contains the binding info.
|
|
22
|
+
*/
|
|
23
|
+
protected extendedPostProcess(context?: ProcessingContext): Promise<void>;
|
|
24
|
+
}
|
|
@@ -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 LineElement extends BaseElement {
|
|
5
|
+
constructor(node: LineNode, 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 PolygonElement extends BaseElement {
|
|
5
|
+
constructor(node: PolygonNode, 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 RectangleElement extends BaseElement {
|
|
5
|
+
constructor(node: RectangleNode, 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 SlotElement extends BaseElement {
|
|
5
|
+
constructor(node: SlotNode, 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 StarElement extends BaseElement {
|
|
5
|
+
constructor(node: StarNode, 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 TextElement extends BaseElement {
|
|
5
|
+
constructor(node: TextNode, 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 VectorElement extends BaseElement {
|
|
5
|
+
constructor(node: VectorNode, config: ResolvedConfig);
|
|
6
|
+
protected extendedEvaluate(): Promise<void>;
|
|
7
|
+
protected extendedPostProcess(_context?: ProcessingContext): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { BaseElement } from "./BaseElement.js";
|
|
2
|
+
export { ElementFactory } from "./ElementFactory.js";
|
|
3
|
+
export { ComponentElement } from "./Primitives/ComponentElement.js";
|
|
4
|
+
export { FrameElement } from "./Primitives/FrameElement.js";
|
|
5
|
+
export { InstanceElement } from "./Primitives/InstanceElement.js";
|
|
6
|
+
export { TextElement } from "./Primitives/TextElement.js";
|
|
7
|
+
export { VectorElement } from "./Primitives/VectorElement.js";
|
|
8
|
+
export { LineElement } from "./Primitives/LineElement.js";
|
|
9
|
+
export { StarElement } from "./Primitives/StarElement.js";
|
|
10
|
+
export { PolygonElement } from "./Primitives/PolygonElement.js";
|
|
11
|
+
export { RectangleElement } from "./Primitives/RectangleElement.js";
|
|
12
|
+
export { EllipseElement } from "./Primitives/EllipseElement.js";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { GradientValue, GradientStop, ResolvedConfig } from '@directededges/specs-schema';
|
|
2
|
+
import { type ProcessingContext } from '../../Runtime/Context/interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Type guard for gradient paints
|
|
5
|
+
*/
|
|
6
|
+
type GradientPaint = Extract<Paint, {
|
|
7
|
+
type: 'GRADIENT_LINEAR' | 'GRADIENT_RADIAL' | 'GRADIENT_ANGULAR' | 'GRADIENT_DIAMOND';
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Gradient — first-class component for Figma gradient fills
|
|
11
|
+
*
|
|
12
|
+
* Instance-based class (peer to Shadow/Blur/Effects) that wraps a GradientValue.
|
|
13
|
+
* Provides lifecycle methods (difference, clone, data) and handles conversion
|
|
14
|
+
* from Figma gradient paints to structured gradient values.
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* const gradient = new Gradient();
|
|
18
|
+
* gradient.evaluate(paint);
|
|
19
|
+
*/
|
|
20
|
+
export declare class Gradient {
|
|
21
|
+
private _value;
|
|
22
|
+
constructor(value?: GradientValue);
|
|
23
|
+
get value(): GradientValue;
|
|
24
|
+
get type(): 'LINEAR' | 'RADIAL' | 'ANGULAR';
|
|
25
|
+
get stops(): GradientStop[];
|
|
26
|
+
/**
|
|
27
|
+
* Returns true if this Gradient differs from base.
|
|
28
|
+
* Compares gradient type, geometry (angle/center), and all stops.
|
|
29
|
+
*/
|
|
30
|
+
difference(base: Gradient): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Serialize this Gradient for output, respecting config.format.tokens.
|
|
33
|
+
* FigmaVariableReference stop colors are converted per config profile.
|
|
34
|
+
* Color instances serialize via .data(config.format.color).
|
|
35
|
+
*/
|
|
36
|
+
data(config: ResolvedConfig): GradientValue;
|
|
37
|
+
/**
|
|
38
|
+
* Create a deep clone of this Gradient instance.
|
|
39
|
+
*/
|
|
40
|
+
clone(): Gradient;
|
|
41
|
+
/**
|
|
42
|
+
* Populate gradient value from a Figma gradient paint.
|
|
43
|
+
* Returns true if evaluation succeeded, false if paint is unsupported/invalid.
|
|
44
|
+
*
|
|
45
|
+
* @param paint - Figma gradient paint (GRADIENT_LINEAR, GRADIENT_RADIAL, GRADIENT_ANGULAR)
|
|
46
|
+
*/
|
|
47
|
+
evaluate(paint: GradientPaint, context?: ProcessingContext): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Static factory: construct and evaluate in one call.
|
|
50
|
+
* Returns Gradient instance or null if evaluation failed.
|
|
51
|
+
*
|
|
52
|
+
* @param paint - Figma gradient paint
|
|
53
|
+
*/
|
|
54
|
+
static fromPaint(paint: GradientPaint, context?: ProcessingContext): Gradient | null;
|
|
55
|
+
/**
|
|
56
|
+
* Check if a paint is a gradient type (LINEAR, RADIAL, ANGULAR, or DIAMOND)
|
|
57
|
+
*/
|
|
58
|
+
static isGradientPaint(paint: Paint | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Extract CSS-equivalent angle from Figma linear gradient transform
|
|
61
|
+
*/
|
|
62
|
+
private static evaluateAngle;
|
|
63
|
+
/**
|
|
64
|
+
* Extract center position from Figma radial/angular gradient transform
|
|
65
|
+
*/
|
|
66
|
+
private static evaluateCenter;
|
|
67
|
+
/**
|
|
68
|
+
* Convert Figma gradient stops to GradientStop array.
|
|
69
|
+
* Returns null if < 2 stops (Figma requires at least 2).
|
|
70
|
+
*/
|
|
71
|
+
private static evaluateStops;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Gradient } from './Gradient.js';
|
|
2
|
+
import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* GradientProcessor — post-processing logic for Gradient instances
|
|
5
|
+
*
|
|
6
|
+
* Handles variable name resolution for gradient stop colors.
|
|
7
|
+
* Peer to EffectsProcessor.
|
|
8
|
+
*/
|
|
9
|
+
export declare class GradientProcessor {
|
|
10
|
+
/**
|
|
11
|
+
* Performs post-processing on a Gradient instance.
|
|
12
|
+
* Resolves variable names for any FigmaVariableReference stop colors.
|
|
13
|
+
*
|
|
14
|
+
* @param gradient The Gradient instance to process
|
|
15
|
+
* @param context Optional processing context with foundations loader
|
|
16
|
+
*/
|
|
17
|
+
static postProcess(gradient: Gradient | null, context?: ProcessingContext): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { InstanceExample as AnovaInstanceExample, ResolvedConfig, SlotContentRef } from '@directededges/specs-schema';
|
|
2
|
+
import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Per-example builder (ADR-048 / ADR-050). Maps one detected INSTANCE node into an
|
|
5
|
+
* `InstanceExample` — `{ title, propConfigurations? }`.
|
|
6
|
+
*
|
|
7
|
+
* Scalar prop configuration (TEXT/BOOLEAN/VARIANT/INSTANCE_SWAP coercion, key
|
|
8
|
+
* formatting, instance-swap name resolution, and slot-constraint folding) is
|
|
9
|
+
* delegated to `PropConfigurations` — the same machinery instance elements use —
|
|
10
|
+
* so an example serializes a configured instance identically to the rest of the
|
|
11
|
+
* spec. Slot props are supplied as pre-resolved `SlotContentRef`s by the owning
|
|
12
|
+
* `InstanceExamples` collaborator (which performs slot detection and owns the
|
|
13
|
+
* shared registry); the example holds no slot content of its own.
|
|
14
|
+
*
|
|
15
|
+
* `PropBinding` is never emitted — an instance example is a documented configuration,
|
|
16
|
+
* not a live data binding (ADR-048).
|
|
17
|
+
*
|
|
18
|
+
* Construction mirrors sibling per-item builders (`Subcomponent`, `PropConfigurations`):
|
|
19
|
+
* `(node, config)`; per-call context arrives via `resolve()` / `data()`.
|
|
20
|
+
*/
|
|
21
|
+
export declare class InstanceExample {
|
|
22
|
+
private _node;
|
|
23
|
+
private _props;
|
|
24
|
+
constructor(node: InstanceNode, config: ResolvedConfig);
|
|
25
|
+
/** The original node name, used as the human-readable title. */
|
|
26
|
+
get title(): string;
|
|
27
|
+
/** Resolve scalar prop configurations (incl. INSTANCE_SWAP names). Run before `data()`. */
|
|
28
|
+
resolve(context?: ProcessingContext): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Build the `InstanceExample`. `slotRefs` are the example's resolved slot-prop
|
|
31
|
+
* references (keyed by slot prop key), supplied by `InstanceExamples`.
|
|
32
|
+
* `propConfigurations` is omitted when the example exposes no configurable props.
|
|
33
|
+
*/
|
|
34
|
+
data(slotRefs: Record<string, SlotContentRef>): AnovaInstanceExample;
|
|
35
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { InstanceExamples as AnovaInstanceExamples, ResolvedConfig } from '@directededges/specs-schema';
|
|
2
|
+
import type { SlotRegistry } from '../SlotContent/SlotRegistry.js';
|
|
3
|
+
import { type ProcessingContext } from '../../Runtime/Context/interfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* Top-level collaborator for instance examples (ADR-048 + ADR-050) — sibling to
|
|
6
|
+
* Subcomponents and SlotContent. Reads `processing.instanceExamples`, gathers
|
|
7
|
+
* candidate nodes by scope (PAGE | FILE), applies match/exclude/parentNames
|
|
8
|
+
* filtering, and builds keyed `InstanceExample` entries.
|
|
9
|
+
*
|
|
10
|
+
* Detection mirrors `processing.subcomponents`. Output gating
|
|
11
|
+
* (`include.instanceExamples`) is applied by the caller in `Component.data()`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class InstanceExamples {
|
|
14
|
+
/** example key → builder + its resolved slot-prop refs */
|
|
15
|
+
private _items;
|
|
16
|
+
private config;
|
|
17
|
+
constructor(config: ResolvedConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Compile an example name pattern (with `{C}` and `*`) into a RegExp and test it.
|
|
20
|
+
* `{C}` expands to the (escaped) component name; `*` becomes `.*`.
|
|
21
|
+
* Independent of `Subcomponents.matchesPatterns` (which uses `{S}` capture semantics).
|
|
22
|
+
*/
|
|
23
|
+
static matchesExamplePattern(name: string, patterns: string[], componentName: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Detect instance examples for the given host component and contribute their
|
|
26
|
+
* slot fills to the shared registry.
|
|
27
|
+
*
|
|
28
|
+
* Candidates are INSTANCE nodes only (FRAME nodes are rejected), found via a
|
|
29
|
+
* boundary-respecting walk (the runtime's getPageSiblings / getAllPagesNodes,
|
|
30
|
+
* which stop at COMPONENT/COMPONENT_SET/INSTANCE). Applies for both PAGE and
|
|
31
|
+
* FILE scope. No-op when `processing.instanceExamples` is absent.
|
|
32
|
+
*
|
|
33
|
+
* `stampReferences` (= include.instanceExamples) controls whether slot refs are
|
|
34
|
+
* stamped and registry entries marked referenced. Detection always runs so the
|
|
35
|
+
* shared registry is populated regardless of the include flag.
|
|
36
|
+
*/
|
|
37
|
+
evaluate(componentName: string, basePath: string, registry: SlotRegistry, stampReferences: boolean, acceptableComponentIds: Set<string>, context?: ProcessingContext, rootNodeId?: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Detect filled slots inside an example instance (recursively, incl. slot ›
|
|
40
|
+
* instance › slot nesting) via the shared SlotDetector, contribute every level
|
|
41
|
+
* to the shared registry (deduped, example-key-prefixed), and — when stamping —
|
|
42
|
+
* mark referenced and wire nested refs. Returns the top-level slot-prop refs.
|
|
43
|
+
*/
|
|
44
|
+
private _contributeSlots;
|
|
45
|
+
/** Serialize to the keyed `InstanceExamples` record, sorted by key for determinism. */
|
|
46
|
+
data(): AnovaInstanceExamples;
|
|
47
|
+
get size(): number;
|
|
48
|
+
get isEmpty(): boolean;
|
|
49
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
2
|
+
import type { LayoutTree, LayoutSerializedNode } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Layout: builds and compares per-variant element hierarchy as a nested tree.
|
|
5
|
+
* Primary construction is via constructor with a provided node list.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Layout {
|
|
8
|
+
private _tree;
|
|
9
|
+
private _config;
|
|
10
|
+
constructor(config: ResolvedConfig, tree: LayoutTree);
|
|
11
|
+
/**
|
|
12
|
+
* Get the internal layout tree.
|
|
13
|
+
*/
|
|
14
|
+
get tree(): LayoutTree;
|
|
15
|
+
/**
|
|
16
|
+
* Compare the current layout tree against a baseline.
|
|
17
|
+
* Follows BaseElement.compare pattern: returns undefined if equal,
|
|
18
|
+
* otherwise returns a new Layout instance with the current tree when different.
|
|
19
|
+
*/
|
|
20
|
+
compare(baseline: Layout | undefined): Layout | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Return nested array representation suitable for serialization.
|
|
23
|
+
*/
|
|
24
|
+
data(): LayoutSerializedNode[];
|
|
25
|
+
private serialize;
|
|
26
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nested layout tree node used internally.
|
|
3
|
+
*/
|
|
4
|
+
export interface LayoutNode {
|
|
5
|
+
name: string;
|
|
6
|
+
children: LayoutNode[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Rooted layout tree container.
|
|
10
|
+
*/
|
|
11
|
+
export interface LayoutTree {
|
|
12
|
+
root: LayoutNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Serialized tree representation returned by data().
|
|
16
|
+
* Format: Array containing the root node object.
|
|
17
|
+
* Leaf nodes are strings, parent nodes are { [nodeName]: children[] }.
|
|
18
|
+
* Example:
|
|
19
|
+
* [
|
|
20
|
+
* {
|
|
21
|
+
* "root": [
|
|
22
|
+
* {
|
|
23
|
+
* "labelContainer": [
|
|
24
|
+
* "requiredIndicator",
|
|
25
|
+
* "label",
|
|
26
|
+
* "secondaryDescription"
|
|
27
|
+
* ]
|
|
28
|
+
* },
|
|
29
|
+
* {
|
|
30
|
+
* "control": [
|
|
31
|
+
* "value",
|
|
32
|
+
* "placeholder",
|
|
33
|
+
* "startIcon"
|
|
34
|
+
* ]
|
|
35
|
+
* }
|
|
36
|
+
* ]
|
|
37
|
+
* }
|
|
38
|
+
* ]
|
|
39
|
+
*/
|
|
40
|
+
export type LayoutSerializedNode = string | {
|
|
41
|
+
[nodeName: string]: LayoutSerializedNode[];
|
|
42
|
+
};
|
|
43
|
+
export type LayoutData = LayoutSerializedNode[];
|
|
44
|
+
/**
|
|
45
|
+
* Whole-tree comparison result.
|
|
46
|
+
*/
|
|
47
|
+
export interface LayoutComparison {
|
|
48
|
+
equal: boolean;
|
|
49
|
+
added: string[];
|
|
50
|
+
removed: string[];
|
|
51
|
+
moved: Array<{
|
|
52
|
+
name: string;
|
|
53
|
+
fromPath: string[];
|
|
54
|
+
toPath: string[];
|
|
55
|
+
}>;
|
|
56
|
+
orderChanges: Array<{
|
|
57
|
+
parent: string;
|
|
58
|
+
previousOrder: string[];
|
|
59
|
+
currentOrder: string[];
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Metadata as AnovaMetadata } from '@directededges/specs-schema';
|
|
2
|
+
import { SpecableNode } from "../Nodes/types";
|
|
3
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
4
|
+
import type { ProcessingContext } from "../../Runtime/Context/interfaces";
|
|
5
|
+
export declare class Metadata {
|
|
6
|
+
/**
|
|
7
|
+
* Find the page ID by traversing up the parent chain
|
|
8
|
+
* Handles both Plugin and REST contexts
|
|
9
|
+
* Note: Plugin API uses 'PAGE' type, REST API uses 'CANVAS' type for pages
|
|
10
|
+
*/
|
|
11
|
+
private static findPageId;
|
|
12
|
+
static create(node: SpecableNode, config: ResolvedConfig, context?: ProcessingContext): AnovaMetadata;
|
|
13
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type SpecableNode = ComponentNode | ComponentSetNode | FrameNode;
|
|
2
|
+
export type FigmaElementNode = ComponentNode | FrameNode | InstanceNode | TextNode | VectorNode | LineNode | StarNode | PolygonNode | RectangleNode | EllipseNode | SlotNode;
|
|
3
|
+
export type FigmaContainerNode = ComponentNode | FrameNode | InstanceNode;
|
|
4
|
+
export type FigmaCorneredNode = ComponentNode | InstanceNode | FrameNode | RectangleNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PropConfigurationValue } from './PropConfigurations';
|
|
2
|
+
/**
|
|
3
|
+
* PropConfiguration
|
|
4
|
+
*
|
|
5
|
+
* Represents a single component property configuration value.
|
|
6
|
+
* Wrapper class to enable type-safe iteration and Output rendering.
|
|
7
|
+
*
|
|
8
|
+
* Pattern: Singular wrapper (like Style.ts) for individual entries
|
|
9
|
+
* Used by: PropConfigurations.entries() → Attribute → Value
|
|
10
|
+
*/
|
|
11
|
+
export declare class PropConfiguration {
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly value: PropConfigurationValue;
|
|
14
|
+
constructor(key: string, value: PropConfigurationValue);
|
|
15
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PropConfigurations as AnovaPropConfigurations } from '@directededges/specs-schema';
|
|
2
|
+
import { ResolvedConfig } from '@directededges/specs-schema';
|
|
3
|
+
import type { ProcessingContext } from '../../Runtime/Context/interfaces.js';
|
|
4
|
+
import { PropConfiguration } from './PropConfiguration.js';
|
|
5
|
+
export type PropConfigurationValue = string | number | boolean;
|
|
6
|
+
export declare class PropConfigurations {
|
|
7
|
+
private _items;
|
|
8
|
+
private _types;
|
|
9
|
+
private _node;
|
|
10
|
+
private config;
|
|
11
|
+
constructor(node: InstanceNode, config: ResolvedConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Evaluate component properties. Stores raw values (including component IDs
|
|
14
|
+
* for INSTANCE_SWAP) so that merge/compare operate on cheap identity checks.
|
|
15
|
+
* Name resolution for INSTANCE_SWAP happens lazily at data() time.
|
|
16
|
+
*/
|
|
17
|
+
evaluate(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Merge another PropConfigurations instance onto this one.
|
|
20
|
+
* Layer properties take precedence over base properties.
|
|
21
|
+
* Performs property-level merge: base properties are preserved unless layer overrides them.
|
|
22
|
+
*
|
|
23
|
+
* @param layer - The PropConfigurations to merge onto this one
|
|
24
|
+
* @returns A new PropConfigurations instance with merged values
|
|
25
|
+
*/
|
|
26
|
+
merge(layer: PropConfigurations): PropConfigurations;
|
|
27
|
+
/**
|
|
28
|
+
* Compare this PropConfigurations against a baseline to identify differences.
|
|
29
|
+
* Returns a new PropConfigurations instance containing only differences.
|
|
30
|
+
*
|
|
31
|
+
* @param baseline - The PropConfigurations to compare against
|
|
32
|
+
* @returns A new PropConfigurations instance with differences, or empty if no differences
|
|
33
|
+
*/
|
|
34
|
+
compare(baseline: PropConfigurations): PropConfigurations;
|
|
35
|
+
/**
|
|
36
|
+
* Resolve INSTANCE_SWAP component IDs to human-readable names.
|
|
37
|
+
* Called during postProcess (after merge/compare) so that evaluate/compare
|
|
38
|
+
* operate on cheap raw IDs and name lookup only happens for the final output set.
|
|
39
|
+
* Writes resolved names back into _items so that entries()/get() return
|
|
40
|
+
* resolved values without dual-state — before postProcess they hold raw IDs,
|
|
41
|
+
* after postProcess they hold resolved names.
|
|
42
|
+
*/
|
|
43
|
+
postProcess(context?: ProcessingContext): Promise<void>;
|
|
44
|
+
data(): AnovaPropConfigurations | undefined;
|
|
45
|
+
get(name: string): PropConfigurationValue | undefined;
|
|
46
|
+
set(name: string, value: PropConfigurationValue | PropConfiguration): void;
|
|
47
|
+
[Symbol.iterator](): IterableIterator<[string, PropConfiguration]>;
|
|
48
|
+
entries(): IterableIterator<[string, PropConfiguration]>;
|
|
49
|
+
values(): IterableIterator<PropConfigurationValue>;
|
|
50
|
+
keys(): IterableIterator<string>;
|
|
51
|
+
get size(): number;
|
|
52
|
+
isEmpty(): boolean;
|
|
53
|
+
copy(source: PropConfigurations, keys?: Set<string> | string[]): void;
|
|
54
|
+
clone(): PropConfigurations;
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BooleanProp } from '@directededges/specs-schema';
|
|
2
|
+
import type { FigmaElementNode } from '../../Nodes/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts BooleanProp from a node whose visibility is bound to a BOOLEAN prop.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BooleanCodeOnlyProp {
|
|
7
|
+
/** A node is extractable if it has a 'visible' binding. */
|
|
8
|
+
static canExtract(node: FigmaElementNode): boolean;
|
|
9
|
+
/** Extract a BooleanProp. The current visible state becomes the default. */
|
|
10
|
+
static extract(node: FigmaElementNode): BooleanProp;
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AnyProp, ResolvedConfig, Props as AnovaProps } from '@directededges/specs-schema';
|
|
2
|
+
import type { FigmaElementNode } from '../../Nodes/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Orchestrator for code-only prop extraction.
|
|
5
|
+
* Routes descendant nodes to specialized extractors (Text, Boolean, Instance)
|
|
6
|
+
* and merges results into the native props map.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CodeOnlyProps {
|
|
9
|
+
/**
|
|
10
|
+
* Full code-only props pipeline: extract, merge with native props,
|
|
11
|
+
* and post-process slot constraints.
|
|
12
|
+
*
|
|
13
|
+
* Keys are stored raw (unformatted). Props.data() handles formatting and sorting.
|
|
14
|
+
* Mutates nativeProps in place.
|
|
15
|
+
*/
|
|
16
|
+
static process(container: FigmaElementNode, nativeProps: AnovaProps, processing: ResolvedConfig['processing']): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the set of raw (unformatted) prop names that will be extracted from the container.
|
|
19
|
+
* Used by Props.process() to pre-exclude these from native prop extraction.
|
|
20
|
+
*/
|
|
21
|
+
static getCodeOnlyPropNames(container: FigmaElementNode): Set<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Extract code-only props from a container node by routing each descendant
|
|
24
|
+
* to the appropriate specialized extractor.
|
|
25
|
+
*/
|
|
26
|
+
static extract(container: FigmaElementNode, existingProps: Record<string, AnyProp>, processing: ResolvedConfig['processing']): Promise<Map<string, AnyProp>>;
|
|
27
|
+
/**
|
|
28
|
+
* Extract the component property name from a node's componentPropertyReferences.
|
|
29
|
+
* Ref values are formatted as "PropName#nodeId" — returns the part before '#'.
|
|
30
|
+
*/
|
|
31
|
+
private static getPropNameFromRefs;
|
|
32
|
+
/**
|
|
33
|
+
* Recursively collect all descendant nodes from a container.
|
|
34
|
+
*/
|
|
35
|
+
private static descendants;
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BooleanProp, EnumProp } from '@directededges/specs-schema';
|
|
2
|
+
import type { FigmaElementNode } from '../../Nodes/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts BooleanProp or EnumProp from an INSTANCE node used as a code-only prop picker.
|
|
5
|
+
* The instance's component must have exactly one VARIANT property in componentPropertyDefinitions.
|
|
6
|
+
*/
|
|
7
|
+
export declare class InstanceCodeOnlyProp {
|
|
8
|
+
/** An INSTANCE node is extractable if it has type 'INSTANCE'. */
|
|
9
|
+
static canExtract(node: FigmaElementNode): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Extract a BooleanProp or EnumProp from the instance's variant definition.
|
|
12
|
+
* Returns null if the instance does not meet the single-VARIANT contract.
|
|
13
|
+
* Returns `propName` derived from the VARIANT key (not the node name).
|
|
14
|
+
*/
|
|
15
|
+
static extract(node: FigmaElementNode): Promise<{
|
|
16
|
+
prop: BooleanProp | EnumProp;
|
|
17
|
+
propName: string;
|
|
18
|
+
} | null>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StringProp, NumberProp } from '@directededges/specs-schema';
|
|
2
|
+
import type { FigmaElementNode } from '../../Nodes/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts StringProp or NumberProp from a TEXT layer bound to a characters prop.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TextCodeOnlyProp {
|
|
7
|
+
/** A TEXT node is extractable if it has a 'characters' binding. */
|
|
8
|
+
static canExtract(node: FigmaElementNode): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Extract a StringProp or NumberProp from a text layer.
|
|
11
|
+
* When `inferNumber` is true and the text content passes the numeric guard,
|
|
12
|
+
* emits NumberProp instead of StringProp (ADR 029).
|
|
13
|
+
*/
|
|
14
|
+
static extract(node: FigmaElementNode, inferNumber?: boolean): StringProp | NumberProp;
|
|
15
|
+
private static buildStringProp;
|
|
16
|
+
private static buildNumberProp;
|
|
17
|
+
private static extensions;
|
|
18
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ResolvedConfig, PropBinding as AnovaPropBinding } from '@directededges/specs-schema';
|
|
2
|
+
import { RawStyle } from '../Styles/References/FigmaVariableReference.js';
|
|
3
|
+
/**
|
|
4
|
+
* PropBinding - represents a property that can optionally be bound to a component property.
|
|
5
|
+
*
|
|
6
|
+
* Unified binding class used for:
|
|
7
|
+
* - Element properties: `instanceOf`, `text` (value: string)
|
|
8
|
+
* - Style properties: `visible` (value: RawStyle)
|
|
9
|
+
*
|
|
10
|
+
* Always stores the raw value; optionally stores a ref for bound properties.
|
|
11
|
+
* Emits `{ $binding: "#/props/{property name}" }` when bound.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PropBinding {
|
|
14
|
+
readonly value: string | RawStyle;
|
|
15
|
+
readonly ref: string | null;
|
|
16
|
+
constructor(value: string | RawStyle, ref?: string);
|
|
17
|
+
/**
|
|
18
|
+
* Check if this property is bound to a component property.
|
|
19
|
+
*/
|
|
20
|
+
isBound(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Get the prop name from the $ref (without the #/props/ prefix).
|
|
23
|
+
* Returns null if not bound.
|
|
24
|
+
*/
|
|
25
|
+
propName(): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Get the raw value (for rendering/comparison purposes).
|
|
28
|
+
*/
|
|
29
|
+
rawValue(): string | RawStyle;
|
|
30
|
+
/**
|
|
31
|
+
* Serialize this PropBinding for output.
|
|
32
|
+
* Returns `{ $binding }` when bound, otherwise the raw value.
|
|
33
|
+
* When `formatValue` is true, applies key formatting to unbound string values.
|
|
34
|
+
*
|
|
35
|
+
* @param keyFormat - Key formatting config
|
|
36
|
+
* @param formatValue - Whether to apply Utilities.formatKey to unbound string values
|
|
37
|
+
*/
|
|
38
|
+
data(keyFormat: ResolvedConfig['format']['keys'], formatValue?: boolean): string | RawStyle | AnovaPropBinding;
|
|
39
|
+
static formatPropBinding(ref: string, keyFormat: ResolvedConfig['format']['keys']): AnovaPropBinding;
|
|
40
|
+
/**
|
|
41
|
+
* Compare this property against a baseline to identify differences.
|
|
42
|
+
* Returns this property if different, null if same.
|
|
43
|
+
*/
|
|
44
|
+
compare(baseline: PropBinding | null): PropBinding | null;
|
|
45
|
+
/**
|
|
46
|
+
* Check if this binding differs from another (used by Style.difference).
|
|
47
|
+
*/
|
|
48
|
+
difference(other: PropBinding): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Merge another property onto this one.
|
|
51
|
+
* Layer wins if non-null.
|
|
52
|
+
*/
|
|
53
|
+
merge(layer: PropBinding | null): PropBinding;
|
|
54
|
+
/**
|
|
55
|
+
* Create a clone of this property.
|
|
56
|
+
*/
|
|
57
|
+
clone(): PropBinding;
|
|
58
|
+
/**
|
|
59
|
+
* Create a PropBinding, optionally bound if refString is provided.
|
|
60
|
+
* Handles parsing the propName from Figma's ref format (e.g., "propName#nodeId").
|
|
61
|
+
* @param value The raw value (string for Element props, RawStyle for Style props)
|
|
62
|
+
* @param refString The componentPropertyReferences value (e.g., "propName#123:456"), or undefined if not bound
|
|
63
|
+
*/
|
|
64
|
+
static create(value: string | RawStyle, refString?: string): PropBinding;
|
|
65
|
+
/**
|
|
66
|
+
* Type guard to check if a value is a PropBinding.
|
|
67
|
+
*/
|
|
68
|
+
static is(v: unknown): v is PropBinding;
|
|
69
|
+
}
|