@open-pencil/scene-graph 0.15.1 → 0.16.0-beta.2
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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/chunks/behaviours/kinds.js +273 -0
- package/dist/chunks/behaviours/kinds.js.map +1 -0
- package/dist/chunks/behaviours/layers.js +607 -0
- package/dist/chunks/behaviours/layers.js.map +1 -0
- package/dist/chunks/behaviours/spec.js +181 -0
- package/dist/chunks/behaviours/spec.js.map +1 -0
- package/dist/chunks/buffered-events.js +57 -0
- package/dist/chunks/buffered-events.js.map +1 -0
- package/dist/chunks/color/contrast.js +57 -0
- package/dist/chunks/color/contrast.js.map +1 -0
- package/dist/chunks/{components/properties.js → color/index.js} +577 -522
- package/dist/chunks/color/index.js.map +1 -0
- package/dist/chunks/comments/document.js +32 -0
- package/dist/chunks/comments/document.js.map +1 -0
- package/dist/chunks/comments/list.js +182 -0
- package/dist/chunks/comments/list.js.map +1 -0
- package/dist/chunks/comments/merge.js +58 -0
- package/dist/chunks/comments/merge.js.map +1 -0
- package/dist/chunks/components/exposure.js +2291 -0
- package/dist/chunks/components/exposure.js.map +1 -0
- package/dist/chunks/components/variants.js +32 -0
- package/dist/chunks/components/variants.js.map +1 -0
- package/dist/chunks/coordinate.js +93 -55
- package/dist/chunks/coordinate.js.map +1 -1
- package/dist/chunks/css/grid.js +94 -0
- package/dist/chunks/css/grid.js.map +1 -0
- package/dist/chunks/css/index.js +160 -0
- package/dist/chunks/css/index.js.map +1 -0
- package/dist/chunks/fields/geometry.js +14 -0
- package/dist/chunks/fields/geometry.js.map +1 -0
- package/dist/chunks/group-bounds.js +104 -0
- package/dist/chunks/group-bounds.js.map +1 -0
- package/dist/chunks/icons/glyph.js +147 -0
- package/dist/chunks/icons/glyph.js.map +1 -0
- package/dist/chunks/index.js +1724 -663
- package/dist/chunks/index.js.map +1 -1
- package/dist/color.d.ts +72 -0
- package/dist/color.d.ts.map +1 -0
- package/dist/color.js +3 -0
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +2 -2
- package/dist/constants2.d.ts +3 -1
- package/dist/constants2.d.ts.map +1 -1
- package/dist/coordinate.d.ts +2 -448
- package/dist/coordinate.js +2 -2
- package/dist/copy.d.ts +1 -1
- package/dist/copy.js +1 -1
- package/dist/css.d.ts +39 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/css.js +3 -0
- package/dist/geometry.d.ts +1 -1
- package/dist/geometry.js +1 -1
- package/dist/gradient.d.ts +51 -0
- package/dist/gradient.d.ts.map +1 -0
- package/dist/gradient.js +132 -0
- package/dist/gradient.js.map +1 -0
- package/dist/guides.d.ts +2 -2
- package/dist/guides.js +39 -0
- package/dist/guides.js.map +1 -0
- package/dist/hit-test.d.ts +2 -9
- package/dist/hit-test.js +176 -34
- package/dist/hit-test.js.map +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.js +19 -5
- package/dist/instances.d.ts +2 -2
- package/dist/instances.js +2 -2
- package/dist/layout.d.ts +2 -0
- package/dist/layout.js +4 -0
- package/dist/node-defaults.d.ts +2 -8
- package/dist/node-defaults.js +2 -2
- package/dist/order-keys.d.ts +39 -0
- package/dist/order-keys.d.ts.map +1 -0
- package/dist/order-keys.js +136 -0
- package/dist/order-keys.js.map +1 -0
- package/dist/parse-path.d.ts +7 -1
- package/dist/parse-path.d.ts.map +1 -1
- package/dist/parse-path.js +6 -2
- package/dist/parse-path.js.map +1 -1
- package/dist/polygon.d.ts +53 -0
- package/dist/polygon.d.ts.map +1 -0
- package/dist/polygon.js +205 -0
- package/dist/polygon.js.map +1 -0
- package/dist/preview.d.ts +1 -1
- package/dist/random.d.ts +7 -0
- package/dist/random.d.ts.map +1 -0
- package/dist/random.js +2 -0
- package/dist/resize.d.ts +11 -2
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +2 -184
- package/dist/snap.d.ts +1 -1
- package/dist/text-direction.d.ts +13 -0
- package/dist/text-direction.d.ts.map +1 -0
- package/dist/text-direction.js +31 -0
- package/dist/text-direction.js.map +1 -0
- package/dist/text-picture.d.ts +1 -1
- package/dist/text-picture.d.ts.map +1 -1
- package/dist/text.d.ts +2 -0
- package/dist/text.js +3 -0
- package/dist/types.d.ts +2121 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types2.d.ts +2 -2
- package/dist/undo.d.ts +2 -2
- package/dist/undo.js +2 -2
- package/dist/undo2.d.ts +29 -1
- package/dist/undo2.d.ts.map +1 -1
- package/dist/variables.d.ts +2 -29
- package/dist/variables.js +2 -2
- package/dist/variant-properties.d.ts +9 -1
- package/dist/variant-properties.d.ts.map +1 -1
- package/dist/variant-properties.js +36 -1
- package/dist/variant-properties.js.map +1 -1
- package/dist/vector-network.d.ts +1 -1
- package/dist/vector-network.js +1 -1
- package/package.json +60 -9
- package/src/behaviours/kinds.ts +185 -0
- package/src/behaviours/layers.ts +51 -0
- package/src/behaviours/model.ts +192 -0
- package/src/behaviours/schema.ts +58 -0
- package/src/behaviours/spec.ts +223 -0
- package/src/buffered-events.ts +64 -0
- package/src/color/contrast.ts +31 -0
- package/src/color/index.ts +88 -0
- package/src/color/management.ts +210 -0
- package/src/color/normalize.ts +7 -0
- package/src/color/okhcl.ts +201 -0
- package/src/comments/document.ts +51 -0
- package/src/comments/list.ts +52 -0
- package/src/comments/merge.ts +63 -0
- package/src/comments/threads.ts +156 -0
- package/src/components/exposure.ts +61 -0
- package/src/components/properties.ts +18 -15
- package/src/components/variants.ts +53 -0
- package/src/constants.ts +2 -0
- package/src/coordinate.ts +100 -43
- package/src/copy.ts +17 -6
- package/src/css/grid.ts +70 -0
- package/src/css/index.ts +9 -0
- package/src/css/layout.ts +53 -0
- package/src/css/shadows.ts +68 -0
- package/src/css/values.ts +42 -0
- package/src/export-format.ts +12 -0
- package/src/fields/geometry.ts +11 -0
- package/src/fields/text.ts +35 -0
- package/src/gradient.ts +166 -0
- package/src/group-bounds.ts +131 -0
- package/src/guides.ts +39 -0
- package/src/hit-test.ts +262 -46
- package/src/icons/glyph.ts +128 -0
- package/src/icons/model.ts +54 -0
- package/src/icons/schema.ts +18 -0
- package/src/index.ts +347 -57
- package/src/instance-overrides.ts +27 -0
- package/src/instances/content-size.ts +58 -0
- package/src/instances/copies.ts +239 -0
- package/src/instances/cycles.ts +73 -0
- package/src/instances/fields.ts +143 -0
- package/src/instances/main-component.ts +19 -0
- package/src/instances/placement.ts +29 -0
- package/src/instances/source-walk.ts +41 -0
- package/src/instances/sync.ts +600 -0
- package/src/instances/vector-geometry.ts +81 -0
- package/src/instances.ts +125 -330
- package/src/layout/aspect-ratio.ts +51 -0
- package/src/{layout-guides.ts → layout/guides.ts} +41 -12
- package/src/layout/index.ts +4 -0
- package/src/layout/keywords.ts +73 -0
- package/src/layout/sizing.ts +196 -0
- package/src/mutation-impact.ts +25 -10
- package/src/node-defaults.ts +50 -2
- package/src/order-keys.ts +162 -0
- package/src/parse-path.ts +10 -2
- package/src/plugin-data/field.ts +131 -0
- package/src/plugin-data/fields.ts +246 -0
- package/src/polygon.ts +211 -0
- package/src/preview.ts +1 -1
- package/src/random.ts +28 -0
- package/src/resize.ts +99 -12
- package/src/scaling/index.ts +2 -0
- package/src/scaling/node.ts +164 -0
- package/src/scaling/tree.ts +50 -0
- package/src/shaders/model.ts +98 -0
- package/src/shaders/schema.ts +48 -0
- package/src/shared-styles.ts +5 -2
- package/src/slots/authoring.ts +101 -0
- package/src/slots/content.ts +124 -0
- package/src/slots/frames.ts +160 -0
- package/src/slots/limits.ts +49 -0
- package/src/text/direction.ts +55 -0
- package/src/text/index.ts +3 -0
- package/src/text/lists.ts +138 -0
- package/src/text/paragraphs.ts +241 -0
- package/src/{text-picture.ts → text/picture.ts} +21 -29
- package/src/text/references.ts +50 -0
- package/src/transfer/apply.ts +84 -0
- package/src/transfer/history.ts +49 -0
- package/src/transfer/identity.ts +16 -0
- package/src/transfer/index.ts +6 -0
- package/src/transfer/nodes.ts +120 -0
- package/src/transfer/plan.ts +130 -0
- package/src/transfer/references.ts +9 -0
- package/src/transfer/remove.ts +39 -0
- package/src/transfer/validation.ts +59 -0
- package/src/transfer/variables.ts +82 -0
- package/src/types.ts +257 -13
- package/src/undo.ts +54 -2
- package/src/variables/bindings.ts +224 -0
- package/src/variables/fields.ts +43 -0
- package/src/variables/token.ts +14 -0
- package/src/variables/units.ts +15 -0
- package/src/variables.ts +118 -69
- package/src/variant-properties.ts +50 -0
- package/dist/chunks/components/properties.js.map +0 -1
- package/dist/chunks/export-scale.js +0 -19
- package/dist/chunks/export-scale.js.map +0 -1
- package/dist/coordinate.d.ts.map +0 -1
- package/dist/coordinate2.d.ts +0 -2
- package/dist/guides2.d.ts +0 -11
- package/dist/guides2.d.ts.map +0 -1
- package/dist/hit-test.d.ts.map +0 -1
- package/dist/layout-guides.d.ts +0 -2
- package/dist/layout-guides.js +0 -2
- package/dist/layout-guides2.d.ts +0 -16
- package/dist/layout-guides2.d.ts.map +0 -1
- package/dist/node-defaults.d.ts.map +0 -1
- package/dist/preview2.d.ts +0 -12
- package/dist/preview2.d.ts.map +0 -1
- package/dist/resize.js.map +0 -1
- package/dist/variables.d.ts.map +0 -1
- package/dist/vector-network2.d.ts +0 -32
- package/dist/vector-network2.d.ts.map +0 -1
- package/src/instance-overrides.test.ts +0 -67
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,385 @@
|
|
|
1
|
-
import { Color, Matrix, Rect, Vector } from "./primitives2.js";
|
|
2
|
-
import {
|
|
1
|
+
import { Color, GUID, Matrix, Rect, Vector } from "./primitives2.js";
|
|
2
|
+
import { Mat3 } from "./matrix2.js";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
import { Emitter } from "nanoevents";
|
|
5
|
+
//#region src/export-format.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Formats a node's export settings may persist. Each id must name a Core IO
|
|
8
|
+
* export adapter that supports node export; labels and options come from that
|
|
9
|
+
* adapter, so this list only decides what the Export panel offers.
|
|
10
|
+
*/
|
|
11
|
+
declare const EXPORT_FORMAT_IDS: readonly ["png", "jpg", "webp", "svg", "pdf", "pptx"];
|
|
12
|
+
type ExportFormatId = (typeof EXPORT_FORMAT_IDS)[number];
|
|
13
|
+
declare function isExportFormatId(value: unknown): value is ExportFormatId;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/mutation-impact.d.ts
|
|
16
|
+
interface SceneMutationImpact {
|
|
17
|
+
changedNodeIds: Set<string>;
|
|
18
|
+
previousParentIds: Set<string>;
|
|
19
|
+
currentParentIds: Set<string>;
|
|
20
|
+
createdNodeIds: Set<string>;
|
|
21
|
+
deletedNodeIds: Set<string>;
|
|
22
|
+
}
|
|
23
|
+
declare function createSceneMutationImpact(): SceneMutationImpact;
|
|
24
|
+
type MutationImpactListener = (impact: SceneMutationImpact) => void;
|
|
25
|
+
interface CollectedSceneMutation<T> {
|
|
26
|
+
result: T;
|
|
27
|
+
impact: SceneMutationImpact;
|
|
28
|
+
}
|
|
29
|
+
/** Records into `impact` the nodes and parent containers the graph's edits touch, until unbound. */
|
|
30
|
+
declare function recordSceneMutations(graph: SceneGraph, impact: SceneMutationImpact, shouldRecord?: () => boolean): () => void;
|
|
31
|
+
/** Collects the actual graph nodes and parent containers touched by an operation. */
|
|
32
|
+
declare function collectSceneMutation<T>(graph: SceneGraph, operation: () => T | Promise<T>): Promise<CollectedSceneMutation<T>>;
|
|
33
|
+
declare function mutationLayoutScopeIds(impact: SceneMutationImpact): string[];
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/variables.d.ts
|
|
36
|
+
declare function addVariable(graph: SceneGraph, variable: Variable): void;
|
|
37
|
+
declare function removeVariable(graph: SceneGraph, id: string): void;
|
|
38
|
+
declare function addCollection(graph: SceneGraph, collection: VariableCollection): void;
|
|
39
|
+
declare function createVariable(graph: SceneGraph, generateId: () => string, name: string, type: VariableType, collectionId: string, value?: VariableValue): Variable;
|
|
40
|
+
declare function createCollection(graph: SceneGraph, generateId: () => string, name: string): VariableCollection;
|
|
41
|
+
declare function removeCollection(graph: SceneGraph, id: string): void;
|
|
42
|
+
declare function getActiveModeId(graph: SceneGraph, collectionId: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* What a node without an explicit mode falls back to: the mode the editor shows (`active`), or
|
|
45
|
+
* the collection's default (`default`), which is what a saved document means to other tools.
|
|
46
|
+
*/
|
|
47
|
+
type VariableModeFallback = 'active' | 'default';
|
|
48
|
+
declare function getNodeVariableModeId(graph: SceneGraph, nodeId: string, collectionId: string, fallback?: VariableModeFallback): string;
|
|
49
|
+
declare function setActiveMode(graph: SceneGraph, collectionId: string, modeId: string): void;
|
|
50
|
+
declare function addMode(graph: SceneGraph, collectionId: string, modeId: string, name: string, sourceMode?: string): void;
|
|
51
|
+
/** Add a mode with a new ID from `generateId`; undo and redo replay it with `addMode`. */
|
|
52
|
+
declare function createMode(graph: SceneGraph, generateId: () => string, collectionId: string, name: string, sourceMode?: string): string | undefined;
|
|
53
|
+
declare function removeMode(graph: SceneGraph, collectionId: string, modeId: string): void;
|
|
54
|
+
declare function renameMode(graph: SceneGraph, collectionId: string, modeId: string, name: string): void;
|
|
55
|
+
declare function setDefaultMode(graph: SceneGraph, collectionId: string, modeId: string): void;
|
|
56
|
+
/** Figma has no default-mode field: the first mode is the default. */
|
|
57
|
+
declare function modesDefaultFirst(collection: VariableCollection): VariableCollectionMode[];
|
|
58
|
+
declare function resolveVariable(graph: SceneGraph, variableId: string, modeId?: string, visited?: Set<string>): VariableValue | undefined;
|
|
59
|
+
declare function resolveColorVariable(graph: SceneGraph, variableId: string): Color | undefined;
|
|
60
|
+
declare function resolveNumberVariable(graph: SceneGraph, variableId: string): number | undefined;
|
|
61
|
+
declare function resolveColorVariableForNode(graph: SceneGraph, nodeId: string, variableId: string, fallback?: VariableModeFallback): Color | undefined;
|
|
62
|
+
declare function resolveNumberVariableForNode(graph: SceneGraph, nodeId: string, variableId: string, fallback?: VariableModeFallback): number | undefined;
|
|
63
|
+
/** A variable's value in the mode a node is in, aliases followed. */
|
|
64
|
+
declare function resolveVariableForNode(graph: SceneGraph, nodeId: string, variableId: string, fallback?: VariableModeFallback): VariableValue | undefined;
|
|
65
|
+
declare function resolveStringVariableForNode(graph: SceneGraph, nodeId: string, variableId: string, fallback?: VariableModeFallback): string | undefined;
|
|
66
|
+
declare function getVariablesForCollection(graph: SceneGraph, collectionId: string): Variable[];
|
|
67
|
+
declare function getVariablesByType(graph: SceneGraph, type: VariableType): Variable[];
|
|
68
|
+
declare function bindVariable(graph: SceneGraph, nodeId: string, field: string, variableId: string): void;
|
|
69
|
+
declare function unbindVariable(graph: SceneGraph, nodeId: string, field: string): void;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/variables/fields.d.ts
|
|
72
|
+
declare function isNumericVariableBindingField(field: string): boolean;
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/variables/bindings.d.ts
|
|
75
|
+
/** New declarations belong to the outermost occurrence, bounded by a component definition. */
|
|
76
|
+
declare function variableBindingOwner(graph: SceneGraph, node: SceneNode): SceneNode;
|
|
77
|
+
declare function assignVariableBindingUnits(graph: SceneGraph, node: SceneNode, field: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* The values a node's numeric bindings resolve to in its mode, in scene units, for the fields
|
|
80
|
+
* whose stored value differs. A width or height an instance overrides keeps its own value.
|
|
81
|
+
*/
|
|
82
|
+
declare function resolvedNumericBindings(graph: SceneGraph, node: SceneNode, fallback?: VariableModeFallback): Partial<SceneNode>;
|
|
83
|
+
/**
|
|
84
|
+
* The text and visibility a node's string and boolean bindings resolve to in its mode, for the
|
|
85
|
+
* fields whose stored value differs. Text or visibility an instance overrides, which typing in a
|
|
86
|
+
* layer or toggling its eye records, keeps its own value, as an overridden width or height does.
|
|
87
|
+
* A bound font family is left as stored: changing it needs the font loaded, which resolving a
|
|
88
|
+
* binding cannot do.
|
|
89
|
+
*/
|
|
90
|
+
declare function resolvedValueBindings(graph: SceneGraph, node: SceneNode, fallback?: VariableModeFallback): Partial<SceneNode>;
|
|
91
|
+
/**
|
|
92
|
+
* The runs a text's character bindings resolve to in its mode, when a bound number differs from
|
|
93
|
+
* what its characters hold. Bound font families and styles are left as stored, as the text's own.
|
|
94
|
+
*/
|
|
95
|
+
declare function resolvedRunBindings(graph: SceneGraph, node: SceneNode, fallback?: VariableModeFallback): Pick<Partial<SceneNode>, 'styleRuns'>;
|
|
96
|
+
/** The fills and strokes a node's color bindings resolve to in its mode, when it has any. */
|
|
97
|
+
declare function resolvedPaintBindings(graph: SceneGraph, node: SceneNode, fallback?: VariableModeFallback): Pick<Partial<SceneNode>, 'fills' | 'strokes'>;
|
|
98
|
+
/**
|
|
99
|
+
* The layers a reconcile looks at: those bound to these variables, directly or through a variable
|
|
100
|
+
* aliasing them, or the layers in these subtrees. Without a scope, every layer.
|
|
101
|
+
*/
|
|
102
|
+
type BindingScope = {
|
|
103
|
+
variables: Iterable<string>;
|
|
104
|
+
} | {
|
|
105
|
+
subtrees: Iterable<string>;
|
|
106
|
+
};
|
|
107
|
+
/** These variables and every variable that aliases one of them, at any depth and in any mode. */
|
|
108
|
+
declare function variablesResolvingThrough(graph: SceneGraph, ids: Iterable<string>): Set<string>;
|
|
109
|
+
/**
|
|
110
|
+
* Resolve live numeric, text, and visibility bindings, numbers in scene units, without authoring
|
|
111
|
+
* instance overrides. A scope limits it to the layers a change can reach, so layers whose saved
|
|
112
|
+
* values differ from their bindings elsewhere in the document are left as saved.
|
|
113
|
+
*/
|
|
114
|
+
declare function reconcileVariableBindings(graph: SceneGraph, scope?: BindingScope): string[];
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/variables/token.d.ts
|
|
117
|
+
/** `rem` tokens are stored in canvas pixels and shown against this root font size. */
|
|
118
|
+
declare const ROOT_FONT_SIZE_PX = 16;
|
|
119
|
+
/** The stored number for a value typed in a unit: `1.5` in `rem` is 24 canvas pixels. */
|
|
120
|
+
declare function tokenNumberFromUnit(value: number, unit: TokenUnit): number;
|
|
121
|
+
/** A stored number as it reads in its unit: 24 canvas pixels in `rem` is `1.5`. */
|
|
122
|
+
declare function tokenNumberInUnit(value: number, unit: TokenUnit): number;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/plugin-data/field.d.ts
|
|
125
|
+
/** The plugin id OpenPencil keeps its own state under, on nodes and in `.fig` files. */
|
|
126
|
+
declare const OPEN_PENCIL_PLUGIN_ID = "open-pencil";
|
|
127
|
+
/**
|
|
128
|
+
* What a field holds:
|
|
129
|
+
* - `content` belongs to the node like its fills do and exists only as plugin data, so it
|
|
130
|
+
* travels with a component copied into a library or another document;
|
|
131
|
+
* - `format` repeats a node or variable field for files that have no slot for it, where the
|
|
132
|
+
* node field is what counts;
|
|
133
|
+
* - `bookkeeping` records where a node or document came from and stays behind.
|
|
134
|
+
*/
|
|
135
|
+
type PluginDataRole = 'content' | 'format' | 'bookkeeping';
|
|
136
|
+
/** One OpenPencil plugin-data key. */
|
|
137
|
+
interface PluginDataKey {
|
|
138
|
+
readonly key: string;
|
|
139
|
+
readonly role: PluginDataRole;
|
|
140
|
+
}
|
|
141
|
+
/** A plugin-data key and how its string value is read and written. */
|
|
142
|
+
interface PluginDataField<T> extends PluginDataKey {
|
|
143
|
+
/** The stored value, or `undefined` when it is missing or not a valid value. */
|
|
144
|
+
decode(value: string | null | undefined): T | undefined;
|
|
145
|
+
encode(value: T): string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A value stored as JSON. Invalid JSON and a wrong shape both read as missing: plugin data
|
|
149
|
+
* comes from files anyone can edit, so a bad entry is ignored rather than thrown on.
|
|
150
|
+
*/
|
|
151
|
+
declare function jsonPluginDataField<T>(key: string, role: PluginDataRole, schema: v.GenericSchema<unknown, T>): PluginDataField<T>;
|
|
152
|
+
/** A value stored as one of a fixed set of plain strings. */
|
|
153
|
+
declare function textPluginDataField<const T extends string>(key: string, role: PluginDataRole, values: readonly T[]): PluginDataField<T>;
|
|
154
|
+
declare function isPluginDataEntry(entry: PluginDataEntry, field: PluginDataKey): boolean;
|
|
155
|
+
declare function hasPluginData(entries: readonly PluginDataEntry[] | undefined, field: PluginDataKey): boolean;
|
|
156
|
+
declare function readPluginData<T>(entries: readonly PluginDataEntry[] | undefined, field: PluginDataField<T>): T | undefined;
|
|
157
|
+
/** Every valid value of a field kept as several entries under one key. */
|
|
158
|
+
declare function readAllPluginData<T>(entries: readonly PluginDataEntry[] | undefined, field: PluginDataField<T>): T[];
|
|
159
|
+
declare function pluginDataEntry<T>(field: PluginDataField<T>, value: T): PluginDataEntry;
|
|
160
|
+
/** Entries other than those of `fields`; other plugins' entries are always kept. */
|
|
161
|
+
declare function withoutPluginData(entries: readonly PluginDataEntry[], fields: readonly PluginDataKey[]): PluginDataEntry[];
|
|
162
|
+
/** Entries with `field` set to `value`, appended last; `undefined` removes the field. */
|
|
163
|
+
declare function withPluginData<T>(entries: readonly PluginDataEntry[], field: PluginDataField<T>, value: T | undefined): PluginDataEntry[];
|
|
164
|
+
/** Entries with every entry of `field` replaced by one per value. */
|
|
165
|
+
declare function withAllPluginData<T>(entries: readonly PluginDataEntry[], field: PluginDataField<T>, values: readonly T[]): PluginDataEntry[];
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/color/okhcl.d.ts
|
|
168
|
+
interface OkHCLColor {
|
|
169
|
+
h: number;
|
|
170
|
+
c: number;
|
|
171
|
+
l: number;
|
|
172
|
+
a?: number;
|
|
173
|
+
}
|
|
174
|
+
interface OkHCLPayload {
|
|
175
|
+
version: 1;
|
|
176
|
+
kind: 'fill' | 'stroke';
|
|
177
|
+
index: number;
|
|
178
|
+
color: OkHCLColor;
|
|
179
|
+
}
|
|
180
|
+
/** Colour spaces a document's stored numbers can be in. */
|
|
181
|
+
type OkHCLColorSpace = 'srgb' | 'display-p3';
|
|
182
|
+
/** Coordinates in `colorSpace`, so callers can store colours in the document's profile. */
|
|
183
|
+
declare function okhclToRGBA(color: OkHCLColor, colorSpace?: OkHCLColorSpace): Color;
|
|
184
|
+
/** Reads `color` as coordinates in `colorSpace`, the inverse of {@link okhclToRGBA}. */
|
|
185
|
+
declare function rgbaToOkHCL(color: Color, colorSpace?: OkHCLColorSpace): OkHCLColor;
|
|
186
|
+
declare function serializeOkHCLPayload(payload: OkHCLPayload): string;
|
|
187
|
+
declare function parseOkHCLPayload(value: string): OkHCLPayload | null;
|
|
188
|
+
declare function setNodeFillOkHCL(node: SceneNode, index: number, color: OkHCLColor, colorSpace?: OkHCLColorSpace): Partial<SceneNode>;
|
|
189
|
+
declare function setNodeStrokeOkHCL(node: SceneNode, index: number, color: OkHCLColor, colorSpace?: OkHCLColorSpace): Partial<SceneNode>;
|
|
190
|
+
declare function clearNodeFillOkHCL(node: SceneNode, index: number): Partial<SceneNode>;
|
|
191
|
+
declare function clearNodeStrokeOkHCL(node: SceneNode, index: number): Partial<SceneNode>;
|
|
192
|
+
declare function getNodeOkHCLPayloads(node: SceneNode): OkHCLPayload[];
|
|
193
|
+
declare function getFillOkHCL(node: SceneNode, index: number): OkHCLPayload | null;
|
|
194
|
+
declare function getStrokeOkHCL(node: SceneNode, index: number): OkHCLPayload | null;
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/plugin-data/fields.d.ts
|
|
197
|
+
/** Token fields Figma has no slot for, with mode ids as the file spells them. */
|
|
198
|
+
interface StoredToken {
|
|
199
|
+
unit?: TokenUnit;
|
|
200
|
+
expressions?: Record<string, {
|
|
201
|
+
css: string;
|
|
202
|
+
resolved: number;
|
|
203
|
+
}>;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Every plugin-data entry OpenPencil writes under {@link OPEN_PENCIL_PLUGIN_ID}: state Figma's
|
|
207
|
+
* format has no field for. Add a key here, never as a string elsewhere, so reading and writing
|
|
208
|
+
* it share one schema.
|
|
209
|
+
*/
|
|
210
|
+
declare const OPEN_PENCIL_PLUGIN_DATA: {
|
|
211
|
+
/** A text node's direction, on TEXT nodes. */
|
|
212
|
+
textDirection: PluginDataField<"AUTO" | "LTR" | "RTL">;
|
|
213
|
+
/** An auto-layout frame's direction. */
|
|
214
|
+
layoutDirection: PluginDataField<"AUTO" | "LTR" | "RTL">;
|
|
215
|
+
/** Marks a component set Figma would read as a plain frame. */
|
|
216
|
+
nodeType: PluginDataField<"COMPONENT_SET">;
|
|
217
|
+
/** Variable bindings by field path, including those Figma cannot store natively. */
|
|
218
|
+
boundVariables: PluginDataField<{
|
|
219
|
+
[k: string]: string;
|
|
220
|
+
}>;
|
|
221
|
+
exportSettings: PluginDataField<ExportSetting[]>;
|
|
222
|
+
/** The node-local rect a TEXT_PATH layout maps onto, which Kiwi has no field for. */
|
|
223
|
+
textPathBox: PluginDataField<Rect>;
|
|
224
|
+
/** The library asset a node was inserted from. */
|
|
225
|
+
librarySource: PluginDataField<LibraryAssetSource>;
|
|
226
|
+
/** Libraries enabled for the document, on the DOCUMENT node. */
|
|
227
|
+
enabledLibraries: PluginDataField<EnabledLibraryBinding[]>;
|
|
228
|
+
/** The library this document publishes as, on the DOCUMENT node. */
|
|
229
|
+
sourceLibraryPublication: PluginDataField<SourceLibraryPublication>;
|
|
230
|
+
/** Canvas comment threads, deleted ones included, on the DOCUMENT node. */
|
|
231
|
+
comments: PluginDataField<CommentThread[]>;
|
|
232
|
+
/** Unit and CSS expressions, on each VARIABLE. */
|
|
233
|
+
token: PluginDataField<StoredToken>;
|
|
234
|
+
/** Mode conditions by mode id, on each VARIABLE_SET. */
|
|
235
|
+
modeConditions: PluginDataField<{
|
|
236
|
+
[x: string]: string;
|
|
237
|
+
}>;
|
|
238
|
+
/** The attribute that switches manual modes, on each VARIABLE_SET. */
|
|
239
|
+
modeAttribute: PluginDataField<string>;
|
|
240
|
+
/** One entry per paint picked in OkHCL, so the picker reopens on the same coordinates. */
|
|
241
|
+
okhcl: PluginDataField<OkHCLPayload>;
|
|
242
|
+
/** How a main component or component set behaves as a control in preview. */
|
|
243
|
+
behaviour: PluginDataField<{
|
|
244
|
+
kind: "button" | "textField" | "textarea" | "numberField" | "toggle" | "switch" | "checkbox" | "radio" | "radioGroup" | "toggleGroup" | "slider" | "progress" | "tabs" | "collapsible" | "accordion";
|
|
245
|
+
booleans: {
|
|
246
|
+
[x: string]: {
|
|
247
|
+
propertyId: string;
|
|
248
|
+
on?: string | undefined;
|
|
249
|
+
off?: string | undefined;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
texts: {
|
|
253
|
+
[x: string]: {
|
|
254
|
+
propertyId: string;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
numbers: {
|
|
258
|
+
[x: string]: {
|
|
259
|
+
min: number;
|
|
260
|
+
max: number;
|
|
261
|
+
step: number;
|
|
262
|
+
default: number;
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
parts: {
|
|
266
|
+
[x: string]: string;
|
|
267
|
+
};
|
|
268
|
+
states?: {
|
|
269
|
+
rest?: string | undefined;
|
|
270
|
+
hover?: string | undefined;
|
|
271
|
+
pressed?: string | undefined;
|
|
272
|
+
focus?: string | undefined;
|
|
273
|
+
disabled?: string | undefined;
|
|
274
|
+
propertyId: string;
|
|
275
|
+
} | undefined;
|
|
276
|
+
}>;
|
|
277
|
+
/** The icon a frame draws, such as `lucide:home`, on the frame its paths are in. */
|
|
278
|
+
icon: PluginDataField<{
|
|
279
|
+
name: string;
|
|
280
|
+
glyph?: string | undefined;
|
|
281
|
+
}>;
|
|
282
|
+
/** Which of an icon path's paints its icon's color sets, on each path the source drew in it. */
|
|
283
|
+
iconTint: PluginDataField<("fill" | "stroke")[]>;
|
|
284
|
+
/** One entry per paint that draws a shader, matched to its image paint by the frame's hash. */
|
|
285
|
+
shader: PluginDataField<{
|
|
286
|
+
image: string;
|
|
287
|
+
preset: {
|
|
288
|
+
components: ShaderComponent[];
|
|
289
|
+
structureVersion?: number | undefined;
|
|
290
|
+
};
|
|
291
|
+
frame?: {
|
|
292
|
+
width: number;
|
|
293
|
+
height: number;
|
|
294
|
+
preset: string;
|
|
295
|
+
} | undefined;
|
|
296
|
+
}>;
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* A node's plugin data that is part of its content, in a stable order: OpenPencil's content
|
|
300
|
+
* fields and every other plugin's entries, which the node carries wherever it goes. Format
|
|
301
|
+
* copies of node fields and bookkeeping are left out.
|
|
302
|
+
*/
|
|
303
|
+
declare function contentPluginData(entries: readonly PluginDataEntry[]): PluginDataEntry[];
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/scaling/node.d.ts
|
|
306
|
+
declare function scaleNodeChanges(node: SceneNode, scale: number, scalePosition: boolean): Partial<SceneNode>;
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/scaling/tree.d.ts
|
|
309
|
+
/** Scale a node tree from the root node's top-left, matching Figma's Scale tool. */
|
|
310
|
+
declare function rescaleNodeTree(graph: SceneGraph, rootId: string, scale: number): void;
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/fields/geometry.d.ts
|
|
313
|
+
/** Placement/orientation only; dimensions are a separate geometry contract. */
|
|
314
|
+
declare const TRANSFORM_FIELDS: readonly ["x", "y", "rotation", "flipX", "flipY"];
|
|
315
|
+
declare const SIZE_FIELDS: readonly ["width", "height"];
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/fields/text.d.ts
|
|
318
|
+
/** Fields shared by shaping, paragraph measurement, and auto-width invalidation. */
|
|
319
|
+
declare const TEXT_METRIC_FIELDS: readonly ["text", "fontSize", "fontFamily", "fontWeight", "italic", "letterSpacing", "styleRuns", "fontVariations", "fontFeatures", "textParagraphs", "listSpacing", "paragraphSpacing", "paragraphIndent", "hangingList"];
|
|
320
|
+
declare const TEXT_SHAPING_FIELDS: readonly ["text", "fontSize", "fontFamily", "fontWeight", "italic", "letterSpacing", "styleRuns", "fontVariations", "fontFeatures", "textParagraphs", "listSpacing", "paragraphSpacing", "paragraphIndent", "hangingList", "lineHeight", "textCase", "textDirection", "textAlignHorizontal", "textAlignVertical"];
|
|
321
|
+
declare const TEXT_LAYOUT_FIELDS: readonly ["width", "height", "textAutoResize", "maxLines"];
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/transfer/plan.d.ts
|
|
324
|
+
interface GraphTransferInput {
|
|
325
|
+
source: SceneGraph;
|
|
326
|
+
rootIds: readonly string[];
|
|
327
|
+
dependencyPageIds: readonly string[];
|
|
328
|
+
target: SceneGraph;
|
|
329
|
+
parentId: string;
|
|
330
|
+
}
|
|
331
|
+
/** Preflight a self-contained fragment; allocation does not insert anything into the target. */
|
|
332
|
+
declare function prepareGraphTransfer(input: GraphTransferInput): {
|
|
333
|
+
activeModes: Map<string, string>;
|
|
334
|
+
images: Map<string, Uint8Array<ArrayBuffer>>;
|
|
335
|
+
variables: Variable[];
|
|
336
|
+
collections: VariableCollection[];
|
|
337
|
+
nodeIds: Map<string, string>;
|
|
338
|
+
rootIds: string[];
|
|
339
|
+
dependencyPageIds: string[];
|
|
340
|
+
nodes: {
|
|
341
|
+
id: string;
|
|
342
|
+
type: NodeType;
|
|
343
|
+
parentId: string;
|
|
344
|
+
props: Partial<SceneNode>;
|
|
345
|
+
}[];
|
|
346
|
+
};
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/transfer/apply.d.ts
|
|
349
|
+
type GraphTransferPlan = ReturnType<typeof prepareGraphTransfer>;
|
|
350
|
+
/** Revalidate at insertion time. Event-delivery failures after commit are not rollback failures. */
|
|
351
|
+
declare function applyGraphTransfer(target: SceneGraph, input: GraphTransferPlan): void;
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/transfer/remove.d.ts
|
|
354
|
+
/** Refuse to remove transferred content that has acquired external dependents. */
|
|
355
|
+
declare function removeGraphTransfer(graph: SceneGraph, plan: GraphTransferPlan): void;
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/transfer/history.d.ts
|
|
358
|
+
/** Capture post-placement state for redo; this does not authorize deleting shared resources. */
|
|
359
|
+
declare function captureTransferredState(graph: SceneGraph, original: GraphTransferPlan): GraphTransferPlan;
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/transfer/variables.d.ts
|
|
362
|
+
interface VariableTransferReferences {
|
|
363
|
+
variables: ReadonlyMap<string, string>;
|
|
364
|
+
collections: ReadonlyMap<string, string>;
|
|
365
|
+
modes: ReadonlyMap<string, string>;
|
|
366
|
+
}
|
|
367
|
+
/** Prepare isolated resource copies; never mutate the source or destination graph. */
|
|
368
|
+
declare function prepareVariableTransfer(variables: readonly Variable[], collections: readonly VariableCollection[], references: VariableTransferReferences): {
|
|
369
|
+
variables: Variable[];
|
|
370
|
+
collections: VariableCollection[];
|
|
371
|
+
};
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/transfer/nodes.d.ts
|
|
374
|
+
interface NodeTransferReferences extends VariableTransferReferences {
|
|
375
|
+
nodes: ReadonlyMap<string, string>;
|
|
376
|
+
styles: ReadonlyMap<string, string>;
|
|
377
|
+
properties: ReadonlyMap<string, string>;
|
|
378
|
+
propertyTypes: ReadonlyMap<string, ComponentPropertyType>;
|
|
379
|
+
}
|
|
380
|
+
/** Prepare runtime references without rewriting original format identities or ordinary text. */
|
|
381
|
+
declare function prepareNodeTransfer(source: SceneNode, refs: NodeTransferReferences): Partial<SceneNode>;
|
|
382
|
+
//#endregion
|
|
3
383
|
//#region src/instance-overrides.d.ts
|
|
4
384
|
type InstanceOverrideField = string;
|
|
5
385
|
interface InstanceOverrideState {
|
|
@@ -18,12 +398,1547 @@ interface SerializedInstanceOverrideState {
|
|
|
18
398
|
declare function serializeInstanceOverrideState(state: InstanceOverrideState): SerializedInstanceOverrideState;
|
|
19
399
|
declare function deserializeInstanceOverrideState(state: unknown): InstanceOverrideState;
|
|
20
400
|
declare function cloneInstanceOverrideState(state: InstanceOverrideState): InstanceOverrideState;
|
|
401
|
+
interface InstanceOverrideReferenceMapper {
|
|
402
|
+
node: (id: string) => string;
|
|
403
|
+
variable: (id: string) => string;
|
|
404
|
+
}
|
|
405
|
+
/** Remap runtime identities only; ordinary strings and source-format payloads stay opaque. */
|
|
406
|
+
declare function remapInstanceOverrideState(state: InstanceOverrideState, references: InstanceOverrideReferenceMapper): InstanceOverrideState;
|
|
21
407
|
declare function getInstanceOverride(state: InstanceOverrideState, instanceId: string, nodeId: string, field: InstanceOverrideField): unknown;
|
|
22
408
|
declare function setInstanceOverride(state: InstanceOverrideState, instanceId: string, nodeId: string, field: InstanceOverrideField, value?: unknown): void;
|
|
23
409
|
declare function deleteInstanceOverride(state: InstanceOverrideState, instanceId: string, nodeId: string, field: InstanceOverrideField): boolean;
|
|
24
410
|
declare function clearInstanceOverrides(state: InstanceOverrideState): void;
|
|
25
411
|
declare function forEachInstanceOverride(state: InstanceOverrideState, callback: (nodeId: string, field: InstanceOverrideField, value: unknown) => void): void;
|
|
26
412
|
//#endregion
|
|
413
|
+
//#region src/components/properties.d.ts
|
|
414
|
+
interface ComponentPropertyTarget {
|
|
415
|
+
node: SceneNode;
|
|
416
|
+
field: ComponentPropertyReferenceField;
|
|
417
|
+
source: SceneNode;
|
|
418
|
+
}
|
|
419
|
+
declare function componentPropertyOwners(graph: SceneGraph, instance: SceneNode): SceneNode[];
|
|
420
|
+
declare function componentPropertyDefinitions(graph: SceneGraph, instance: SceneNode): ComponentPropertyDefinition[];
|
|
421
|
+
declare function resolveComponentPropertyValue(graph: SceneGraph, value: string): SceneNode | null;
|
|
422
|
+
declare function findComponentPropertyTarget(graph: SceneGraph, instance: SceneNode, propertyId: string): ComponentPropertyTarget | null;
|
|
423
|
+
declare function findComponentPropertyTargets(graph: SceneGraph, instance: SceneNode, propertyId: string): ComponentPropertyTarget[];
|
|
424
|
+
declare function applyComponentPropertyValue(graph: SceneGraph, instanceId: string, definition: ComponentPropertyDefinition, value: string): SceneNode | null;
|
|
425
|
+
declare function removeComponentProperty(graph: SceneGraph, ownerId: string, propertyId: string): boolean;
|
|
426
|
+
/** A new component property ID, in the `prop:` form the editor, plugin API, and design JSX share. */
|
|
427
|
+
declare function createComponentPropertyId(): string;
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/components/variants.d.ts
|
|
430
|
+
/** Variants in reading order on the canvas: top to bottom, then left to right, then by name. */
|
|
431
|
+
declare function compareCanvasPosition(a: SceneNode, b: SceneNode): number;
|
|
432
|
+
/**
|
|
433
|
+
* A component set's default variant, the one an instance starts as: the variant in its
|
|
434
|
+
* top-left corner, as Figma defines it.
|
|
435
|
+
*/
|
|
436
|
+
declare function defaultVariant(graph: SceneGraph, set: SceneNode): SceneNode | undefined;
|
|
437
|
+
/**
|
|
438
|
+
* The value a variant property starts at: its recorded default when that is one of its options,
|
|
439
|
+
* or else the default variant's, since a document may leave the recorded default empty.
|
|
440
|
+
*/
|
|
441
|
+
declare function variantDefaultValue(graph: SceneGraph, set: SceneNode, property: {
|
|
442
|
+
name: string;
|
|
443
|
+
defaultValue: string;
|
|
444
|
+
variantOptions?: string[];
|
|
445
|
+
}): string;
|
|
446
|
+
/**
|
|
447
|
+
* The variant with every property at its default value: the recorded defaults when they name a
|
|
448
|
+
* variant, else the default variant, as a document that leaves them out draws it.
|
|
449
|
+
*/
|
|
450
|
+
declare function restingVariant(graph: SceneGraph, set: SceneNode): SceneNode | undefined;
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/slots/frames.d.ts
|
|
453
|
+
/** The slot property a frame holds the content of, if it is a slot. */
|
|
454
|
+
declare function slotPropertyId(node: SceneNode): string | undefined;
|
|
455
|
+
/**
|
|
456
|
+
* Whether this slot frame's children belong to its instance rather than its component: the
|
|
457
|
+
* nearest enclosing instance assigns the slot. Such content is never synced from the component.
|
|
458
|
+
*/
|
|
459
|
+
declare function ownsSlotContent(graph: SceneGraph, node: SceneNode, propertyId?: string | undefined): boolean;
|
|
460
|
+
/** An instance's slot frames, without entering nested instances, whose slots are their own. */
|
|
461
|
+
declare function instanceSlotFrames(graph: SceneGraph, instance: SceneNode): SceneNode[];
|
|
462
|
+
/** One slot's owned content, parked while the instance it belongs to is rebuilt. */
|
|
463
|
+
interface ParkedSlot {
|
|
464
|
+
/** Names of the nested instances leading to the slot's owner; empty for the instance itself. */
|
|
465
|
+
path: string[];
|
|
466
|
+
/** The slot property's name, which the replacement must share. */
|
|
467
|
+
name: string;
|
|
468
|
+
/** Content layer ids, in layer order. */
|
|
469
|
+
content: string[];
|
|
470
|
+
}
|
|
471
|
+
/** Owned slot content parked under an instance while its component changes. */
|
|
472
|
+
interface ParkedSlotContent {
|
|
473
|
+
slots: ParkedSlot[];
|
|
474
|
+
/** The instance's own slot assignments the content was parked from. */
|
|
475
|
+
propertyIds: string[];
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Park the slot content an instance and the instances nested in it own, by slot name and the
|
|
479
|
+
* nested instance's name path, directly under the instance, so its component can be replaced.
|
|
480
|
+
* Figma keeps that content when a variant switch or swap leads to slots of the same names.
|
|
481
|
+
*/
|
|
482
|
+
declare function detachOwnedSlotContent(graph: SceneGraph, instance: SceneNode): ParkedSlotContent;
|
|
483
|
+
/** Move parked content into the slots of the same names and paths, and reassign them. */
|
|
484
|
+
declare function restoreOwnedSlotContent(graph: SceneGraph, instance: SceneNode, parked: ParkedSlotContent): void;
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/instances/main-component.d.ts
|
|
487
|
+
/**
|
|
488
|
+
* The main component an instance shows. An instance nested in another instance points at the
|
|
489
|
+
* instance it was cloned from, so follow those links to the component.
|
|
490
|
+
*/
|
|
491
|
+
declare function instanceMainComponent(graph: SceneGraph, instance: SceneNode): SceneNode | undefined;
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/instances/cycles.d.ts
|
|
494
|
+
/**
|
|
495
|
+
* Whether moving `nodeId` under `parentId` would make a component contain itself: its layers,
|
|
496
|
+
* followed through instances into their components, reach a component at or above the parent.
|
|
497
|
+
* Both components and instances above the parent count: an instance's layers are its
|
|
498
|
+
* component's, so a swap inside one may not bring that component back in.
|
|
499
|
+
*/
|
|
500
|
+
declare function createsComponentCycle(graph: SceneGraph, nodeId: string, parentId: string): boolean;
|
|
501
|
+
/** Whether placing this definition's instance under `parentId` would make a component contain itself. */
|
|
502
|
+
declare function canCreateInstance(graph: SceneGraph, componentId: string, parentId: string): boolean;
|
|
503
|
+
/**
|
|
504
|
+
* `parentId`, or its nearest ancestor that can hold these layers or instances of these
|
|
505
|
+
* components without a component containing itself. Figma pastes an instance next to its own
|
|
506
|
+
* component, not in it.
|
|
507
|
+
*/
|
|
508
|
+
declare function cycleSafeParent(graph: SceneGraph, parentId: string, nodeIds: readonly string[]): string;
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/components/exposure.d.ts
|
|
511
|
+
/**
|
|
512
|
+
* Instances a component can expose: those in its own layers, not inside another instance,
|
|
513
|
+
* whose content belongs to that instance's component.
|
|
514
|
+
*/
|
|
515
|
+
declare function exposableInstances(graph: SceneGraph, componentId: string): SceneNode[];
|
|
516
|
+
/**
|
|
517
|
+
* The layers of an instance that stand for exposed nested instances of its component, in
|
|
518
|
+
* layer order. Each is matched to its source the way instance sync matches children.
|
|
519
|
+
*/
|
|
520
|
+
declare function exposedInstances(graph: SceneGraph, instance: SceneNode): SceneNode[];
|
|
521
|
+
/** Why Figma refuses to expose an instance, or null when it may be exposed. */
|
|
522
|
+
type InstanceExposureIssue = 'not-in-component' | 'not-primary' | 'nothing-to-expose';
|
|
523
|
+
/**
|
|
524
|
+
* Whether an instance may be exposed, under Figma's rules: it sits in a component's own layers
|
|
525
|
+
* (an instance's copy follows its source) and its component has properties or exposes nested
|
|
526
|
+
* instances itself.
|
|
527
|
+
*/
|
|
528
|
+
declare function instanceExposureIssue(graph: SceneGraph, instance: SceneNode): InstanceExposureIssue | null;
|
|
529
|
+
//#endregion
|
|
530
|
+
//#region src/slots/content.d.ts
|
|
531
|
+
/**
|
|
532
|
+
* Where layers may be added, moved, or removed under a parent:
|
|
533
|
+
* - `free`: outside any instance, or inside a component definition;
|
|
534
|
+
* - `slot`: inside a slot of an instance, whose content the instance owns or can claim;
|
|
535
|
+
* - `locked`: anywhere else inside an instance, whose layers come from its component.
|
|
536
|
+
*/
|
|
537
|
+
type SlotScope = {
|
|
538
|
+
kind: 'free';
|
|
539
|
+
} | {
|
|
540
|
+
kind: 'slot';
|
|
541
|
+
frame: SceneNode;
|
|
542
|
+
instance: SceneNode;
|
|
543
|
+
propertyId: string;
|
|
544
|
+
} | {
|
|
545
|
+
kind: 'locked';
|
|
546
|
+
instance: SceneNode;
|
|
547
|
+
};
|
|
548
|
+
declare function slotScope(graph: SceneGraph, parentId: string): SlotScope;
|
|
549
|
+
/**
|
|
550
|
+
* Make the instance own its slot's content, as Figma does on the first edit: the layers
|
|
551
|
+
* stay where they are, but stop following the component. Overrides the instance held for
|
|
552
|
+
* them become their own values, or move to the nested instance they belong to.
|
|
553
|
+
*/
|
|
554
|
+
declare function claimSlotContent(graph: SceneGraph, scope: Extract<SlotScope, {
|
|
555
|
+
kind: 'slot';
|
|
556
|
+
}>): void;
|
|
557
|
+
/** Return the slot to its component's content: the instance stops owning it. */
|
|
558
|
+
declare function resetSlotContent(graph: SceneGraph, scope: Extract<SlotScope, {
|
|
559
|
+
kind: 'slot';
|
|
560
|
+
}>): void;
|
|
561
|
+
/** Remove everything from the slot; the instance keeps owning it, now empty. */
|
|
562
|
+
declare function clearSlotContent(graph: SceneGraph, scope: Extract<SlotScope, {
|
|
563
|
+
kind: 'slot';
|
|
564
|
+
}>): void;
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region src/slots/authoring.d.ts
|
|
567
|
+
/** The settings a new slot starts with: no limits, any layer allowed. */
|
|
568
|
+
declare const DEFAULT_SLOT_SETTINGS: SlotSettings;
|
|
569
|
+
/**
|
|
570
|
+
* The main component a layer belongs to, which defines the slots inside it. Layers of an
|
|
571
|
+
* instance are not authored there, so a layer under an instance has none.
|
|
572
|
+
*/
|
|
573
|
+
declare function slotOwner(graph: SceneGraph, node: SceneNode): SceneNode | undefined;
|
|
574
|
+
/** Whether a frame inside a main component can become a slot. */
|
|
575
|
+
declare function canCreateSlot(graph: SceneGraph, node: SceneNode): boolean;
|
|
576
|
+
/**
|
|
577
|
+
* Make a frame of a main component a slot: define a SLOT property, named after the frame, on
|
|
578
|
+
* the component and bind the frame's children to it. Instances pick up the slot on their next
|
|
579
|
+
* sync.
|
|
580
|
+
*/
|
|
581
|
+
declare function createSlotProperty(graph: SceneGraph, frameId: string, id: string): ComponentPropertyDefinition | null;
|
|
582
|
+
/** What a slot's settings panel can change. */
|
|
583
|
+
type SlotPropertyPatch = Partial<Pick<ComponentPropertyDefinition, 'name' | 'description' | 'preferredValues'>> & {
|
|
584
|
+
slotSettings?: Partial<SlotSettings>;
|
|
585
|
+
};
|
|
586
|
+
/** Change a slot property's name, description, preferred components, or limits. */
|
|
587
|
+
declare function updateSlotProperty(graph: SceneGraph, ownerId: string, propertyId: string, patch: SlotPropertyPatch): boolean;
|
|
588
|
+
//#endregion
|
|
589
|
+
//#region src/slots/limits.d.ts
|
|
590
|
+
/** A limit a slot's content breaks, named as Figma's `SlotNode.limitViolations` names them. */
|
|
591
|
+
type SlotLimitViolation = 'BELOW_MIN' | 'ABOVE_MAX' | 'HAS_NON_PREFERRED';
|
|
592
|
+
/** Whether a component is among a slot's preferred values, by id, key, or library key. */
|
|
593
|
+
declare function isPreferredComponent(component: SceneNode | undefined, preferredValues?: readonly string[]): boolean;
|
|
594
|
+
/** Content layers a preferred-only slot does not allow: anything but preferred instances. */
|
|
595
|
+
declare function nonPreferredLayers(graph: SceneGraph, definition: ComponentPropertyDefinition, content: readonly SceneNode[]): SceneNode[];
|
|
596
|
+
/** The limits a slot's content breaks; below-minimum and above-maximum exclude each other. */
|
|
597
|
+
declare function slotLimitViolations(graph: SceneGraph, definition: ComponentPropertyDefinition, content: readonly SceneNode[]): SlotLimitViolation[];
|
|
598
|
+
//#endregion
|
|
599
|
+
//#region src/behaviours/kinds.d.ts
|
|
600
|
+
/** The controls a main component can behave as, in the order the picker lists them. */
|
|
601
|
+
declare const BEHAVIOUR_KINDS: readonly ["button", "textField", "textarea", "numberField", "toggle", "switch", "checkbox", "radio", "radioGroup", "toggleGroup", "slider", "progress", "tabs", "collapsible", "accordion"];
|
|
602
|
+
type BehaviourKind = (typeof BEHAVIOUR_KINDS)[number];
|
|
603
|
+
/**
|
|
604
|
+
* The interaction states a control can show, each drawn as a value of one variant property:
|
|
605
|
+
* at rest, under the pointer, while pressed, focused from the keyboard, and disabled.
|
|
606
|
+
*/
|
|
607
|
+
declare const INTERACTION_STATES: readonly ["rest", "hover", "pressed", "focus", "disabled"];
|
|
608
|
+
type InteractionState = (typeof INTERACTION_STATES)[number];
|
|
609
|
+
/**
|
|
610
|
+
* How a behaviour value is held. A boolean is a variant or boolean property of the component,
|
|
611
|
+
* and text is a text property. Figma has no number property, so a number is the behaviour's
|
|
612
|
+
* own (min, max, step, default); a choice is which item of a slot is active, the first by
|
|
613
|
+
* default.
|
|
614
|
+
*/
|
|
615
|
+
type BehaviourValueType = 'boolean' | 'text' | 'number' | 'choice';
|
|
616
|
+
/** A value of the control: its state, which preview reads and changes. */
|
|
617
|
+
interface BehaviourValueContract {
|
|
618
|
+
id: string;
|
|
619
|
+
type: BehaviourValueType;
|
|
620
|
+
/** Whether a boolean or text value must be bound before the behaviour is complete. */
|
|
621
|
+
required: boolean;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* A Reka UI subcomponent of the control, which is a slot of the component: the behaviour binds
|
|
625
|
+
* it to one of the component's slot properties, never to a layer found by name.
|
|
626
|
+
*/
|
|
627
|
+
interface BehaviourPartContract {
|
|
628
|
+
id: string;
|
|
629
|
+
required: boolean;
|
|
630
|
+
/**
|
|
631
|
+
* Whether the slot holds the control's items, each an instance with its own behaviour (a
|
|
632
|
+
* radio, a toggle, a collapsible), which the control turns on and off.
|
|
633
|
+
*/
|
|
634
|
+
items?: boolean;
|
|
635
|
+
/**
|
|
636
|
+
* The Reka UI part each child of the slot is, when the slot holds repeated parts: a tab list's
|
|
637
|
+
* triggers, the tabs' content panels, or a group's items.
|
|
638
|
+
*/
|
|
639
|
+
children?: string;
|
|
640
|
+
}
|
|
641
|
+
interface BehaviourContract {
|
|
642
|
+
values: BehaviourValueContract[];
|
|
643
|
+
parts: BehaviourPartContract[];
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* The behaviours OpenPencil knows, after Reka UI's primitives. Their states are drawn as the
|
|
647
|
+
* component's variants and properties; their subcomponents (thumb, range, trigger, …) are the
|
|
648
|
+
* component's slots, and the component itself is the control's root.
|
|
649
|
+
*/
|
|
650
|
+
declare const BEHAVIOUR_CONTRACTS: Readonly<Record<BehaviourKind, BehaviourContract>>;
|
|
651
|
+
declare function behaviourContract(kind: BehaviourKind): BehaviourContract;
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/icons/schema.d.ts
|
|
654
|
+
/** An icon's name in its set, `prefix:name`, as Iconify names icons. */
|
|
655
|
+
declare const ICON_NAME: RegExp;
|
|
656
|
+
declare const iconSchema: v.ObjectSchema<{
|
|
657
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
|
|
658
|
+
/** A fingerprint of the glyph as placed, to tell when its paths were edited; see `iconGlyph`. */
|
|
659
|
+
readonly glyph: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
660
|
+
}, undefined>;
|
|
661
|
+
/** An icon a frame draws. */
|
|
662
|
+
type Icon = v.InferOutput<typeof iconSchema>;
|
|
663
|
+
declare const ICON_PAINTS: readonly ["fill", "stroke"];
|
|
664
|
+
type IconPaint = (typeof ICON_PAINTS)[number];
|
|
665
|
+
declare const iconTintSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["fill", "stroke"], undefined>, undefined>, v.MinLengthAction<("fill" | "stroke")[], 1, undefined>]>;
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region src/icons/model.d.ts
|
|
668
|
+
/** The icon a frame draws, or null when it is not an icon or its data is unreadable. */
|
|
669
|
+
declare function readIcon(node: SceneNode): Icon | null;
|
|
670
|
+
/** The node's plugin data with the icon set, or removed when null. */
|
|
671
|
+
declare function withIcon(node: SceneNode, icon: Icon | null): SceneNode['pluginData'];
|
|
672
|
+
/** The layer name an icon is placed with: its name in the set, such as `cat` for `mdi:cat`. */
|
|
673
|
+
declare function iconLayerName(name: string): string;
|
|
674
|
+
/**
|
|
675
|
+
* Whether `layerName` is the name an icon `name` was placed with, rather than one someone gave
|
|
676
|
+
* it: `cat`, or `Icon / mdi:cat` as icons were named before.
|
|
677
|
+
*/
|
|
678
|
+
declare function isPlacedIconName(layerName: string, name: string): boolean;
|
|
679
|
+
/** The names of the icons among `nodes`, each once, in the order they are first met. */
|
|
680
|
+
declare function iconNames(nodes: Iterable<SceneNode>): string[];
|
|
681
|
+
/** The paints of an icon path that its icon's color sets; none when it keeps its own colors. */
|
|
682
|
+
declare function readIconTint(node: SceneNode): readonly IconPaint[];
|
|
683
|
+
/** The path's plugin data with its tinted paints, or removed when there are none. */
|
|
684
|
+
declare function withIconTint(node: SceneNode, paints: readonly IconPaint[]): SceneNode['pluginData'];
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region src/icons/glyph.d.ts
|
|
687
|
+
/** What reading an icon's paths needs of a graph. */
|
|
688
|
+
interface IconGraph {
|
|
689
|
+
getChildren(id: string): SceneNode[];
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* A fingerprint of what an icon frame draws: which paths it holds and their shapes, stroke ends,
|
|
693
|
+
* and paints. Resizing the icon, however unevenly, or changing its color leaves it unchanged;
|
|
694
|
+
* editing points, rotating or fading a path, adding or removing one, or changing a color of the
|
|
695
|
+
* icon's own changes it. Moving a whole path or changing its stroke weight does not count, since
|
|
696
|
+
* resizing changes those by rounded amounts too.
|
|
697
|
+
*/
|
|
698
|
+
declare function iconGlyph(graph: IconGraph, frame: SceneNode): string;
|
|
699
|
+
/**
|
|
700
|
+
* Whether an icon frame no longer draws the glyph it was placed with: its paths were edited,
|
|
701
|
+
* added, or removed. An icon placed before glyphs were recorded counts as unedited.
|
|
702
|
+
*/
|
|
703
|
+
declare function isIconModified(graph: IconGraph, frame: SceneNode): boolean;
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/shaders/schema.d.ts
|
|
706
|
+
/** One effect of a shader preset, as the `shaders` library names it, with the effects it holds. */
|
|
707
|
+
interface ShaderComponent {
|
|
708
|
+
type: string;
|
|
709
|
+
id?: string;
|
|
710
|
+
props?: Record<string, unknown>;
|
|
711
|
+
children?: ShaderComponent[];
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* A shader as the `shaders` library describes it and shaders.com exports it: a tree of effects,
|
|
715
|
+
* drawn first to last.
|
|
716
|
+
*/
|
|
717
|
+
declare const shaderPresetSchema: v.ObjectSchema<{
|
|
718
|
+
readonly components: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<unknown, ShaderComponent>, undefined>, v.MinLengthAction<ShaderComponent[], 1, undefined>]>;
|
|
719
|
+
readonly structureVersion: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
720
|
+
}, undefined>;
|
|
721
|
+
type ShaderPreset = v.InferOutput<typeof shaderPresetSchema>;
|
|
722
|
+
/**
|
|
723
|
+
* A paint that draws a shader. The paint itself is an image fill of the shader's still frame, so
|
|
724
|
+
* every format and renderer that reads images shows it; this entry says which image it is, the
|
|
725
|
+
* preset that draws it, and the layer size and preset the frame was rendered for, which is
|
|
726
|
+
* missing until it is first rendered.
|
|
727
|
+
*/
|
|
728
|
+
declare const shaderPaintSchema: v.ObjectSchema<{
|
|
729
|
+
readonly image: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>;
|
|
730
|
+
readonly preset: v.ObjectSchema<{
|
|
731
|
+
readonly components: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<unknown, ShaderComponent>, undefined>, v.MinLengthAction<ShaderComponent[], 1, undefined>]>;
|
|
732
|
+
readonly structureVersion: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
733
|
+
}, undefined>;
|
|
734
|
+
readonly frame: v.OptionalSchema<v.ObjectSchema<{
|
|
735
|
+
readonly width: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
736
|
+
readonly height: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
737
|
+
/** The preset's key (`shaderPresetKey`) when the frame was rendered. */
|
|
738
|
+
readonly preset: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>;
|
|
739
|
+
}, undefined>, undefined>;
|
|
740
|
+
}, undefined>;
|
|
741
|
+
type ShaderPaint = v.InferOutput<typeof shaderPaintSchema>;
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region src/shaders/model.d.ts
|
|
744
|
+
/** What shader paints read of a node. */
|
|
745
|
+
type ShaderNode = Pick<SceneNode, 'fills' | 'strokes' | 'pluginData'>;
|
|
746
|
+
/** Every shader a node's fills and strokes draw, whether or not a paint still shows it. */
|
|
747
|
+
declare function readShaderPaints(node: Pick<SceneNode, 'pluginData'>): ShaderPaint[];
|
|
748
|
+
/**
|
|
749
|
+
* The shader a fill or stroke of `node` draws: an image paint whose image is a shader's frame.
|
|
750
|
+
* Null for any other paint, including one whose image was replaced, which then draws as the
|
|
751
|
+
* image it holds.
|
|
752
|
+
*/
|
|
753
|
+
declare function shaderOfPaint(node: Pick<SceneNode, 'pluginData'>, paint: Fill): ShaderPaint | null;
|
|
754
|
+
/** Whether any paint of `node` draws a shader. */
|
|
755
|
+
declare function hasShaderPaint(node: ShaderNode): boolean;
|
|
756
|
+
/**
|
|
757
|
+
* The node's plugin data with `shaders` set by their image, keeping only shaders a fill or
|
|
758
|
+
* stroke of `paints` still shows, so removing or replacing a paint leaves no entry behind.
|
|
759
|
+
*/
|
|
760
|
+
declare function withShaderPaints(node: Pick<SceneNode, 'pluginData'>, paints: readonly Fill[], shaders?: readonly ShaderPaint[]): SceneNode['pluginData'];
|
|
761
|
+
/**
|
|
762
|
+
* A new paint that draws `preset`, and the shader entry it shows. Its image names a frame not yet
|
|
763
|
+
* rendered, unique to this paint, so no other paint's entry claims it until the frame is drawn.
|
|
764
|
+
*/
|
|
765
|
+
declare function createShaderPaint(preset: ShaderPreset): {
|
|
766
|
+
paint: Fill;
|
|
767
|
+
shader: ShaderPaint;
|
|
768
|
+
};
|
|
769
|
+
/** A short key that tells one preset from another, which a rendered frame records. */
|
|
770
|
+
declare function shaderPresetKey(preset: ShaderPreset): string;
|
|
771
|
+
/**
|
|
772
|
+
* Whether a shader's frame was rendered for its preset at the size `node` has now, so undoing a
|
|
773
|
+
* preset change after reopening the document does not keep a frame of the newer preset.
|
|
774
|
+
*/
|
|
775
|
+
declare function isShaderFrameCurrent(shader: ShaderPaint, size: {
|
|
776
|
+
width: number;
|
|
777
|
+
height: number;
|
|
778
|
+
}): boolean;
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region src/behaviours/layers.d.ts
|
|
781
|
+
/** Whether an instance's main component, or its set, has a behaviour. */
|
|
782
|
+
declare function hasBehaviour(graph: SceneGraph, node: SceneNode): boolean;
|
|
783
|
+
/**
|
|
784
|
+
* A layer's path below a root: the names of the layers down to it, with the position among
|
|
785
|
+
* same-named siblings when names repeat. It stays the same when a variant switch rebuilds an
|
|
786
|
+
* instance's layers, so it identifies controls and keeps their DOM in place.
|
|
787
|
+
*/
|
|
788
|
+
declare function layerPath(graph: SceneGraph, rootId: string, nodeId: string): string;
|
|
789
|
+
/** The layer at `path` below a root, the inverse of `layerPath`. */
|
|
790
|
+
declare function findLayerByPath(graph: SceneGraph, rootId: string, path: string): SceneNode | undefined;
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/behaviours/schema.d.ts
|
|
793
|
+
declare const BooleanBinding: v.ObjectSchema<{
|
|
794
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
795
|
+
/** For a variant property: the values that mean on and off. */
|
|
796
|
+
readonly on: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
797
|
+
readonly off: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
798
|
+
}, undefined>;
|
|
799
|
+
/** Whether a number value's range can be stepped through: `max` above `min`, a positive step. */
|
|
800
|
+
declare function isNumberRange(settings: {
|
|
801
|
+
min: number;
|
|
802
|
+
max: number;
|
|
803
|
+
step: number;
|
|
804
|
+
}): boolean;
|
|
805
|
+
declare const NumberSettings: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
806
|
+
readonly min: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
807
|
+
readonly max: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
808
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
809
|
+
readonly default: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
810
|
+
}, undefined>, v.CheckAction<{
|
|
811
|
+
min: number;
|
|
812
|
+
max: number;
|
|
813
|
+
step: number;
|
|
814
|
+
default: number;
|
|
815
|
+
}, "A number value needs max above min and a positive step">]>;
|
|
816
|
+
declare const InteractionStates: v.ObjectSchema<{
|
|
817
|
+
readonly rest: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
818
|
+
readonly hover: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
819
|
+
readonly pressed: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
820
|
+
readonly focus: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
821
|
+
readonly disabled: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
822
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
823
|
+
}, undefined>;
|
|
824
|
+
declare const behaviourSchema: v.ObjectSchema<{
|
|
825
|
+
readonly kind: v.PicklistSchema<readonly ["button", "textField", "textarea", "numberField", "toggle", "switch", "checkbox", "radio", "radioGroup", "toggleGroup", "slider", "progress", "tabs", "collapsible", "accordion"], undefined>;
|
|
826
|
+
/** Boolean values, by value id, bound to component properties. */
|
|
827
|
+
readonly booleans: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
828
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
829
|
+
/** For a variant property: the values that mean on and off. */
|
|
830
|
+
readonly on: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
831
|
+
readonly off: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
832
|
+
}, undefined>, undefined>;
|
|
833
|
+
/** Text values, by value id, bound to text properties. */
|
|
834
|
+
readonly texts: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
835
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
836
|
+
}, undefined>, undefined>, {}>;
|
|
837
|
+
/** Number values, by value id: the range the behaviour keeps itself. */
|
|
838
|
+
readonly numbers: v.RecordSchema<v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
839
|
+
readonly min: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
840
|
+
readonly max: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
841
|
+
readonly step: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
842
|
+
readonly default: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
843
|
+
}, undefined>, v.CheckAction<{
|
|
844
|
+
min: number;
|
|
845
|
+
max: number;
|
|
846
|
+
step: number;
|
|
847
|
+
default: number;
|
|
848
|
+
}, "A number value needs max above min and a positive step">]>, undefined>;
|
|
849
|
+
/** Parts, by part id, bound to slot properties. */
|
|
850
|
+
readonly parts: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
851
|
+
readonly states: v.OptionalSchema<v.ObjectSchema<{
|
|
852
|
+
readonly rest: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
853
|
+
readonly hover: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
854
|
+
readonly pressed: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
855
|
+
readonly focus: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
856
|
+
readonly disabled: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
857
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
858
|
+
}, undefined>, undefined>;
|
|
859
|
+
}, undefined>;
|
|
860
|
+
/** How a main component behaves as a control, as kept in its plugin data. */
|
|
861
|
+
type Behaviour = v.InferOutput<typeof behaviourSchema>;
|
|
862
|
+
type BehaviourBooleanBinding = v.InferOutput<typeof BooleanBinding>;
|
|
863
|
+
type BehaviourNumberSettings = v.InferOutput<typeof NumberSettings>;
|
|
864
|
+
type BehaviourInteractionStates = v.InferOutput<typeof InteractionStates>;
|
|
865
|
+
//#endregion
|
|
866
|
+
//#region src/behaviours/model.d.ts
|
|
867
|
+
declare const DEFAULT_NUMBER_SETTINGS: BehaviourNumberSettings;
|
|
868
|
+
/** A boolean value's binding, if the behaviour has one. */
|
|
869
|
+
declare function booleanBinding(behaviour: Behaviour, valueId: string): BehaviourBooleanBinding | undefined;
|
|
870
|
+
/** The slot property a part is bound to, if any. */
|
|
871
|
+
declare function partBinding(behaviour: Behaviour, partId: string): string | undefined;
|
|
872
|
+
/** The text property a text value is bound to, if any. */
|
|
873
|
+
declare function textBinding(behaviour: Behaviour, valueId: string): string | undefined;
|
|
874
|
+
/** A number value's range, if the behaviour has one. */
|
|
875
|
+
declare function numberSettings(behaviour: Behaviour, valueId: string): BehaviourNumberSettings | undefined;
|
|
876
|
+
/** A new behaviour of a kind, its number values at their defaults and nothing bound. */
|
|
877
|
+
declare function emptyBehaviour(kind: BehaviourKind): Behaviour;
|
|
878
|
+
/**
|
|
879
|
+
* The node that keeps the behaviour: a component set for its variants, otherwise the main
|
|
880
|
+
* component itself.
|
|
881
|
+
*/
|
|
882
|
+
declare function behaviourOwner(graph: SceneGraph, node: SceneNode): SceneNode | undefined;
|
|
883
|
+
/** The behaviour a component or component set keeps, or null when it has none or it is unreadable. */
|
|
884
|
+
declare function readBehaviour(owner: SceneNode): Behaviour | null;
|
|
885
|
+
/** The owner's plugin data with the behaviour set, or removed when null. */
|
|
886
|
+
declare function withBehaviour(owner: SceneNode, behaviour: Behaviour | null): SceneNode['pluginData'];
|
|
887
|
+
/** Component properties the behaviour can bind to: the owner's, and a set's variants' own. */
|
|
888
|
+
declare function behaviourProperties(graph: SceneGraph, owner: SceneNode): ComponentPropertyDefinition[];
|
|
889
|
+
/**
|
|
890
|
+
* Required values and parts that are unbound, or bound to a property the component no longer
|
|
891
|
+
* has, by value or part id; `states` when the interaction states lost their variant property.
|
|
892
|
+
*/
|
|
893
|
+
declare function missingBindings(graph: SceneGraph, owner: SceneNode, behaviour: Behaviour): string[];
|
|
894
|
+
/**
|
|
895
|
+
* Interaction states for a variant property, each mapped to the value whose name means it, such
|
|
896
|
+
* as `Hover` or `Pressed`; states without such a value are left unset.
|
|
897
|
+
*/
|
|
898
|
+
declare function guessInteractionStates(propertyId: string, values: readonly string[]): BehaviourInteractionStates;
|
|
899
|
+
/**
|
|
900
|
+
* The behaviour with every component property id it binds renamed by `rename`, for formats that
|
|
901
|
+
* give properties new ids on write, such as `.fig` with its GUIDs.
|
|
902
|
+
*/
|
|
903
|
+
declare function renameBehaviourProperties(behaviour: Behaviour, rename: (propertyId: string) => string): Behaviour;
|
|
904
|
+
//#endregion
|
|
905
|
+
//#region src/behaviours/spec.d.ts
|
|
906
|
+
/**
|
|
907
|
+
* A behaviour as scripts, tools, and JSX write it: component properties and slots by name, not
|
|
908
|
+
* by id. Values are boolean or text values by their contract id; numbers are a slider's or
|
|
909
|
+
* number field's own range.
|
|
910
|
+
*/
|
|
911
|
+
declare const behaviourSpecSchema: v.ObjectSchema<{
|
|
912
|
+
readonly kind: v.PicklistSchema<readonly ["button", "textField", "textarea", "numberField", "toggle", "switch", "checkbox", "radio", "radioGroup", "toggleGroup", "slider", "progress", "tabs", "collapsible", "accordion"], undefined>;
|
|
913
|
+
readonly values: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.StringSchema<undefined>, v.ObjectSchema<{
|
|
914
|
+
readonly property: v.StringSchema<undefined>;
|
|
915
|
+
readonly on: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
916
|
+
readonly off: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
917
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
918
|
+
readonly numbers: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
919
|
+
readonly min: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
920
|
+
readonly max: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
921
|
+
readonly step: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
922
|
+
readonly default: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
923
|
+
}, undefined>, undefined>, undefined>;
|
|
924
|
+
readonly parts: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>, undefined>;
|
|
925
|
+
readonly states: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ObjectSchema<{
|
|
926
|
+
readonly rest: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
927
|
+
readonly hover: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
928
|
+
readonly pressed: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
929
|
+
readonly focus: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
930
|
+
readonly disabled: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
931
|
+
readonly property: v.StringSchema<undefined>;
|
|
932
|
+
}, undefined>], undefined>, undefined>;
|
|
933
|
+
}, undefined>;
|
|
934
|
+
type BehaviourSpec = v.InferOutput<typeof behaviourSpecSchema>;
|
|
935
|
+
/**
|
|
936
|
+
* The variant values that likely mean on and off: names such as On, True, or Checked first,
|
|
937
|
+
* then the values in order.
|
|
938
|
+
*/
|
|
939
|
+
declare function guessOnOff(options: readonly string[], explicit?: {
|
|
940
|
+
on?: string;
|
|
941
|
+
off?: string;
|
|
942
|
+
}): {
|
|
943
|
+
on?: string;
|
|
944
|
+
off?: string;
|
|
945
|
+
};
|
|
946
|
+
/**
|
|
947
|
+
* The stored behaviour for a spec, with names resolved to the owner's property and slot ids. A
|
|
948
|
+
* name the component lacks, a value the kind does not have, or a variant value the property
|
|
949
|
+
* does not offer fails with a message naming what exists.
|
|
950
|
+
*/
|
|
951
|
+
declare function behaviourFromSpec(graph: SceneGraph, owner: SceneNode, spec: BehaviourSpec): Behaviour;
|
|
952
|
+
/** The spec a stored behaviour reads as, with ids back to names; unresolved bindings are left out. */
|
|
953
|
+
declare function behaviourToSpec(graph: SceneGraph, owner: SceneNode, behaviour: Behaviour): BehaviourSpec;
|
|
954
|
+
//#endregion
|
|
955
|
+
//#region src/comments/document.d.ts
|
|
956
|
+
/**
|
|
957
|
+
* A document's comment threads, deleted ones included. Comments are part of the document: they
|
|
958
|
+
* live in OpenPencil's plugin data on the document node, so they travel with the `.fig` file,
|
|
959
|
+
* its storage copy and a collaboration room, and Figma or an older OpenPencil open the file as
|
|
960
|
+
* before.
|
|
961
|
+
*/
|
|
962
|
+
declare function readComments(graph: SceneGraph): CommentThread[];
|
|
963
|
+
/**
|
|
964
|
+
* Stores the threads on the document node. This is a document change, so the document asks to
|
|
965
|
+
* be saved, but not an undo step: undoing a layer edit never takes back a comment.
|
|
966
|
+
*/
|
|
967
|
+
declare function writeComments(graph: SceneGraph, threads: readonly CommentThread[]): void;
|
|
968
|
+
/**
|
|
969
|
+
* `entries` holding the comments of `live` instead of their own. Undo and redo restore the
|
|
970
|
+
* document node with this, so they leave comments as they are now.
|
|
971
|
+
*/
|
|
972
|
+
declare function withLiveComments(entries: readonly PluginDataEntry[], live: readonly PluginDataEntry[]): PluginDataEntry[];
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region src/comments/list.d.ts
|
|
975
|
+
declare const COMMENT_SORTS: readonly ["newest", "oldest"];
|
|
976
|
+
type CommentSort = (typeof COMMENT_SORTS)[number];
|
|
977
|
+
interface CommentListOptions {
|
|
978
|
+
query: string;
|
|
979
|
+
showResolved: boolean;
|
|
980
|
+
/** Only threads on `pageId`. */
|
|
981
|
+
onlyPage: boolean;
|
|
982
|
+
pageId: string;
|
|
983
|
+
/** Only threads `author` started or replied to. */
|
|
984
|
+
onlyMine: boolean;
|
|
985
|
+
author: string;
|
|
986
|
+
sort: CommentSort;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Each thread's number, counted in the order threads were started, as Figma numbers them in its
|
|
990
|
+
* list. Deleted threads keep their place so the numbers people refer to do not shift.
|
|
991
|
+
*/
|
|
992
|
+
declare function commentThreadNumbers(threads: readonly CommentThread[]): Map<string, number>;
|
|
993
|
+
/** The threads the comments list shows for its search, filters and order. */
|
|
994
|
+
declare function listCommentThreads(threads: readonly CommentThread[], options: CommentListOptions): CommentThread[];
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region src/comments/merge.d.ts
|
|
997
|
+
/**
|
|
998
|
+
* Two copies of a document's comments become one. Nothing is lost: threads and replies are
|
|
999
|
+
* joined by id, and for a thread both copies changed, the newer edit wins while replies from
|
|
1000
|
+
* both are kept. Deleted threads and replies stay deleted.
|
|
1001
|
+
*/
|
|
1002
|
+
declare function mergeCommentThreads(local: readonly CommentThread[], remote: readonly CommentThread[]): CommentThread[];
|
|
1003
|
+
/**
|
|
1004
|
+
* Whether `local` holds anything `remote` lacks: a thread or reply it does not have, a newer edit,
|
|
1005
|
+
* or a deletion. Merging is then needed; otherwise `remote` already says everything.
|
|
1006
|
+
*/
|
|
1007
|
+
declare function hasNewerComments(local: readonly CommentThread[], remote: readonly CommentThread[]): boolean;
|
|
1008
|
+
//#endregion
|
|
1009
|
+
//#region src/comments/threads.d.ts
|
|
1010
|
+
/** Who writes a comment: their name and, in a collaboration room, their color. */
|
|
1011
|
+
interface CommentAuthor {
|
|
1012
|
+
name: string;
|
|
1013
|
+
color?: Color;
|
|
1014
|
+
}
|
|
1015
|
+
/** When a comment is written or changed, as stored: an ISO timestamp. */
|
|
1016
|
+
declare function commentTimestamp(): string;
|
|
1017
|
+
/** Oldest first, the order threads and replies are shown and numbered in. */
|
|
1018
|
+
declare function byCreatedAt(a: {
|
|
1019
|
+
createdAt: string;
|
|
1020
|
+
}, b: {
|
|
1021
|
+
createdAt: string;
|
|
1022
|
+
}): number;
|
|
1023
|
+
/** A thread's replies, without the deleted ones kept as tombstones. */
|
|
1024
|
+
declare function liveReplies(thread: CommentThread): CommentReply[];
|
|
1025
|
+
/** Whether `author` started the thread or replied to it, as Figma's "Only your threads" counts. */
|
|
1026
|
+
declare function takesPartInThread(thread: CommentThread, author: string): boolean;
|
|
1027
|
+
/** The thread with `id`, unless it is missing or deleted. */
|
|
1028
|
+
declare function findLiveCommentThread(threads: readonly CommentThread[], id: string): CommentThread | undefined;
|
|
1029
|
+
/**
|
|
1030
|
+
* Where a pin at a canvas point is kept: on the top-level layer under it, or on `node`'s when
|
|
1031
|
+
* given, so it follows that layer; on the canvas when nothing is there.
|
|
1032
|
+
*/
|
|
1033
|
+
declare function commentAnchor(graph: SceneGraph, pageId: string, at: Vector, node?: SceneNode): {
|
|
1034
|
+
nodeId: string | null;
|
|
1035
|
+
nodeName: string | null;
|
|
1036
|
+
offsetX: number;
|
|
1037
|
+
offsetY: number;
|
|
1038
|
+
x: number;
|
|
1039
|
+
y: number;
|
|
1040
|
+
};
|
|
1041
|
+
/** Where a thread's pin is now: on its layer while that layer exists, else where it was left. */
|
|
1042
|
+
declare function commentPosition(graph: SceneGraph, thread: CommentThread): Vector;
|
|
1043
|
+
/** A new thread pinned at a canvas point of a page. */
|
|
1044
|
+
declare function createCommentThread(graph: SceneGraph, options: {
|
|
1045
|
+
pageId: string;
|
|
1046
|
+
at: Vector;
|
|
1047
|
+
/** Pin it on this layer's top-level layer rather than on whatever is at `at`. */
|
|
1048
|
+
node?: SceneNode;
|
|
1049
|
+
author: CommentAuthor;
|
|
1050
|
+
text: string;
|
|
1051
|
+
now: string;
|
|
1052
|
+
}): CommentThread;
|
|
1053
|
+
declare function createCommentReply(author: CommentAuthor, text: string, now: string): CommentReply;
|
|
1054
|
+
/** The threads with one changed and marked as edited at `now`, for merging with other copies. */
|
|
1055
|
+
declare function editCommentThread(threads: readonly CommentThread[], id: string, now: string, edit: (thread: CommentThread) => CommentThread): CommentThread[];
|
|
1056
|
+
/** A reply ends up in the thread and reopens it, as answering a resolved comment does. */
|
|
1057
|
+
declare function replyToCommentThread(thread: CommentThread, reply: CommentReply): CommentThread;
|
|
1058
|
+
declare function resolveCommentThread(thread: CommentThread, resolved: boolean, now: string): CommentThread;
|
|
1059
|
+
/** Deleted threads and replies stay as tombstones, so a stale copy cannot bring them back. */
|
|
1060
|
+
declare function deleteCommentThread(thread: CommentThread): CommentThread;
|
|
1061
|
+
declare function deleteCommentReply(thread: CommentThread, replyId: string): CommentThread;
|
|
1062
|
+
//#endregion
|
|
1063
|
+
//#region src/copy.d.ts
|
|
1064
|
+
/** Generic over the paint shape so a stroke keeps its own fields while the paint deep-copies. */
|
|
1065
|
+
declare function copyFill<T extends Fill>(f: T): T;
|
|
1066
|
+
declare function copyStroke(s: Stroke): Stroke;
|
|
1067
|
+
declare function copyEffect(e: Effect): Effect;
|
|
1068
|
+
declare function copyStyleRun(r: StyleRun): StyleRun;
|
|
1069
|
+
/** Record immutable lineage for an internal deep copy without sharing mutable values. */
|
|
1070
|
+
declare function markCopySource<T extends object>(source: T, copy: T): T;
|
|
1071
|
+
/** Compare internal deep copies in O(1) without traversing large paint or text payloads. */
|
|
1072
|
+
declare function hasSameCopySource(left: object, right: object): boolean;
|
|
1073
|
+
declare function copyFills(fills: Fill[]): Fill[];
|
|
1074
|
+
declare function copyStrokes(strokes: Stroke[]): Stroke[];
|
|
1075
|
+
declare function copyEffects(effects: Effect[]): Effect[];
|
|
1076
|
+
declare function copyLayoutGrids(grids: LayoutGrid[]): LayoutGrid[];
|
|
1077
|
+
declare function copyStyleRuns(runs: StyleRun[]): StyleRun[];
|
|
1078
|
+
declare function copyGeometryPaths(paths: GeometryPath[]): GeometryPath[];
|
|
1079
|
+
/**
|
|
1080
|
+
* Affine-transform every coordinate pair in a path command blob (returns a
|
|
1081
|
+
* copy): (x, y) → (m00·x + m01·y + tx, m10·x + m11·y + ty).
|
|
1082
|
+
* Command layout: 1=move/2=line (1 pair), 3=quad (2 pairs), 4=cubic (3 pairs)
|
|
1083
|
+
* — font-glyph blobs are quad-heavy, so skipping command 3 desyncs the walk.
|
|
1084
|
+
*/
|
|
1085
|
+
declare function transformGeometryBlob(blob: Uint8Array, m00: number, m01: number, m10: number, m11: number, tx?: number, ty?: number): Uint8Array;
|
|
1086
|
+
declare function transformGeometryPaths(paths: GeometryPath[], m00: number, m01: number, m10: number, m11: number, tx?: number, ty?: number): GeometryPath[];
|
|
1087
|
+
/**
|
|
1088
|
+
* Scale path command blob coordinates by (sx, sy).
|
|
1089
|
+
* Identity scale returns a deep copy (same as copyGeometryPaths).
|
|
1090
|
+
*/
|
|
1091
|
+
declare function scaleGeometryPaths(paths: GeometryPath[], sx: number, sy: number): GeometryPath[];
|
|
1092
|
+
/** Deep-copy path-text glyphs (fresh commandsBlob buffers). */
|
|
1093
|
+
declare function copyDerivedGlyphs(glyphs: DerivedTextGlyph[] | null): DerivedTextGlyph[] | null;
|
|
1094
|
+
/**
|
|
1095
|
+
* Build the init props for a deep-copy clone of `src`.
|
|
1096
|
+
* Shares logic between SceneGraph.cloneTree and instance child cloning.
|
|
1097
|
+
* Explicitly deep-copies all mutable object/array fields that `...rest`
|
|
1098
|
+
* would otherwise share by reference. When adding a mutable SceneNode field,
|
|
1099
|
+
* add its copy behavior here or document why sharing is intentional.
|
|
1100
|
+
*/
|
|
1101
|
+
type NodeCloneMode = 'deep' | 'fig-import';
|
|
1102
|
+
declare function cloneNodeProps(src: SceneNode, componentId: string | null, mode?: NodeCloneMode): Partial<SceneNode>;
|
|
1103
|
+
//#endregion
|
|
1104
|
+
//#region src/node-defaults.d.ts
|
|
1105
|
+
declare function createDefaultSourceMetadata(): SourceMetadata;
|
|
1106
|
+
/** Where Figma aligns a new node's strokes: centered on lines and vectors, outside text, else inside. */
|
|
1107
|
+
declare function defaultStrokeAlign(type: NodeType): SceneNode['strokeAlign'];
|
|
1108
|
+
/**
|
|
1109
|
+
* Weight and alignment a stroke added to `node` takes: its first stroke's, or what the node keeps
|
|
1110
|
+
* with none. Adding a stroke from the panel and from the plugin API both go through here.
|
|
1111
|
+
*/
|
|
1112
|
+
declare function newStrokeGeometry(node: Pick<SceneNode, 'strokes' | 'strokeWeight' | 'strokeAlign'>): Pick<SceneNode['strokes'][number], 'weight' | 'align'>;
|
|
1113
|
+
declare function createDefaultNode(generateId: () => string, type: NodeType, overrides?: Partial<SceneNode>): SceneNode;
|
|
1114
|
+
/** Containers whose bounds follow their children and that set no coordinate space, as in Figma. */
|
|
1115
|
+
declare const FITTED_CONTAINER_TYPES: ReadonlySet<NodeType>;
|
|
1116
|
+
declare const CONTAINER_TYPES: Set<NodeType>;
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region src/instances/fields.d.ts
|
|
1119
|
+
declare const INSTANCE_SYNC_TEXT_PROPS: readonly ["name", "text", "fontSize", "fontWeight", "fontFamily", "italic", "textDirection", "letterSpacing", "lineHeight", "textCase", "textDecoration", "textDecorationStyle", "textDecorationThickness", "textUnderlineOffset", "textDecorationFills", "textDecorationSkipInk", "textAlignHorizontal", "textAlignVertical", "textAutoResize", "textTruncation", "maxLines", "leadingTrim", "paragraphSpacing", "paragraphIndent", "listSpacing", "hangingList", "fontVariations", "fontFeatures", "styleRuns", "textParagraphs"];
|
|
1120
|
+
declare const INSTANCE_SYNC_PROPS: (keyof SceneNode)[];
|
|
1121
|
+
/**
|
|
1122
|
+
* Where a component's layer sits and how it is shaped, which Figma refuses to override in an
|
|
1123
|
+
* instance ("This property cannot be overridden in an instance"), so its copies always follow.
|
|
1124
|
+
* A layer in an auto layout flow takes its position from the layout instead.
|
|
1125
|
+
*/
|
|
1126
|
+
declare const INSTANCE_FOLLOWED_FIELDS: readonly ["x", "y", "rotation", "flipX", "flipY", "horizontalConstraint", "verticalConstraint", "layoutPositioning", "isMask", "maskType", "arcData", "pointCount", "starInnerRadius"];
|
|
1127
|
+
/** Fields an edit to a layer inside an instance records as that instance's override. */
|
|
1128
|
+
declare const INSTANCE_OVERRIDE_FIELDS: readonly [...(keyof SceneNode)[], "name", "text", "fontSize", "fontWeight", "fontFamily", "italic", "textDirection", "letterSpacing", "lineHeight", "textCase", "textDecoration", "textDecorationStyle", "textDecorationThickness", "textUnderlineOffset", "textDecorationFills", "textDecorationSkipInk", "textAlignHorizontal", "textAlignVertical", "textAutoResize", "textTruncation", "maxLines", "leadingTrim", "paragraphSpacing", "paragraphIndent", "listSpacing", "hangingList", "fontVariations", "fontFeatures", "styleRuns", "textParagraphs", "layoutGrow", "layoutAlignSelf", "locked", "visible"];
|
|
1129
|
+
/** Fields a component's layer gives the copies of it in every instance. */
|
|
1130
|
+
declare const INSTANCE_SYNC_FIELDS: readonly [...(keyof SceneNode)[], "name", "text", "fontSize", "fontWeight", "fontFamily", "italic", "textDirection", "letterSpacing", "lineHeight", "textCase", "textDecoration", "textDecorationStyle", "textDecorationThickness", "textUnderlineOffset", "textDecorationFills", "textDecorationSkipInk", "textAlignHorizontal", "textAlignVertical", "textAutoResize", "textTruncation", "maxLines", "leadingTrim", "paragraphSpacing", "paragraphIndent", "listSpacing", "hangingList", "fontVariations", "fontFeatures", "styleRuns", "textParagraphs", "layoutGrow", "layoutAlignSelf", "locked", "visible", "x", "y", "rotation", "flipX", "flipY", "horizontalConstraint", "verticalConstraint", "layoutPositioning", "isMask", "maskType", "arcData", "pointCount", "starInnerRadius"];
|
|
1131
|
+
//#endregion
|
|
1132
|
+
//#region src/instances.d.ts
|
|
1133
|
+
declare function copyInstanceComponentProps(component: SceneNode): Partial<SceneNode>;
|
|
1134
|
+
declare function createInstance(graph: SceneGraph, componentId: string, parentId: string, overrides?: Partial<SceneNode>): SceneNode | null;
|
|
1135
|
+
declare function populateInstanceChildren(graph: SceneGraph, instanceId: string, componentId: string, mode?: NodeCloneMode): void;
|
|
1136
|
+
interface SwapInstanceOptions {
|
|
1137
|
+
/**
|
|
1138
|
+
* Keep the instance's name even when it is its old component's. A swap otherwise renames such
|
|
1139
|
+
* an instance after the new component, as Figma does; a view that only shows another variant,
|
|
1140
|
+
* such as preview, keeps names so layer paths stay the same.
|
|
1141
|
+
*/
|
|
1142
|
+
keepName?: boolean;
|
|
1143
|
+
}
|
|
1144
|
+
declare function swapInstanceComponent(graph: SceneGraph, instanceId: string, componentId: string, { keepName }?: SwapInstanceOptions): void;
|
|
1145
|
+
declare function syncInstances(graph: SceneGraph, componentId: string): void;
|
|
1146
|
+
/**
|
|
1147
|
+
* Syncs each component's instances, in order, as one edit: the copies they remove stay
|
|
1148
|
+
* restorable together for as long as undo keeps that edit.
|
|
1149
|
+
*/
|
|
1150
|
+
declare function syncInstancesTogether(graph: SceneGraph, componentIds: Iterable<string>): void;
|
|
1151
|
+
/** Syncs one instance from its component, as `syncInstances` does for every instance. */
|
|
1152
|
+
declare function syncInstance(graph: SceneGraph, instanceId: string): void;
|
|
1153
|
+
declare function detachInstance(graph: SceneGraph, instanceId: string): void;
|
|
1154
|
+
declare function getMainComponent(graph: SceneGraph, instanceId: string): SceneNode | undefined;
|
|
1155
|
+
declare function getInstances(graph: SceneGraph, componentId: string): SceneNode[];
|
|
1156
|
+
/** Nearest INSTANCE at or above `nodeId` — self, parent, grandparent, etc. */
|
|
1157
|
+
declare function findInstanceAncestor(graph: SceneGraph, nodeId: string): SceneNode | undefined;
|
|
1158
|
+
/**
|
|
1159
|
+
* True when a node field is protected from instance synchronization.
|
|
1160
|
+
*/
|
|
1161
|
+
declare function hasInstanceOverride(graph: SceneGraph, nodeId: string, field: string): boolean;
|
|
1162
|
+
declare function recordInstanceOverride(graph: SceneGraph, nodeId: string, fields: Iterable<string>): void;
|
|
1163
|
+
//#endregion
|
|
1164
|
+
//#region src/snap.d.ts
|
|
1165
|
+
interface SnapGuide {
|
|
1166
|
+
axis: 'x' | 'y';
|
|
1167
|
+
position: number;
|
|
1168
|
+
from: number;
|
|
1169
|
+
to: number;
|
|
1170
|
+
}
|
|
1171
|
+
interface SnapResult {
|
|
1172
|
+
dx: number;
|
|
1173
|
+
dy: number;
|
|
1174
|
+
guides: SnapGuide[];
|
|
1175
|
+
}
|
|
1176
|
+
declare function computeSnap(movingIds: Set<string>, movingBounds: Rect, allNodes: SceneNode[], threshold?: number): SnapResult;
|
|
1177
|
+
declare function computeSelectionBounds(nodes: SceneNode[]): Rect | null;
|
|
1178
|
+
//#endregion
|
|
1179
|
+
//#region src/export-scale.d.ts
|
|
1180
|
+
/**
|
|
1181
|
+
* Bounds for export scale multipliers. A huge multiplier would allocate an
|
|
1182
|
+
* enormous canvas and crash the renderer, so clamp at every boundary the value
|
|
1183
|
+
* can enter from: the UI (edits) and the file format (imported/plugin .fig data).
|
|
1184
|
+
*/
|
|
1185
|
+
declare const MIN_EXPORT_SCALE = 0.01;
|
|
1186
|
+
declare const MAX_EXPORT_SCALE = 1024;
|
|
1187
|
+
declare function clampExportScale(scale: number): number;
|
|
1188
|
+
/** Accept a scale only if it is finite and within bounds (no silent clamping). */
|
|
1189
|
+
declare function isValidExportScale(scale: number): boolean;
|
|
1190
|
+
//#endregion
|
|
1191
|
+
//#region src/coordinate.d.ts
|
|
1192
|
+
declare function getWorldMatrix(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Mat3;
|
|
1193
|
+
declare function getAxisAlignedWorldBounds(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Rect;
|
|
1194
|
+
/** World matrix of a parent; the document root and a missing parent are the identity. */
|
|
1195
|
+
declare function getParentWorldMatrix(parent: SceneNode | undefined, graph: Pick<SceneGraph, 'getNode' | 'rootId'>): Mat3;
|
|
1196
|
+
/**
|
|
1197
|
+
* Axis-aligned box of `nodes` in `parentId`'s own axes: where a group, frame, or boolean operation
|
|
1198
|
+
* made from them sits. Each node's corners are mapped through the parent's inverse world matrix,
|
|
1199
|
+
* so a rotated or flipped parent gets a box in its own axes and the nodes keep their drawn places
|
|
1200
|
+
* once they move into the container.
|
|
1201
|
+
*/
|
|
1202
|
+
declare function getAxisAlignedBoundsInParent(nodes: readonly SceneNode[], parentId: string, graph: Pick<SceneGraph, 'getNode' | 'rootId'>): Rect;
|
|
1203
|
+
declare function getAbsolutePosition(node: SceneNode, graph: SceneGraph): Vector;
|
|
1204
|
+
declare function getAbsoluteRotation(node: SceneNode, graph: SceneGraph): number;
|
|
1205
|
+
declare function getAbsolutePositionFull(node: SceneNode, graph: SceneGraph): {
|
|
1206
|
+
x: number;
|
|
1207
|
+
y: number;
|
|
1208
|
+
boundX: number;
|
|
1209
|
+
boundY: number;
|
|
1210
|
+
width: number;
|
|
1211
|
+
height: number;
|
|
1212
|
+
rotation: number;
|
|
1213
|
+
centerX: number;
|
|
1214
|
+
centerY: number;
|
|
1215
|
+
};
|
|
1216
|
+
/** Lines retain their origin pivot; other shapes rotate around their center. */
|
|
1217
|
+
declare function getNodeRotationOrigin(node: SceneNode): Vector;
|
|
1218
|
+
/** Position can be applied separately by renderers before setting up local opacity layers. */
|
|
1219
|
+
declare function getNodeLocalMatrix(n: SceneNode, position?: Vector): Mat3;
|
|
1220
|
+
declare function getNodeWorldBounds(node: SceneNode): Rect;
|
|
1221
|
+
/**
|
|
1222
|
+
* World-space positions of the 8 selection handles. `localRect` overrides the
|
|
1223
|
+
* node-local box the handles sit on — text-on-path draws its handles on the
|
|
1224
|
+
* glyph-fitted path box, not node bounds, so its hit-test must pass that box
|
|
1225
|
+
* or the visible handles are ~25px off and unclickable. Defaults to full node
|
|
1226
|
+
* bounds.
|
|
1227
|
+
*/
|
|
1228
|
+
declare function getWorldHandles(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>, localRect?: Rect): {
|
|
1229
|
+
nw: {
|
|
1230
|
+
x: number;
|
|
1231
|
+
y: number;
|
|
1232
|
+
};
|
|
1233
|
+
n: {
|
|
1234
|
+
x: number;
|
|
1235
|
+
y: number;
|
|
1236
|
+
};
|
|
1237
|
+
ne: {
|
|
1238
|
+
x: number;
|
|
1239
|
+
y: number;
|
|
1240
|
+
};
|
|
1241
|
+
e: {
|
|
1242
|
+
x: number;
|
|
1243
|
+
y: number;
|
|
1244
|
+
};
|
|
1245
|
+
se: {
|
|
1246
|
+
x: number;
|
|
1247
|
+
y: number;
|
|
1248
|
+
};
|
|
1249
|
+
s: {
|
|
1250
|
+
x: number;
|
|
1251
|
+
y: number;
|
|
1252
|
+
};
|
|
1253
|
+
sw: {
|
|
1254
|
+
x: number;
|
|
1255
|
+
y: number;
|
|
1256
|
+
};
|
|
1257
|
+
w: {
|
|
1258
|
+
x: number;
|
|
1259
|
+
y: number;
|
|
1260
|
+
};
|
|
1261
|
+
};
|
|
1262
|
+
type LocalTransform = Pick<SceneNode, 'x' | 'y' | 'rotation' | 'flipX' | 'flipY'>;
|
|
1263
|
+
/**
|
|
1264
|
+
* Local transform that draws `node` with the given world matrix once it sits under a parent
|
|
1265
|
+
* whose world matrix is `parentWorld`. Keeps the node's own `flipX` when the matrix allows it.
|
|
1266
|
+
*/
|
|
1267
|
+
declare function localTransformFromWorld(node: SceneNode, world: Mat3, parentWorld: Mat3): LocalTransform | null;
|
|
1268
|
+
declare function isTranslationOnly(matrix: Mat3): boolean;
|
|
1269
|
+
/**
|
|
1270
|
+
* Maps a node's parent space into its container's: through the groups and booleans around it,
|
|
1271
|
+
* which set no coordinate space of their own. Figma's plugin API reports `x`, `y`, and
|
|
1272
|
+
* `relativeTransform` of their children in the container's space. The identity when the parent is
|
|
1273
|
+
* not a group.
|
|
1274
|
+
*/
|
|
1275
|
+
declare function getParentToContainerMatrix(node: SceneNode, graph: Pick<SceneGraph, 'getNode'>): Mat3;
|
|
1276
|
+
//#endregion
|
|
1277
|
+
//#region src/layout/aspect-ratio.d.ts
|
|
1278
|
+
type AspectRatioNode = Pick<SceneNode, 'type' | 'targetAspectRatio' | 'textAutoResize'>;
|
|
1279
|
+
/** The value Figma's `lockAspectRatio()` stores: the size the layer has when it is locked. */
|
|
1280
|
+
declare function lockedAspectRatioTarget(width: number, height: number): Vector;
|
|
1281
|
+
/** Whether the lock can change: a layer inside an instance keeps its component's, as in Figma. */
|
|
1282
|
+
declare function aspectRatioLockEditable(graph: SceneGraph, node: SceneNode): boolean;
|
|
1283
|
+
/**
|
|
1284
|
+
* The width-to-height ratio a resize keeps, or `null` when the layer's proportions are free.
|
|
1285
|
+
* Text that sizes itself to its content keeps the lock without following it, as in Figma.
|
|
1286
|
+
*/
|
|
1287
|
+
declare function enforcedAspectRatio(node: AspectRatioNode): number | null;
|
|
1288
|
+
/**
|
|
1289
|
+
* A resize that ignores a locked ratio, such as Figma's plugin `resize()` or a Control-drag,
|
|
1290
|
+
* keeps the lock and stores the new size as the ratio to keep.
|
|
1291
|
+
*/
|
|
1292
|
+
declare function recapturedAspectRatio(node: Pick<SceneNode, 'targetAspectRatio'>, width: number, height: number): Partial<Pick<SceneNode, 'targetAspectRatio'>>;
|
|
1293
|
+
/** The size that keeps `ratio` when one axis is set to `value`. */
|
|
1294
|
+
declare function sizeKeepingAspectRatio(ratio: number, axis: 'width' | 'height', value: number): {
|
|
1295
|
+
width: number;
|
|
1296
|
+
height: number;
|
|
1297
|
+
};
|
|
1298
|
+
//#endregion
|
|
1299
|
+
//#region src/layout/guides.d.ts
|
|
1300
|
+
interface LayoutGuideLine {
|
|
1301
|
+
axis: 'x' | 'y';
|
|
1302
|
+
position: number;
|
|
1303
|
+
}
|
|
1304
|
+
/** Figma's Auto count, as its archive stores it: as many sections as fit. */
|
|
1305
|
+
declare const AUTO_LAYOUT_GRID_COUNT = 2147483647;
|
|
1306
|
+
/** Whether a guide's count is Auto: the archive's value, or the plugin API's `Infinity` or `null`. */
|
|
1307
|
+
declare function isAutoGridCount(count: number | null | undefined): boolean;
|
|
1308
|
+
/**
|
|
1309
|
+
* A guide's count, set in Figma's plugin shape (`count`) or read from a file (`numSections`); an
|
|
1310
|
+
* edit's `count` wins over the count the file had. Auto is {@link AUTO_LAYOUT_GRID_COUNT}.
|
|
1311
|
+
*/
|
|
1312
|
+
declare function layoutGridCount(grid: LayoutGrid): number;
|
|
1313
|
+
interface LayoutGuideSection {
|
|
1314
|
+
axis: 'x' | 'y';
|
|
1315
|
+
start: number;
|
|
1316
|
+
end: number;
|
|
1317
|
+
}
|
|
1318
|
+
declare function layoutGuideSections(node: Pick<SceneNode, 'width' | 'height'>, grid: LayoutGrid): LayoutGuideSection[];
|
|
1319
|
+
declare function layoutGuideLines(node: Pick<SceneNode, 'width' | 'height'>, grid: LayoutGrid): LayoutGuideLine[];
|
|
1320
|
+
//#endregion
|
|
1321
|
+
//#region src/layout/keywords.d.ts
|
|
1322
|
+
/**
|
|
1323
|
+
* Auto layout as the formats that author it spell it: flexbox keywords from CSS, design JSX,
|
|
1324
|
+
* and `.pen` files. Each format keeps its own syntax and defaults; what a keyword means for the
|
|
1325
|
+
* scene graph is decided here once, so `space-between` or `baseline` cannot mean one thing in
|
|
1326
|
+
* one format and fall back to start in another.
|
|
1327
|
+
*/
|
|
1328
|
+
type AutoLayoutDirection = 'HORIZONTAL' | 'VERTICAL';
|
|
1329
|
+
/** The stack direction a `flex-direction`-like keyword names, or `undefined` for any other. */
|
|
1330
|
+
declare function parseAutoLayoutDirection(value: string | undefined): AutoLayoutDirection | undefined;
|
|
1331
|
+
/**
|
|
1332
|
+
* Primary axis alignment from a `justify-content` keyword. Auto layout has no
|
|
1333
|
+
* `space-around` or `space-evenly`, so those, like unknown keywords, give `undefined`.
|
|
1334
|
+
*/
|
|
1335
|
+
declare function parsePrimaryAxisAlign(value: string | undefined): LayoutAlign | undefined;
|
|
1336
|
+
/** Cross axis alignment of a stack's children from an `align-items` keyword. */
|
|
1337
|
+
declare function parseCounterAxisAlign(value: string | undefined): LayoutCounterAlign | undefined;
|
|
1338
|
+
/** One child's cross axis alignment from an `align-self` keyword; `auto` follows the parent. */
|
|
1339
|
+
declare function parseLayoutAlignSelf(value: string | undefined): LayoutAlignSelf | undefined;
|
|
1340
|
+
type PaddingFields = Pick<SceneNode, 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft'>;
|
|
1341
|
+
/** Padding from one to four values in CSS shorthand order: top, right, bottom, left. */
|
|
1342
|
+
declare function paddingFromShorthand(values: readonly number[]): PaddingFields;
|
|
1343
|
+
//#endregion
|
|
1344
|
+
//#region src/layout/sizing.d.ts
|
|
1345
|
+
/**
|
|
1346
|
+
* How a node sizes along one screen axis, as Figma's `layoutSizingHorizontal` and
|
|
1347
|
+
* `layoutSizingVertical` report it. Fill is stored on the child, the way Figma stores it:
|
|
1348
|
+
* along the parent's primary axis as `layoutGrow`, across it as `layoutAlignSelf: 'STRETCH'`.
|
|
1349
|
+
* A grid lays its children out like a horizontal stack. Hug is stored on the node itself:
|
|
1350
|
+
* `primaryAxisSizing` and `counterAxisSizing` for an auto-layout frame, `textAutoResize`
|
|
1351
|
+
* for text.
|
|
1352
|
+
*/
|
|
1353
|
+
type LayoutSizingAxis = 'HORIZONTAL' | 'VERTICAL';
|
|
1354
|
+
type AutoLayoutMode = Exclude<SceneNode['layoutMode'], 'NONE'>;
|
|
1355
|
+
/** The node's sizing along `axis`: fill from its parent, else its own hug, else fixed. */
|
|
1356
|
+
declare function layoutSizing(graph: SceneGraph, node: SceneNode, axis: LayoutSizingAxis): LayoutSizing;
|
|
1357
|
+
/** `layoutSizing` for code that holds the parent rather than the graph. */
|
|
1358
|
+
declare function layoutSizingInParent(parentNode: SceneNode | undefined, node: SceneNode, axis: LayoutSizingAxis): LayoutSizing;
|
|
1359
|
+
/** The sizings this node accepts on either axis, in Figma's order. */
|
|
1360
|
+
declare function layoutSizingOptions(graph: SceneGraph, node: SceneNode): LayoutSizing[];
|
|
1361
|
+
/** Figma's reason for refusing `value` on this node, or `undefined` when it applies. */
|
|
1362
|
+
declare function layoutSizingError(graph: SceneGraph, node: SceneNode, value: LayoutSizing): string | undefined;
|
|
1363
|
+
/** The text auto-resize that hugs the content along the axes given. */
|
|
1364
|
+
declare function textAutoResizeFor(hugsWidth: boolean, hugsHeight: boolean): TextAutoResize;
|
|
1365
|
+
/**
|
|
1366
|
+
* The fields that set the node's sizing along `axis` to `value`, as Figma's setter writes
|
|
1367
|
+
* them. A value Figma refuses yields no updates; `layoutSizingError` says why.
|
|
1368
|
+
*/
|
|
1369
|
+
declare function layoutSizingUpdates(graph: SceneGraph, node: SceneNode, axis: LayoutSizingAxis, value: LayoutSizing): Partial<SceneNode>;
|
|
1370
|
+
/**
|
|
1371
|
+
* The fields that make a child fill `axis` of a parent laid out as `parentLayout`, for a node
|
|
1372
|
+
* an importer builds before it joins the graph. Under a parent without auto layout, such as a
|
|
1373
|
+
* staging parent the node leaves when placed, both are set, so it fills whichever axis its
|
|
1374
|
+
* eventual parent stacks along.
|
|
1375
|
+
*/
|
|
1376
|
+
declare function fillSizingFields(parentLayout: SceneNode['layoutMode'], axis: LayoutSizingAxis): Partial<Pick<SceneNode, 'layoutGrow' | 'layoutAlignSelf'>>;
|
|
1377
|
+
/** An auto-layout frame's own sizing when it hugs or fixes its width and height. */
|
|
1378
|
+
declare function autoLayoutSizingFields(direction: AutoLayoutMode, width: 'FIXED' | 'HUG', height: 'FIXED' | 'HUG'): Pick<SceneNode, 'primaryAxisSizing' | 'counterAxisSizing'>;
|
|
1379
|
+
//#endregion
|
|
1380
|
+
//#region src/text/paragraphs.d.ts
|
|
1381
|
+
/** The style of a paragraph with no entry: not in a list. */
|
|
1382
|
+
declare const PLAIN_PARAGRAPH: Readonly<TextParagraphStyle>;
|
|
1383
|
+
/** Figma nests list items at most this deep. */
|
|
1384
|
+
declare const MAX_LIST_INDENTATION = 5;
|
|
1385
|
+
/** A paragraph's characters: `start` to `end`, not counting the newline that ends it. */
|
|
1386
|
+
interface TextParagraphRange {
|
|
1387
|
+
start: number;
|
|
1388
|
+
end: number;
|
|
1389
|
+
}
|
|
1390
|
+
/** The paragraphs of `text`: one per line ending at a newline, and one after the last. */
|
|
1391
|
+
declare function textParagraphRanges(text: string): TextParagraphRange[];
|
|
1392
|
+
/** The paragraph holding character `index`; a newline belongs to the paragraph it ends. */
|
|
1393
|
+
declare function paragraphIndexAt(text: string, index: number): number;
|
|
1394
|
+
declare function paragraphStyleAt(paragraphs: readonly TextParagraphStyle[], paragraph: number): TextParagraphStyle;
|
|
1395
|
+
declare const TEXT_PARAGRAPH_SPACING_FIELDS: readonly TextParagraphSpacingField[];
|
|
1396
|
+
/** A paragraph's spacing: its own value, or the text's when it sets none. */
|
|
1397
|
+
declare function paragraphSpacingAt(node: Pick<SceneNode, 'textParagraphs' | TextParagraphSpacingField>, paragraph: number, field: TextParagraphSpacingField): number;
|
|
1398
|
+
/** Whether a paragraph sets any spacing of its own. */
|
|
1399
|
+
declare function hasParagraphSpacing(style: TextParagraphStyle): boolean;
|
|
1400
|
+
/** A paragraph style with its own `field` set, or following the text again for `undefined`. */
|
|
1401
|
+
declare function withParagraphSpacing(style: TextParagraphStyle, field: TextParagraphSpacingField, value: number | undefined): TextParagraphStyle;
|
|
1402
|
+
/** Every paragraph's `field`, or `null` when they differ. */
|
|
1403
|
+
declare function sharedParagraphSpacing(node: Pick<SceneNode, 'text' | 'textParagraphs' | TextParagraphSpacingField>, field: TextParagraphSpacingField, first?: number, last?: number): number | null;
|
|
1404
|
+
/** Paragraph styles with no paragraph setting its own `field`, as setting the text's does. */
|
|
1405
|
+
declare function paragraphStylesWithoutSpacing(paragraphs: readonly TextParagraphStyle[], field: TextParagraphSpacingField): TextParagraphStyle[];
|
|
1406
|
+
/** Whether any paragraph of the node is a list item. */
|
|
1407
|
+
declare function hasTextList(node: Pick<SceneNode, 'textParagraphs'>): boolean;
|
|
1408
|
+
/**
|
|
1409
|
+
* Paragraph styles for `count` paragraphs, without the plain paragraphs at the end, so text
|
|
1410
|
+
* without lists, indentation, or paragraph spacing of its own keeps none.
|
|
1411
|
+
*/
|
|
1412
|
+
declare function trimParagraphStyles(paragraphs: readonly TextParagraphStyle[], count: number): TextParagraphStyle[];
|
|
1413
|
+
/** How many paragraphs `text` has: one more than its newlines. */
|
|
1414
|
+
declare function paragraphCount(text: string): number;
|
|
1415
|
+
/**
|
|
1416
|
+
* Paragraph styles after replacing `text[start, end)` with `inserted`, as Figma keeps them: the
|
|
1417
|
+
* paragraph the edit starts in keeps its style, paragraphs a deleted newline joins to it are
|
|
1418
|
+
* dropped, and paragraphs an inserted newline starts take its style.
|
|
1419
|
+
*/
|
|
1420
|
+
declare function paragraphStylesAfterEdit(paragraphs: readonly TextParagraphStyle[], text: string, start: number, end: number, inserted: string): TextParagraphStyle[];
|
|
1421
|
+
/**
|
|
1422
|
+
* Paragraph styles with every paragraph that `text[start, end)` touches changed by `change`,
|
|
1423
|
+
* as a range setter changes whole paragraphs.
|
|
1424
|
+
*/
|
|
1425
|
+
declare function paragraphStylesInRange(paragraphs: readonly TextParagraphStyle[], text: string, start: number, end: number, change: (style: TextParagraphStyle) => TextParagraphStyle): TextParagraphStyle[];
|
|
1426
|
+
/**
|
|
1427
|
+
* A paragraph style with its list type set. A list item is nested at least one level, and a
|
|
1428
|
+
* paragraph leaving a list keeps no indentation.
|
|
1429
|
+
*/
|
|
1430
|
+
declare function withListType(style: TextParagraphStyle, listType: TextListType): TextParagraphStyle;
|
|
1431
|
+
/** A paragraph style with its nesting set, kept in the range a list item allows. */
|
|
1432
|
+
declare function withIndentation(style: TextParagraphStyle, indentation: number): TextParagraphStyle;
|
|
1433
|
+
/**
|
|
1434
|
+
* Paragraph styles after `before` became `after` through one edit, found as the text between
|
|
1435
|
+
* their common start and end, for editors that replace the text rather than report the edit.
|
|
1436
|
+
*/
|
|
1437
|
+
declare function paragraphStylesAfterTextChange(paragraphs: readonly TextParagraphStyle[], before: string, after: string): TextParagraphStyle[];
|
|
1438
|
+
//#endregion
|
|
1439
|
+
//#region src/text/lists.d.ts
|
|
1440
|
+
/** How an ordered item's number is written at its nesting level. */
|
|
1441
|
+
type ListNumberFormat = 'DECIMAL' | 'LOWER_ALPHA' | 'LOWER_ROMAN';
|
|
1442
|
+
/** A list item paragraph and what marks it. */
|
|
1443
|
+
interface TextListItem extends TextParagraphRange {
|
|
1444
|
+
paragraph: number;
|
|
1445
|
+
listType: 'ORDERED' | 'UNORDERED';
|
|
1446
|
+
/** Nesting level, from 1. */
|
|
1447
|
+
level: number;
|
|
1448
|
+
/** The item's number among the items of its list at its level, from 1. */
|
|
1449
|
+
ordinal: number;
|
|
1450
|
+
/** The marker drawn before the item: a bullet, or its number and a period. */
|
|
1451
|
+
marker: string;
|
|
1452
|
+
/** Whether the item starts a new count at its level. */
|
|
1453
|
+
startsList: boolean;
|
|
1454
|
+
/**
|
|
1455
|
+
* The paragraph that starts the group of list items this item belongs to. A list group runs
|
|
1456
|
+
* from a list item that follows a plain paragraph, or that starts a top-level list, and its
|
|
1457
|
+
* first character styles every marker and indent in it.
|
|
1458
|
+
*/
|
|
1459
|
+
groupStart: number;
|
|
1460
|
+
}
|
|
1461
|
+
/** The marker of an unordered item, at every level. */
|
|
1462
|
+
declare const LIST_BULLET = "•";
|
|
1463
|
+
/** Ordered items count in decimal, then letters, then roman numerals, repeating as they nest. */
|
|
1464
|
+
declare function listNumberFormat(level: number): ListNumberFormat;
|
|
1465
|
+
/** An ordered item's number as its level writes it, without the period. */
|
|
1466
|
+
declare function formatListNumber(ordinal: number, format: ListNumberFormat): string;
|
|
1467
|
+
/**
|
|
1468
|
+
* The list items of a text, numbered as Figma numbers them: each level counts its own items,
|
|
1469
|
+
* a deeper item leaves the count above it running, a shallower one restarts the counts below
|
|
1470
|
+
* it, and a plain paragraph or an item of the other list type restarts the count.
|
|
1471
|
+
*/
|
|
1472
|
+
declare function textListItems(text: string, paragraphs: readonly TextParagraphStyle[]): TextListItem[];
|
|
1473
|
+
/**
|
|
1474
|
+
* Digits in the largest number of a top-level ordered item. Figma widens the indent of every
|
|
1475
|
+
* ordered item by the extra digits, so a list's numbers line up past nine.
|
|
1476
|
+
*/
|
|
1477
|
+
declare function topLevelNumberDigits(items: readonly TextListItem[]): number;
|
|
1478
|
+
//#endregion
|
|
1479
|
+
//#region src/text/references.d.ts
|
|
1480
|
+
/** What a text's runs refer to outside the text: the variables they bind and the styles they use. */
|
|
1481
|
+
interface StyleRunReferences {
|
|
1482
|
+
variables: string[];
|
|
1483
|
+
styles: string[];
|
|
1484
|
+
}
|
|
1485
|
+
/** The variables and styles a text's runs refer to, which copies and transfers carry with it. */
|
|
1486
|
+
declare function styleRunReferences(runs: readonly StyleRun[]): StyleRunReferences;
|
|
1487
|
+
/**
|
|
1488
|
+
* Runs whose variables, styles, and linked layers are renamed, as a copy into another document
|
|
1489
|
+
* renames them. Layers are renamed only when given, since a link may name a layer left behind.
|
|
1490
|
+
*/
|
|
1491
|
+
declare function remapStyleRunReferences(runs: readonly StyleRun[], rename: {
|
|
1492
|
+
variable: (id: string) => string;
|
|
1493
|
+
style: (id: string) => string;
|
|
1494
|
+
node?: (id: string) => string;
|
|
1495
|
+
}): StyleRun[];
|
|
1496
|
+
//#endregion
|
|
1497
|
+
//#region src/group-bounds.d.ts
|
|
1498
|
+
type Placement = Pick<SceneNode, 'x' | 'y' | 'width' | 'height'>;
|
|
1499
|
+
/** What `fitEnclosingGroups` changed, so a caller can undo and redo it. */
|
|
1500
|
+
interface GroupFit {
|
|
1501
|
+
before: Map<string, Placement>;
|
|
1502
|
+
after: Map<string, Placement>;
|
|
1503
|
+
/** Emptied groups, outermost last, with their index in their parent. */
|
|
1504
|
+
removed: Array<{
|
|
1505
|
+
node: SceneNode;
|
|
1506
|
+
index: number;
|
|
1507
|
+
}>;
|
|
1508
|
+
}
|
|
1509
|
+
interface GroupFitOptions {
|
|
1510
|
+
/**
|
|
1511
|
+
* The box of a boolean operation's result in its parent's space, which Figma sizes a boolean to,
|
|
1512
|
+
* or null to fit its operands. Measuring needs path operations, so the renderer supplies it.
|
|
1513
|
+
*/
|
|
1514
|
+
booleanBounds?: (node: SceneNode) => Rect | null;
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Refits the groups and booleans around these parents to their children, keeping every child where
|
|
1518
|
+
* it is on the canvas, and removes groups left empty, as Figma does after a layer inside one moves,
|
|
1519
|
+
* resizes, or leaves. Rotated or flipped containers keep their bounds. Returns null when nothing
|
|
1520
|
+
* changed.
|
|
1521
|
+
*/
|
|
1522
|
+
declare function fitEnclosingGroups(graph: SceneGraph, parentIds: Iterable<string>, options?: GroupFitOptions): GroupFit | null;
|
|
1523
|
+
/** Reapplies a fit after `undoGroupFit`. */
|
|
1524
|
+
declare function redoGroupFit(graph: SceneGraph, fit: GroupFit): void;
|
|
1525
|
+
/** Brings back the groups a fit removed and their earlier bounds. */
|
|
1526
|
+
declare function undoGroupFit(graph: SceneGraph, fit: GroupFit): void;
|
|
1527
|
+
//#endregion
|
|
1528
|
+
//#region src/geometry.d.ts
|
|
1529
|
+
declare function degToRad(degrees: number): number;
|
|
1530
|
+
declare function radToDeg(radians: number): number;
|
|
1531
|
+
declare function rotatePoint(px: number, py: number, cx: number, cy: number, rad: number): Vector;
|
|
1532
|
+
declare function rotatedCorners(cx: number, cy: number, hw: number, hh: number, rotationDeg: number): [Vector, Vector, Vector, Vector];
|
|
1533
|
+
declare function rotatedBBox(x: number, y: number, w: number, h: number, rotationDeg: number): {
|
|
1534
|
+
left: number;
|
|
1535
|
+
right: number;
|
|
1536
|
+
top: number;
|
|
1537
|
+
bottom: number;
|
|
1538
|
+
centerX: number;
|
|
1539
|
+
centerY: number;
|
|
1540
|
+
};
|
|
1541
|
+
interface VisualBounds {
|
|
1542
|
+
minX: number;
|
|
1543
|
+
minY: number;
|
|
1544
|
+
maxX: number;
|
|
1545
|
+
maxY: number;
|
|
1546
|
+
}
|
|
1547
|
+
declare function computeBounds(items: Iterable<Rect>): Rect;
|
|
1548
|
+
declare function polygonVertices(node: {
|
|
1549
|
+
width: number;
|
|
1550
|
+
height: number;
|
|
1551
|
+
pointCount: number;
|
|
1552
|
+
type: string;
|
|
1553
|
+
starInnerRadius: number;
|
|
1554
|
+
}): Vector[];
|
|
1555
|
+
declare function strokeOverflow(strokes?: Stroke[], fallbackCap?: StrokeCap, network?: VectorNetwork | null): number;
|
|
1556
|
+
declare function effectOverflow(effects?: Effect[]): {
|
|
1557
|
+
left: number;
|
|
1558
|
+
right: number;
|
|
1559
|
+
top: number;
|
|
1560
|
+
bottom: number;
|
|
1561
|
+
};
|
|
1562
|
+
declare function computeAbsoluteBounds(nodes: Iterable<{
|
|
1563
|
+
id: string;
|
|
1564
|
+
width: number;
|
|
1565
|
+
height: number;
|
|
1566
|
+
}>, getAbsolutePosition: (id: string) => Vector): Rect;
|
|
1567
|
+
declare function computeVisualBounds(nodes: Iterable<{
|
|
1568
|
+
id: string;
|
|
1569
|
+
width: number;
|
|
1570
|
+
height: number;
|
|
1571
|
+
rotation?: number;
|
|
1572
|
+
strokes?: Stroke[];
|
|
1573
|
+
strokeCap?: StrokeCap;
|
|
1574
|
+
vectorNetwork?: VectorNetwork | null;
|
|
1575
|
+
effects?: Effect[];
|
|
1576
|
+
}>, getAbsolutePosition: (id: string) => Vector): Rect;
|
|
1577
|
+
interface VisualBoundsNode {
|
|
1578
|
+
id: string;
|
|
1579
|
+
width: number;
|
|
1580
|
+
height: number;
|
|
1581
|
+
rotation?: number;
|
|
1582
|
+
flipX?: boolean;
|
|
1583
|
+
flipY?: boolean;
|
|
1584
|
+
strokes?: Stroke[];
|
|
1585
|
+
strokeCap?: StrokeCap;
|
|
1586
|
+
vectorNetwork?: VectorNetwork | null;
|
|
1587
|
+
effects?: Effect[];
|
|
1588
|
+
fillGeometry?: Array<{
|
|
1589
|
+
commandsBlob: Uint8Array;
|
|
1590
|
+
}>;
|
|
1591
|
+
strokeGeometry?: Array<{
|
|
1592
|
+
commandsBlob: Uint8Array;
|
|
1593
|
+
}>;
|
|
1594
|
+
childIds?: string[];
|
|
1595
|
+
visible?: boolean;
|
|
1596
|
+
type?: string;
|
|
1597
|
+
clipsContent?: boolean;
|
|
1598
|
+
fontSize?: number;
|
|
1599
|
+
textDecoration?: string;
|
|
1600
|
+
textUnderlineOffset?: number | null;
|
|
1601
|
+
textDecorationThickness?: number | null;
|
|
1602
|
+
}
|
|
1603
|
+
declare function unionVisualBounds(a: VisualBounds | null, b: VisualBounds | null): VisualBounds | null;
|
|
1604
|
+
declare function intersectVisualBounds(a: VisualBounds, b: VisualBounds): VisualBounds | null;
|
|
1605
|
+
/**
|
|
1606
|
+
* Coordinate pairs per path blob command: 0=close, 1=move, 2=line,
|
|
1607
|
+
* 3=quad (glyph-derived blobs are quad-heavy), 4=cubic. Unknown → null so
|
|
1608
|
+
* walkers stop instead of desyncing into coordinate bytes.
|
|
1609
|
+
*/
|
|
1610
|
+
declare function geometryCommandCoordCount(command: number): number | null;
|
|
1611
|
+
declare function geometryBlobBounds(paths: Array<{
|
|
1612
|
+
commandsBlob: Uint8Array;
|
|
1613
|
+
}>): Rect | null;
|
|
1614
|
+
declare function nodeVisualBounds(node: VisualBoundsNode, getAbsolutePosition: (id: string) => Vector): VisualBounds;
|
|
1615
|
+
declare function computeDescendantVisualBounds(nodeIds: string[], getNode: (id: string) => VisualBoundsNode | undefined, getAbsolutePosition: (id: string) => Vector): VisualBounds | null;
|
|
1616
|
+
/**
|
|
1617
|
+
* Clip a subject polygon against a convex polygon (e.g. the 4 canvas-space
|
|
1618
|
+
* corners of a rotated clipping ancestor).
|
|
1619
|
+
*
|
|
1620
|
+
* Uses Sutherland–Hodgman polygon clipping with centroid-based interior
|
|
1621
|
+
* detection, making it robust to either winding order of the clip polygon.
|
|
1622
|
+
* Returns the clipped polygon, or null if the subject is fully outside the
|
|
1623
|
+
* clip polygon. When `clipCorners` has fewer than 3 points the subject is
|
|
1624
|
+
* returned unchanged (no clipping).
|
|
1625
|
+
*
|
|
1626
|
+
* Preserving the polygon (rather than collapsing to an AABB) lets callers
|
|
1627
|
+
* chain multiple clips without reintroducing corners removed by an inner clip.
|
|
1628
|
+
*/
|
|
1629
|
+
declare function clipPolygon(subject: Vector[], clipCorners: Vector[]): Vector[] | null;
|
|
1630
|
+
/**
|
|
1631
|
+
* Clip an axis-aligned VisualBounds rectangle against a convex polygon
|
|
1632
|
+
* (e.g. the 4 canvas-space corners of a rotated clipping ancestor).
|
|
1633
|
+
*
|
|
1634
|
+
* Returns the AABB of the intersection, or null if the bounds are fully
|
|
1635
|
+
* outside the clip polygon. Delegates to {@link clipPolygon}.
|
|
1636
|
+
*
|
|
1637
|
+
* For a non-rotated clip (axis-aligned corners) the result is identical
|
|
1638
|
+
* to `intersectVisualBounds`.
|
|
1639
|
+
*/
|
|
1640
|
+
declare function clipBoundsToPolygon(bounds: VisualBounds, clipCorners: Vector[]): VisualBounds | null;
|
|
1641
|
+
//#endregion
|
|
1642
|
+
//#region src/font-style.d.ts
|
|
1643
|
+
interface FontFamilyStyle {
|
|
1644
|
+
family: string;
|
|
1645
|
+
style: string;
|
|
1646
|
+
}
|
|
1647
|
+
interface ParsedFontStyle {
|
|
1648
|
+
weight: number;
|
|
1649
|
+
italic: boolean;
|
|
1650
|
+
}
|
|
1651
|
+
declare const FONT_WEIGHT_NAMES: Record<number, string>;
|
|
1652
|
+
declare function normalizeFontStyleName(style: string): string;
|
|
1653
|
+
declare function parseFontStyle(style: string | undefined): ParsedFontStyle;
|
|
1654
|
+
declare function styleToWeight(style: string | undefined): number;
|
|
1655
|
+
declare function normalizeFontFamily(family: string): string;
|
|
1656
|
+
declare function styleToVariant(style: string): string;
|
|
1657
|
+
declare function weightToStyle(weight: number, italic?: boolean): string;
|
|
1658
|
+
//#endregion
|
|
1659
|
+
//#region src/shared-styles.d.ts
|
|
1660
|
+
declare const STYLE_REF_KEYS: {
|
|
1661
|
+
readonly fill: "fillStyleId";
|
|
1662
|
+
readonly stroke: "strokeStyleId";
|
|
1663
|
+
readonly text: "textStyleId";
|
|
1664
|
+
readonly effect: "effectStyleId";
|
|
1665
|
+
readonly grid: "gridStyleId";
|
|
1666
|
+
};
|
|
1667
|
+
/** The fields a text style gives what uses it; changing one leaves the style. */
|
|
1668
|
+
declare const SHARED_TEXT_STYLE_FIELDS: readonly ["fontFamily", "fontWeight", "italic", "fontSize", "lineHeight", "letterSpacing", "textDecoration", "textCase", "fontFeatures"];
|
|
1669
|
+
declare function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind];
|
|
1670
|
+
declare function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType;
|
|
1671
|
+
declare function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[];
|
|
1672
|
+
declare function styleDetachmentChanges(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode>;
|
|
1673
|
+
//#endregion
|
|
1674
|
+
//#region src/buffered-events.d.ts
|
|
1675
|
+
declare class CommittedGraphEventError extends AggregateError {
|
|
1676
|
+
readonly committed = true;
|
|
1677
|
+
constructor(errors: readonly unknown[]);
|
|
1678
|
+
}
|
|
1679
|
+
/** Stable emitter identity with synchronous, nestable event buffering. */
|
|
1680
|
+
declare class BufferedSceneEmitter implements Emitter<SceneGraphEvents> {
|
|
1681
|
+
private readonly delegate;
|
|
1682
|
+
private readonly buffers;
|
|
1683
|
+
get events(): Emitter<SceneGraphEvents>['events'];
|
|
1684
|
+
set events(events: Emitter<SceneGraphEvents>['events']);
|
|
1685
|
+
on<K extends keyof SceneGraphEvents>(event: K, listener: SceneGraphEvents[K]): import("nanoevents").Unsubscribe;
|
|
1686
|
+
emit<K extends keyof SceneGraphEvents>(event: K, ...args: Parameters<SceneGraphEvents[K]>): void;
|
|
1687
|
+
/** Buffers events, not mutations. Callers own rollback if the action throws. */
|
|
1688
|
+
batch<T>(action: () => T): T;
|
|
1689
|
+
}
|
|
1690
|
+
//#endregion
|
|
1691
|
+
//#region src/hit-test.d.ts
|
|
1692
|
+
declare function hitTest(graph: SceneGraph, px: number, py: number, scopeId?: string): SceneNode | null;
|
|
1693
|
+
declare function hitTestDeep(graph: SceneGraph, px: number, py: number, scopeId?: string, pad?: number): SceneNode | null;
|
|
1694
|
+
/**
|
|
1695
|
+
* The layer a click selects, as in Figma. It walks from the scope down to the deepest layer under
|
|
1696
|
+
* the point and stops at the first layer that is not open. Top-level frames and sections with
|
|
1697
|
+
* layers and component sets are open, and so is every ancestor of the selection, so clicks reach
|
|
1698
|
+
* the siblings of selected layers. Where every layer under the point is open, a container opened
|
|
1699
|
+
* by the selection is selected, so is a top-level frame with auto layout, and a plain top-level
|
|
1700
|
+
* frame or a section is not.
|
|
1701
|
+
*/
|
|
1702
|
+
declare function hitTestSelectable(graph: SceneGraph, px: number, py: number, scopeId: string, selectedIds: ReadonlySet<string>, pad?: number): SceneNode | null;
|
|
1703
|
+
/** Whether a click looks into this container rather than selecting it; see `hitTestSelectable`. */
|
|
1704
|
+
declare function isOpenContainer(graph: SceneGraph, nodeId: string): boolean;
|
|
1705
|
+
/**
|
|
1706
|
+
* The innermost open container under the point when every layer there is open: a marquee starting
|
|
1707
|
+
* here selects that container's layers, as in Figma.
|
|
1708
|
+
*/
|
|
1709
|
+
declare function hitTestOpenContainer(graph: SceneGraph, px: number, py: number, scopeId: string): SceneNode | null;
|
|
1710
|
+
/** Whether the point lies inside the node's rotated and flipped bounds. */
|
|
1711
|
+
declare function isPointInNode(graph: SceneGraph, nodeId: string, px: number, py: number): boolean;
|
|
1712
|
+
interface DropTargetOptions {
|
|
1713
|
+
/**
|
|
1714
|
+
* Set when the dropped layers are all main components: the component sets they come from.
|
|
1715
|
+
* Components then go only into frames, sections, instances, and those sets.
|
|
1716
|
+
*/
|
|
1717
|
+
componentSetIds?: ReadonlySet<string>;
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* The topmost unlocked frame, section, component, or instance under the point, in its rotated
|
|
1721
|
+
* shape and inside its clipping ancestors. Groups and component sets are looked through but never
|
|
1722
|
+
* returned, except that a set takes dropped components; locked layers and their contents are
|
|
1723
|
+
* skipped.
|
|
1724
|
+
*/
|
|
1725
|
+
declare function hitTestDropTarget(graph: SceneGraph, px: number, py: number, excludeIds: ReadonlySet<string>, scopeId?: string, options?: DropTargetOptions): SceneNode | null;
|
|
1726
|
+
//#endregion
|
|
1727
|
+
//#region src/preview.d.ts
|
|
1728
|
+
type NodePreviewObserver = (node: SceneNode, changes: Partial<SceneNode>) => void;
|
|
1729
|
+
type PreviewGraph = {
|
|
1730
|
+
nodes: Map<string, SceneNode>;
|
|
1731
|
+
positionPreviewVersion: number;
|
|
1732
|
+
clearAbsPosCache: () => void;
|
|
1733
|
+
};
|
|
1734
|
+
declare function updateNodePreview(graph: PreviewGraph, id: string, changes: Partial<SceneNode>, beforeUpdate?: NodePreviewObserver): Partial<SceneNode> | null;
|
|
1735
|
+
//#endregion
|
|
1736
|
+
//#region src/vector-network.d.ts
|
|
1737
|
+
/** Concatenate vector networks while preserving independent geometry. */
|
|
1738
|
+
declare function mergeVectorNetworks(networks: readonly VectorNetwork[]): VectorNetwork;
|
|
1739
|
+
/**
|
|
1740
|
+
* Map a VectorNetwork through an affine matrix: vertices as points,
|
|
1741
|
+
* tangents as direction vectors (linear part only, no translation).
|
|
1742
|
+
* Returns a deep copy; the input is not mutated.
|
|
1743
|
+
*/
|
|
1744
|
+
declare function transformVectorNetwork(m: Mat3, vn: VectorNetwork): VectorNetwork;
|
|
1745
|
+
/** Structural equality of two VectorNetworks (order-sensitive, exact values). */
|
|
1746
|
+
declare function vectorNetworksEqual(a: VectorNetwork, b: VectorNetwork): boolean;
|
|
1747
|
+
/** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */
|
|
1748
|
+
declare function cloneVectorNetwork(vn: VectorNetwork): VectorNetwork;
|
|
1749
|
+
/**
|
|
1750
|
+
* Validate a VectorNetwork structure, returning an array of error messages.
|
|
1751
|
+
* Empty array means the network is valid.
|
|
1752
|
+
*/
|
|
1753
|
+
declare function validateVectorNetwork(value: unknown): string[];
|
|
1754
|
+
type NormalizableVectorNetwork = Omit<VectorNetwork, 'regions'> & {
|
|
1755
|
+
regions?: VectorNetwork['regions'];
|
|
1756
|
+
};
|
|
1757
|
+
/**
|
|
1758
|
+
* Ensure every segment has tangentStart/tangentEnd and a regions array.
|
|
1759
|
+
* Missing tangents default to {x:0, y:0} (straight line segments).
|
|
1760
|
+
* Use at system boundaries where input may come from JSON/MCP.
|
|
1761
|
+
*/
|
|
1762
|
+
declare function normalizeVectorNetwork(vn: NormalizableVectorNetwork): VectorNetwork;
|
|
1763
|
+
//#endregion
|
|
1764
|
+
//#region src/checkpoint.d.ts
|
|
1765
|
+
/** Capture rollback state without changing graph or surviving object identities. */
|
|
1766
|
+
declare function captureGraphCheckpoint(graph: SceneGraph): {
|
|
1767
|
+
nodes: Map<string, SceneNode>;
|
|
1768
|
+
variables: Map<string, Variable>;
|
|
1769
|
+
assertPropertiesOnly: () => void;
|
|
1770
|
+
restore: () => void;
|
|
1771
|
+
};
|
|
1772
|
+
//#endregion
|
|
1773
|
+
//#region src/index.d.ts
|
|
1774
|
+
/**
|
|
1775
|
+
* Sets the session part of the IDs this process mints, as in Figma's `sessionID:localID` GUIDs.
|
|
1776
|
+
* Every process starts in a random session, so layers that the editor, the CLI, or MCP add to
|
|
1777
|
+
* copies of one file never share IDs. Tests and fixtures that need the same IDs on every run
|
|
1778
|
+
* set a fixed session or give the graph its own generator. Returns the previous session.
|
|
1779
|
+
*/
|
|
1780
|
+
declare function setIdSession(sessionId: number): number;
|
|
1781
|
+
declare function generateId(): string;
|
|
1782
|
+
declare class SceneGraph {
|
|
1783
|
+
private readonly idGenerator;
|
|
1784
|
+
nodes: Map<string, SceneNode>;
|
|
1785
|
+
images: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
1786
|
+
variables: Map<string, Variable>;
|
|
1787
|
+
variableCollections: Map<string, VariableCollection>;
|
|
1788
|
+
activeMode: Map<string, string>;
|
|
1789
|
+
rootId: string;
|
|
1790
|
+
figKiwiVersion: number | null;
|
|
1791
|
+
/** Deflated kiwi schema bytes from the original .fig file, preserved for roundtrip fidelity. */
|
|
1792
|
+
figSchemaDeflated: Uint8Array | null;
|
|
1793
|
+
documentColorSpace: DocumentColorSpace;
|
|
1794
|
+
enabledLibraries: Map<string, EnabledLibraryBinding>;
|
|
1795
|
+
readonly emitter: BufferedSceneEmitter;
|
|
1796
|
+
private absPosCache;
|
|
1797
|
+
private previewMutationDepth;
|
|
1798
|
+
private previewObservers;
|
|
1799
|
+
private readonly changeObservers;
|
|
1800
|
+
private sourceMetadataPreservationDepth;
|
|
1801
|
+
private importedStateApplicationDepth;
|
|
1802
|
+
private importedIdGenerator;
|
|
1803
|
+
private layoutMutationDepth;
|
|
1804
|
+
private derivedLayoutDepth;
|
|
1805
|
+
positionPreviewVersion: number;
|
|
1806
|
+
instanceIndex: Map<string, Set<string>>;
|
|
1807
|
+
constructor(idGenerator?: () => string);
|
|
1808
|
+
addPage(name: string): SceneNode;
|
|
1809
|
+
getPages(includeInternal?: boolean): SceneNode[];
|
|
1810
|
+
getAllNodes(): Iterable<SceneNode>;
|
|
1811
|
+
getNode(id: string): SceneNode | undefined;
|
|
1812
|
+
onNodeEvents(handlers: SceneGraphEventHandlers): () => void;
|
|
1813
|
+
/**
|
|
1814
|
+
* Tells `observer` about each node an edit adds and, before it changes, each node it is about
|
|
1815
|
+
* to change, so a recorder can keep the node as it was. Unlike node events these are never
|
|
1816
|
+
* buffered. Graph methods report the nodes they change; code that writes into a node directly
|
|
1817
|
+
* reports it with `willChangeNode` first.
|
|
1818
|
+
*/
|
|
1819
|
+
observeNodeChanges(observer: NodeChangeObserver): () => void;
|
|
1820
|
+
/** Tells `observeNodeChanges` observers that `node` is about to change. */
|
|
1821
|
+
willChangeNode(node: SceneNode | undefined): void;
|
|
1822
|
+
countDescendants(nodeId: string): number;
|
|
1823
|
+
addVariable(variable: Variable): void;
|
|
1824
|
+
removeVariable(id: string): void;
|
|
1825
|
+
addCollection(collection: VariableCollection): void;
|
|
1826
|
+
createVariable(name: string, type: VariableType, collectionId: string, value?: VariableValue): Variable;
|
|
1827
|
+
createCollection(name: string): VariableCollection;
|
|
1828
|
+
createMode(collectionId: string, name: string, sourceModeId?: string): string | undefined;
|
|
1829
|
+
removeCollection(id: string): void;
|
|
1830
|
+
getActiveModeId(collectionId: string): string;
|
|
1831
|
+
getNodeVariableModeId(nodeId: string, collectionId: string): string;
|
|
1832
|
+
setActiveMode(collectionId: string, modeId: string): void;
|
|
1833
|
+
addMode(collectionId: string, modeId: string, name: string, sourceMode?: string): void;
|
|
1834
|
+
removeMode(collectionId: string, modeId: string): void;
|
|
1835
|
+
renameMode(collectionId: string, modeId: string, name: string): void;
|
|
1836
|
+
setDefaultMode(collectionId: string, modeId: string): void;
|
|
1837
|
+
resolveVariable(variableId: string, modeId?: string, visited?: Set<string>): VariableValue | undefined;
|
|
1838
|
+
resolveColorVariable(variableId: string): Color | undefined;
|
|
1839
|
+
resolveNumberVariable(variableId: string): number | undefined;
|
|
1840
|
+
resolveColorVariableForNode(nodeId: string, variableId: string, fallback?: VariableModeFallback): Color | undefined;
|
|
1841
|
+
resolveNumberVariableForNode(nodeId: string, variableId: string, fallback?: VariableModeFallback): number | undefined;
|
|
1842
|
+
resolveVariableForNode(nodeId: string, variableId: string, fallback?: VariableModeFallback): VariableValue | undefined;
|
|
1843
|
+
resolveStringVariableForNode(nodeId: string, variableId: string, fallback?: VariableModeFallback): string | undefined;
|
|
1844
|
+
getVariablesForCollection(collectionId: string): Variable[];
|
|
1845
|
+
getVariablesByType(type: VariableType): Variable[];
|
|
1846
|
+
bindVariable(nodeId: string, field: string, variableId: string): void;
|
|
1847
|
+
unbindVariable(nodeId: string, field: string): void;
|
|
1848
|
+
getChildren(id: string): SceneNode[];
|
|
1849
|
+
isContainer(id: string): boolean;
|
|
1850
|
+
isDescendant(childId: string, ancestorId: string): boolean;
|
|
1851
|
+
/**
|
|
1852
|
+
* The node itself or its nearest ancestor that matches. The walk visits at most as many nodes
|
|
1853
|
+
* as the graph holds, so a parent cycle in bad data cannot hang it.
|
|
1854
|
+
*/
|
|
1855
|
+
closest(id: string, match: (node: SceneNode) => boolean): SceneNode | undefined;
|
|
1856
|
+
/**
|
|
1857
|
+
* The page a node is on: the node itself for a page, its nearest page ancestor otherwise, and
|
|
1858
|
+
* null for the document root or a node on no page.
|
|
1859
|
+
*/
|
|
1860
|
+
pageOf(id: string): string | null;
|
|
1861
|
+
clearAbsPosCache(): void;
|
|
1862
|
+
getAbsolutePosition(id: string): Vector;
|
|
1863
|
+
getAbsoluteBounds(id: string): Rect;
|
|
1864
|
+
/**
|
|
1865
|
+
* An ID no entity uses; `issued` also excludes IDs handed out earlier in the same creation.
|
|
1866
|
+
* A generator that returns more taken IDs than the graph holds must be repeating itself, so
|
|
1867
|
+
* it counts as exhausted then; a fixed cap would reject a sequence walking past a large import.
|
|
1868
|
+
*/
|
|
1869
|
+
private generateEntityId;
|
|
1870
|
+
private entityIdCount;
|
|
1871
|
+
private isEntityIdTaken;
|
|
1872
|
+
private registerNode;
|
|
1873
|
+
/** Publish synchronous graph events only after the supplied mutation succeeds. */
|
|
1874
|
+
withBufferedEvents<T>(action: () => T): T;
|
|
1875
|
+
createNode(type: NodeType, parentId: string, overrides?: Partial<SceneNode>): SceneNode;
|
|
1876
|
+
createNodeWithId(id: string, type: NodeType, parentId: string | null, overrides?: Partial<SceneNode>): SceneNode;
|
|
1877
|
+
static TEXT_PICTURE_KEYS: ReadonlySet<string>;
|
|
1878
|
+
static GLYPH_AFFECTING_KEYS: ReadonlySet<string>;
|
|
1879
|
+
static LAYOUT_AFFECTING_KEYS: ReadonlySet<string>;
|
|
1880
|
+
runPreviewUpdates(fn: () => void, beforeUpdate?: NodePreviewObserver): void;
|
|
1881
|
+
preserveSourceMetadataDuring<T>(fn: () => T): T;
|
|
1882
|
+
get isPreservingSourceMetadata(): boolean;
|
|
1883
|
+
applyImportedStateDuring<T>(fn: () => T, idGenerator?: () => string): T;
|
|
1884
|
+
get isApplyingImportedState(): boolean;
|
|
1885
|
+
/**
|
|
1886
|
+
* Lays out what the document already holds: a page as it loads, or again once its fonts
|
|
1887
|
+
* arrive. What this writes derives from the document; an edit's own layout is not this.
|
|
1888
|
+
*/
|
|
1889
|
+
applyDerivedLayoutDuring(fn: () => void): void;
|
|
1890
|
+
get isApplyingDerivedLayout(): boolean;
|
|
1891
|
+
withLayoutMutations(fn: () => void): void;
|
|
1892
|
+
get isApplyingLayout(): boolean;
|
|
1893
|
+
updateNodePositionPreview(id: string, x: number, y: number): void;
|
|
1894
|
+
updateNodePreview(id: string, changes: Partial<SceneNode>): void;
|
|
1895
|
+
updateNode(id: string, changes: Partial<SceneNode>): void;
|
|
1896
|
+
/** Replay captured properties without dropping explicit undefined values or absent keys. */
|
|
1897
|
+
restoreNodeProperties(id: string, changes: Partial<SceneNode>, absent: readonly (keyof SceneNode)[]): void;
|
|
1898
|
+
private applyNodeChanges;
|
|
1899
|
+
reparentNode(nodeId: string, newParentId: string): void;
|
|
1900
|
+
private parentWorldMatrix;
|
|
1901
|
+
reorderChild(nodeId: string, parentId: string, insertIndex: number): void;
|
|
1902
|
+
insertChildAt(childId: string, parentId: string, index: number): void;
|
|
1903
|
+
deleteNode(id: string): void;
|
|
1904
|
+
hitTest(px: number, py: number, scopeId?: string): SceneNode | null;
|
|
1905
|
+
/** `pad`, in canvas units, grows each shape's box, as Figma takes clicks just outside one. */
|
|
1906
|
+
hitTestDeep(px: number, py: number, scopeId?: string, pad?: number): SceneNode | null;
|
|
1907
|
+
hitTestSelectable(px: number, py: number, scopeId: string, selectedIds: ReadonlySet<string>, pad?: number): SceneNode | null;
|
|
1908
|
+
hitTestOpenContainer(px: number, py: number, scopeId: string): SceneNode | null;
|
|
1909
|
+
isOpenContainer(nodeId: string): boolean;
|
|
1910
|
+
isPointInNode(nodeId: string, px: number, py: number): boolean;
|
|
1911
|
+
hitTestDropTarget(px: number, py: number, excludeIds: ReadonlySet<string>, scopeId?: string, options?: DropTargetOptions): SceneNode | null;
|
|
1912
|
+
cloneTree(sourceId: string, parentId: string, overrides?: Partial<SceneNode>): SceneNode | null;
|
|
1913
|
+
createInstance(componentId: string, parentId: string, overrides?: Partial<SceneNode>): SceneNode | null;
|
|
1914
|
+
populateInstanceChildren(instanceId: string, componentId: string, mode?: NodeCloneMode): void;
|
|
1915
|
+
swapInstanceComponent(instanceId: string, componentId: string, options?: SwapInstanceOptions): void;
|
|
1916
|
+
syncInstances(componentId: string): void;
|
|
1917
|
+
syncInstancesTogether(componentIds: Iterable<string>): void;
|
|
1918
|
+
syncInstance(instanceId: string): void;
|
|
1919
|
+
detachInstance(instanceId: string): void;
|
|
1920
|
+
getMainComponent(instanceId: string): SceneNode | undefined;
|
|
1921
|
+
getInstances(componentId: string): SceneNode[];
|
|
1922
|
+
flattenTree(parentId?: string, depth?: number): Array<{
|
|
1923
|
+
node: SceneNode;
|
|
1924
|
+
depth: number;
|
|
1925
|
+
}>;
|
|
1926
|
+
}
|
|
1927
|
+
//#endregion
|
|
1928
|
+
//#region src/guides.d.ts
|
|
1929
|
+
interface CanvasGuide {
|
|
1930
|
+
id: string;
|
|
1931
|
+
axis: 'x' | 'y';
|
|
1932
|
+
position: number;
|
|
1933
|
+
figGuid?: GUID;
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* The layers on a page that carry guides, which a frame anywhere in the tree can, as in Figma.
|
|
1937
|
+
* The graph keeps the set current from its node events, so drawing and hit-testing guides do not
|
|
1938
|
+
* walk the page's whole tree on every frame.
|
|
1939
|
+
*/
|
|
1940
|
+
declare function guideOwnersOnPage(graph: SceneGraph, pageId: string): SceneNode[];
|
|
1941
|
+
//#endregion
|
|
27
1942
|
//#region src/types.d.ts
|
|
28
1943
|
interface SceneGraphEvents {
|
|
29
1944
|
'node:created': (node: SceneNode) => void;
|
|
@@ -41,6 +1956,13 @@ type SceneGraphEventHandlers = Partial<{
|
|
|
41
1956
|
reparented: (nodeId: string, oldParentId: string | null, newParentId: string) => void;
|
|
42
1957
|
reordered: (nodeId: string, parentId: string, index: number, previousParentId: string | null) => void;
|
|
43
1958
|
}>;
|
|
1959
|
+
/** Hears about nodes as an edit adds and changes them, synchronously and before each change. */
|
|
1960
|
+
interface NodeChangeObserver {
|
|
1961
|
+
/** A node is about to change and is still as it was. */
|
|
1962
|
+
before: (node: SceneNode) => void;
|
|
1963
|
+
/** A node was just added. */
|
|
1964
|
+
created: (node: SceneNode) => void;
|
|
1965
|
+
}
|
|
44
1966
|
type DocumentColorSpace = 'srgb' | 'display-p3';
|
|
45
1967
|
interface FigmaSourcePayload {
|
|
46
1968
|
rawSize: Vector | null;
|
|
@@ -136,12 +2058,14 @@ type MaskType = 'ALPHA' | 'VECTOR' | 'LUMINANCE';
|
|
|
136
2058
|
interface LayoutGrid {
|
|
137
2059
|
visible?: boolean;
|
|
138
2060
|
color?: Color;
|
|
139
|
-
|
|
2061
|
+
/** `STRIPES` is the archive's name for columns or rows, along `axis`. */
|
|
2062
|
+
pattern?: 'COLUMNS' | 'ROWS' | 'GRID' | 'STRIPES';
|
|
140
2063
|
axis?: 'X' | 'Y';
|
|
141
2064
|
type?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH';
|
|
142
2065
|
alignment?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH';
|
|
143
2066
|
numSections?: number;
|
|
144
|
-
count
|
|
2067
|
+
/** Figma's plugin API reports an Auto count as `null` and accepts `Infinity` for it. */
|
|
2068
|
+
count?: number | null;
|
|
145
2069
|
offset?: number;
|
|
146
2070
|
sectionSize?: number;
|
|
147
2071
|
gutterSize?: number;
|
|
@@ -152,11 +2076,9 @@ interface SharedStyle {
|
|
|
152
2076
|
name: string;
|
|
153
2077
|
type: SharedStyleType;
|
|
154
2078
|
}
|
|
155
|
-
|
|
156
|
-
|
|
2079
|
+
/** A stroke is a paint with the geometry that decides where it is drawn. */
|
|
2080
|
+
interface Stroke extends Fill {
|
|
157
2081
|
weight: number;
|
|
158
|
-
opacity: number;
|
|
159
|
-
visible: boolean;
|
|
160
2082
|
align: 'INSIDE' | 'CENTER' | 'OUTSIDE';
|
|
161
2083
|
cap?: StrokeCap;
|
|
162
2084
|
join?: StrokeJoin;
|
|
@@ -181,6 +2103,20 @@ type TextDecorationStyle = 'SOLID' | 'DOTTED' | 'WAVY';
|
|
|
181
2103
|
type LeadingTrim = 'NONE' | 'CAP_HEIGHT';
|
|
182
2104
|
type TextDirection = 'AUTO' | 'LTR' | 'RTL';
|
|
183
2105
|
type LayoutDirection = 'AUTO' | 'LTR' | 'RTL';
|
|
2106
|
+
/** Whether a paragraph is an item of a numbered list, a bulleted list, or no list. */
|
|
2107
|
+
type TextListType = 'NONE' | 'ORDERED' | 'UNORDERED';
|
|
2108
|
+
/** How one paragraph of a text node (a line ending at a newline) sits in a list. */
|
|
2109
|
+
/** Spacing a text sets for all its paragraphs and a paragraph can set for itself. */
|
|
2110
|
+
type TextParagraphSpacingField = 'listSpacing' | 'paragraphSpacing' | 'paragraphIndent';
|
|
2111
|
+
interface TextParagraphStyle {
|
|
2112
|
+
listType: TextListType;
|
|
2113
|
+
/** Nesting level: 1–5 for list items; kept but not drawn for plain paragraphs. */
|
|
2114
|
+
indentation: number;
|
|
2115
|
+
/** This paragraph's own spacing, in place of the text's; absent ones follow the text. */
|
|
2116
|
+
listSpacing?: number;
|
|
2117
|
+
paragraphSpacing?: number;
|
|
2118
|
+
paragraphIndent?: number;
|
|
2119
|
+
}
|
|
184
2120
|
interface FontVariation {
|
|
185
2121
|
axis: string;
|
|
186
2122
|
value: number;
|
|
@@ -189,6 +2125,16 @@ interface FontFeature {
|
|
|
189
2125
|
tag: string;
|
|
190
2126
|
enabled: boolean;
|
|
191
2127
|
}
|
|
2128
|
+
/** Where a stretch of text links to, as Figma's `HyperlinkTarget`: a URL, or a node by its ID. */
|
|
2129
|
+
interface HyperlinkTarget {
|
|
2130
|
+
type: 'URL' | 'NODE';
|
|
2131
|
+
value: string;
|
|
2132
|
+
}
|
|
2133
|
+
/** The text fields a range of characters can bind to a variable, as Figma lists them. */
|
|
2134
|
+
declare const TEXT_BINDABLE_FIELDS: readonly ["fontFamily", "fontSize", "fontStyle", "fontWeight", "letterSpacing", "lineHeight", "paragraphSpacing", "paragraphIndent"];
|
|
2135
|
+
type TextBindableField = (typeof TEXT_BINDABLE_FIELDS)[number];
|
|
2136
|
+
/** Variable IDs bound to text fields, by field. */
|
|
2137
|
+
type TextBoundVariables = Partial<Record<TextBindableField, string>>;
|
|
192
2138
|
interface CharacterStyleOverride {
|
|
193
2139
|
fontWeight?: number;
|
|
194
2140
|
italic?: boolean;
|
|
@@ -206,6 +2152,15 @@ interface CharacterStyleOverride {
|
|
|
206
2152
|
fontVariations?: FontVariation[];
|
|
207
2153
|
fontFeatures?: FontFeature[];
|
|
208
2154
|
textLanguage?: string | null;
|
|
2155
|
+
textCase?: TextCase;
|
|
2156
|
+
/** A link over the characters; `null`, like leaving it out, links nowhere. */
|
|
2157
|
+
hyperlink?: HyperlinkTarget | null;
|
|
2158
|
+
/** The text style the characters use in place of the text's own; `null` uses none. */
|
|
2159
|
+
textStyleId?: string | null;
|
|
2160
|
+
/** The fill style the characters use in place of the text's own; `null` uses none. */
|
|
2161
|
+
fillStyleId?: string | null;
|
|
2162
|
+
/** The characters' text field bindings, in place of the text's own. */
|
|
2163
|
+
boundVariables?: TextBoundVariables;
|
|
209
2164
|
}
|
|
210
2165
|
interface StyleRun {
|
|
211
2166
|
start: number;
|
|
@@ -218,7 +2173,10 @@ interface ArcData {
|
|
|
218
2173
|
innerRadius: number;
|
|
219
2174
|
}
|
|
220
2175
|
type LayoutMode = 'NONE' | 'HORIZONTAL' | 'VERTICAL' | 'GRID';
|
|
2176
|
+
/** A node's sizing along one axis; fill is stored on the child, see `layoutSizing`. */
|
|
221
2177
|
type LayoutSizing = 'FIXED' | 'HUG' | 'FILL';
|
|
2178
|
+
/** Whether an auto-layout frame keeps its size or hugs its children along one of its axes. */
|
|
2179
|
+
type AxisSizingMode = 'FIXED' | 'HUG';
|
|
222
2180
|
type GridTrackSizing = 'FIXED' | 'FR' | 'AUTO';
|
|
223
2181
|
interface GridTrack {
|
|
224
2182
|
sizing: GridTrackSizing;
|
|
@@ -239,7 +2197,6 @@ interface PluginDataEntry {
|
|
|
239
2197
|
key: string;
|
|
240
2198
|
value: string;
|
|
241
2199
|
}
|
|
242
|
-
type ExportFormatId = 'png' | 'jpg' | 'webp' | 'svg' | 'pdf';
|
|
243
2200
|
interface ExportSetting {
|
|
244
2201
|
scale: number;
|
|
245
2202
|
format: ExportFormatId;
|
|
@@ -262,12 +2219,19 @@ interface TextPathData {
|
|
|
262
2219
|
forward: boolean;
|
|
263
2220
|
}
|
|
264
2221
|
interface DerivedTextGlyph {
|
|
2222
|
+
/** UTF-16 source-text cluster start, when supplied by the shaping source. */
|
|
2223
|
+
firstCharacter?: number;
|
|
265
2224
|
commandsBlob: Uint8Array;
|
|
266
2225
|
x: number;
|
|
267
2226
|
y: number;
|
|
268
2227
|
fontSize: number;
|
|
269
2228
|
/** Figma Glyph.rotation — radians, not degrees. Zero for axis-aligned text. */
|
|
270
2229
|
rotation?: number;
|
|
2230
|
+
/**
|
|
2231
|
+
* Horizontal advance in pixels at `fontSize`, before `scaleX`, when the shaping source gave
|
|
2232
|
+
* one; where the glyph ends, so decorations stop at the text rather than the layer's edge.
|
|
2233
|
+
*/
|
|
2234
|
+
advance?: number;
|
|
271
2235
|
/**
|
|
272
2236
|
* Accumulated non-uniform resize scale (default 1). Paint order is
|
|
273
2237
|
* translate → scale(scaleX,Y) → rotate → scale(fontSize,-fontSize) so
|
|
@@ -302,6 +2266,53 @@ interface EnabledLibraryBinding {
|
|
|
302
2266
|
revisionId: string;
|
|
303
2267
|
enabled: boolean;
|
|
304
2268
|
}
|
|
2269
|
+
/** The library a document publishes as. */
|
|
2270
|
+
interface SourceLibraryPublication {
|
|
2271
|
+
libraryId: string;
|
|
2272
|
+
revisionId: string;
|
|
2273
|
+
name: string;
|
|
2274
|
+
catalogSource?: string;
|
|
2275
|
+
}
|
|
2276
|
+
/** A reply in a canvas comment thread. */
|
|
2277
|
+
interface CommentReply {
|
|
2278
|
+
id: string;
|
|
2279
|
+
author: string;
|
|
2280
|
+
/** The author's collaboration color when they wrote it, for their avatar. */
|
|
2281
|
+
authorColor?: Color;
|
|
2282
|
+
/** Markdown: bold, italic, strikethrough, links and lists. */
|
|
2283
|
+
text: string;
|
|
2284
|
+
createdAt: string;
|
|
2285
|
+
deleted?: boolean;
|
|
2286
|
+
}
|
|
2287
|
+
/** A canvas comment thread, kept in the document's root plugin data. */
|
|
2288
|
+
interface CommentThread {
|
|
2289
|
+
id: string;
|
|
2290
|
+
pageId: string;
|
|
2291
|
+
/** Page name when the pin was placed, for readers of the raw data. */
|
|
2292
|
+
pageName?: string;
|
|
2293
|
+
/** Top-level layer under the pin; the pin follows it when it moves. */
|
|
2294
|
+
nodeId?: string | null;
|
|
2295
|
+
nodeName?: string | null;
|
|
2296
|
+
/** Offset from the layer's top-left corner, in canvas units. */
|
|
2297
|
+
offsetX?: number;
|
|
2298
|
+
offsetY?: number;
|
|
2299
|
+
/** Canvas position when the pin was last saved; used when the layer is gone. */
|
|
2300
|
+
x: number;
|
|
2301
|
+
y: number;
|
|
2302
|
+
author: string;
|
|
2303
|
+
/** The author's collaboration color when they wrote it, for their avatar. */
|
|
2304
|
+
authorColor?: Color;
|
|
2305
|
+
/** Markdown: bold, italic, strikethrough, links and lists. */
|
|
2306
|
+
text: string;
|
|
2307
|
+
createdAt: string;
|
|
2308
|
+
/** Bumped on every change. */
|
|
2309
|
+
updatedAt: string;
|
|
2310
|
+
resolved: boolean;
|
|
2311
|
+
resolvedAt?: string | null;
|
|
2312
|
+
/** Deleted threads stay as tombstones so a stale copy cannot bring them back. */
|
|
2313
|
+
deleted?: boolean;
|
|
2314
|
+
replies: CommentReply[];
|
|
2315
|
+
}
|
|
305
2316
|
interface SceneNode {
|
|
306
2317
|
id: string;
|
|
307
2318
|
type: NodeType;
|
|
@@ -360,6 +2371,19 @@ interface SceneNode {
|
|
|
360
2371
|
lineHeight: number | null;
|
|
361
2372
|
letterSpacing: number;
|
|
362
2373
|
maxLines: number | null;
|
|
2374
|
+
/**
|
|
2375
|
+
* One entry per paragraph of `text`, in order. Missing entries are plain paragraphs, so text
|
|
2376
|
+
* without lists keeps this empty.
|
|
2377
|
+
*/
|
|
2378
|
+
textParagraphs: TextParagraphStyle[];
|
|
2379
|
+
/** Space after a list item followed by another; a paragraph's own value comes first. */
|
|
2380
|
+
listSpacing: number;
|
|
2381
|
+
/** Space after a paragraph other than between two list items. */
|
|
2382
|
+
paragraphSpacing: number;
|
|
2383
|
+
/** Indent of the first line of each plain paragraph. */
|
|
2384
|
+
paragraphIndent: number;
|
|
2385
|
+
/** Whether list markers hang outside the text box instead of indenting the items. */
|
|
2386
|
+
hangingList: boolean;
|
|
363
2387
|
styleRuns: StyleRun[];
|
|
364
2388
|
fontVariations: FontVariation[];
|
|
365
2389
|
fontFeatures: FontFeature[];
|
|
@@ -370,8 +2394,8 @@ interface SceneNode {
|
|
|
370
2394
|
layoutWrap: LayoutWrap;
|
|
371
2395
|
primaryAxisAlign: LayoutAlign;
|
|
372
2396
|
counterAxisAlign: LayoutCounterAlign;
|
|
373
|
-
primaryAxisSizing:
|
|
374
|
-
counterAxisSizing:
|
|
2397
|
+
primaryAxisSizing: AxisSizingMode;
|
|
2398
|
+
counterAxisSizing: AxisSizingMode;
|
|
375
2399
|
itemSpacing: number;
|
|
376
2400
|
counterAxisSpacing: number;
|
|
377
2401
|
paddingTop: number;
|
|
@@ -383,7 +2407,7 @@ interface SceneNode {
|
|
|
383
2407
|
layoutAlignSelf: LayoutAlignSelf;
|
|
384
2408
|
vectorNetwork: VectorNetwork | null;
|
|
385
2409
|
handleMirroring: HandleMirroring;
|
|
386
|
-
booleanOperation
|
|
2410
|
+
booleanOperation: 'UNION' | 'SUBTRACT' | 'INTERSECT' | 'EXCLUDE' | undefined;
|
|
387
2411
|
fillGeometry: GeometryPath[];
|
|
388
2412
|
strokeGeometry: GeometryPath[];
|
|
389
2413
|
arcData: ArcData | null;
|
|
@@ -395,11 +2419,23 @@ interface SceneNode {
|
|
|
395
2419
|
borderBottomWeight: number;
|
|
396
2420
|
borderLeftWeight: number;
|
|
397
2421
|
independentStrokeWeights: boolean;
|
|
2422
|
+
/**
|
|
2423
|
+
* The weight and alignment a node keeps for its strokes, as Figma keeps them on the node: they
|
|
2424
|
+
* last while it has no strokes, and a stroke added to it takes them. Each stroke still carries
|
|
2425
|
+
* its own `weight` and `align`, which win while the node has strokes.
|
|
2426
|
+
*/
|
|
2427
|
+
strokeWeight: number;
|
|
2428
|
+
strokeAlign: Stroke['align'];
|
|
398
2429
|
strokeMiterLimit: number;
|
|
399
2430
|
minWidth: number | null;
|
|
400
2431
|
maxWidth: number | null;
|
|
401
2432
|
minHeight: number | null;
|
|
402
2433
|
maxHeight: number | null;
|
|
2434
|
+
/**
|
|
2435
|
+
* The size whose proportions the layer keeps, as Figma stores it: the width and height it had
|
|
2436
|
+
* when the ratio was locked, not a reduced ratio. Null leaves the proportions free.
|
|
2437
|
+
*/
|
|
2438
|
+
targetAspectRatio: Vector | null;
|
|
403
2439
|
isMask: boolean;
|
|
404
2440
|
maskType: MaskType;
|
|
405
2441
|
maskIsOutline: boolean;
|
|
@@ -431,10 +2467,21 @@ interface SceneNode {
|
|
|
431
2467
|
librarySource: LibraryAssetSource | null;
|
|
432
2468
|
isPublishable: boolean;
|
|
433
2469
|
isSymbolPublishable: boolean;
|
|
2470
|
+
/**
|
|
2471
|
+
* On an instance inside a component: its properties show on instances of that component,
|
|
2472
|
+
* as Figma's `isExposedInstance`.
|
|
2473
|
+
*/
|
|
2474
|
+
isExposedInstance: boolean;
|
|
434
2475
|
symbolDescription: string;
|
|
435
2476
|
symbolLinks: SymbolLink[];
|
|
436
2477
|
variantPropSpecs: VariantPropSpec[];
|
|
437
2478
|
boundVariables: Record<string, string>;
|
|
2479
|
+
/** Multipliers from bound numeric values to this occurrence's scene units. */
|
|
2480
|
+
variableBindingScales: Partial<Record<string, number>>;
|
|
2481
|
+
/** Numeric units for new declarations owned by this node's occurrence scope. */
|
|
2482
|
+
variableAssignmentScales: Partial<Record<string, number>>;
|
|
2483
|
+
/** Explicit coordinate scale relative to the containing component definition. */
|
|
2484
|
+
componentScale: number;
|
|
438
2485
|
variableModes: VariableModeMap;
|
|
439
2486
|
exportSettings: ExportSetting[];
|
|
440
2487
|
pluginData: PluginDataEntry[];
|
|
@@ -449,12 +2496,26 @@ interface SceneNode {
|
|
|
449
2496
|
/** Node-local box that maps textPathData into the node coordinate space. */
|
|
450
2497
|
textPathBox: Rect | null;
|
|
451
2498
|
}
|
|
452
|
-
type ComponentPropertyType = 'VARIANT' | 'TEXT' | 'BOOLEAN' | 'INSTANCE_SWAP';
|
|
453
|
-
|
|
2499
|
+
type ComponentPropertyType = 'VARIANT' | 'TEXT' | 'BOOLEAN' | 'INSTANCE_SWAP' | 'SLOT';
|
|
2500
|
+
/** `SLOT_CONTENT` marks a frame whose children are the slot's content. */
|
|
2501
|
+
type ComponentPropertyReferenceField = 'VISIBLE' | 'TEXT' | 'INSTANCE_SWAP' | 'SLOT_CONTENT';
|
|
454
2502
|
interface ComponentPropertyReference {
|
|
455
2503
|
propertyId: string;
|
|
456
2504
|
field: ComponentPropertyReferenceField;
|
|
457
2505
|
}
|
|
2506
|
+
/** Guidance for a slot property; Figma reports a breach but still accepts the content. */
|
|
2507
|
+
interface SlotSettings {
|
|
2508
|
+
minChildren?: number;
|
|
2509
|
+
maxChildren?: number;
|
|
2510
|
+
allowPreferredValuesOnly: boolean;
|
|
2511
|
+
displayEmptyByDefault: boolean;
|
|
2512
|
+
/** Content added to the slot fills its counter axis. */
|
|
2513
|
+
stretchChildOnInsert: boolean;
|
|
2514
|
+
}
|
|
2515
|
+
/**
|
|
2516
|
+
* For a `SLOT` property, an instance assignment (whatever its value) means the instance owns
|
|
2517
|
+
* that slot's content: the slot frame's children in the instance, which component sync keeps.
|
|
2518
|
+
*/
|
|
458
2519
|
interface ComponentPropertyDefinition {
|
|
459
2520
|
id: string;
|
|
460
2521
|
name: string;
|
|
@@ -462,12 +2523,30 @@ interface ComponentPropertyDefinition {
|
|
|
462
2523
|
defaultValue: string;
|
|
463
2524
|
variantOptions?: string[];
|
|
464
2525
|
preferredValues?: string[];
|
|
2526
|
+
description?: string;
|
|
2527
|
+
slotSettings?: SlotSettings;
|
|
465
2528
|
}
|
|
466
2529
|
type VariableType = 'COLOR' | 'FLOAT' | 'STRING' | 'BOOLEAN';
|
|
467
2530
|
type VariableValue = Color | number | string | boolean | {
|
|
468
2531
|
aliasId: string;
|
|
469
2532
|
};
|
|
470
2533
|
type VariableModeMap = Record<string, string>;
|
|
2534
|
+
/** Property pickers a variable is offered in, as Figma names them. */
|
|
2535
|
+
declare const VARIABLE_SCOPES: readonly ["ALL_SCOPES", "TEXT_CONTENT", "CORNER_RADIUS", "WIDTH_HEIGHT", "GAP", "ALL_FILLS", "FRAME_FILL", "SHAPE_FILL", "TEXT_FILL", "STROKE", "STROKE_FLOAT", "EFFECT_FLOAT", "EFFECT_COLOR", "OPACITY", "FONT_STYLE", "FONT_FAMILY", "FONT_SIZE", "LINE_HEIGHT", "LETTER_SPACING", "PARAGRAPH_SPACING", "PARAGRAPH_INDENT", "FONT_VARIATIONS", "TRANSFORM"];
|
|
2536
|
+
type VariableScope = (typeof VARIABLE_SCOPES)[number];
|
|
2537
|
+
declare const CODE_SYNTAX_PLATFORMS: readonly ["WEB", "ANDROID", "iOS"];
|
|
2538
|
+
type CodeSyntaxPlatform = (typeof CODE_SYNTAX_PLATFORMS)[number];
|
|
2539
|
+
/**
|
|
2540
|
+
* The CSS unit a numeric token is written in. Lengths (`px`, `rem`) stay in canvas pixels in
|
|
2541
|
+
* the document and convert only when written as CSS; the other units store the number as written.
|
|
2542
|
+
*/
|
|
2543
|
+
declare const TOKEN_UNITS: readonly ["none", "px", "rem", "%", "ms", "s", "deg"];
|
|
2544
|
+
type TokenUnit = (typeof TOKEN_UNITS)[number];
|
|
2545
|
+
/** A mode value authored as raw CSS. `resolved` is the number the canvas drew for it. */
|
|
2546
|
+
interface TokenExpression {
|
|
2547
|
+
css: string;
|
|
2548
|
+
resolved: number;
|
|
2549
|
+
}
|
|
471
2550
|
interface Variable {
|
|
472
2551
|
id: string;
|
|
473
2552
|
name: string;
|
|
@@ -476,6 +2555,18 @@ interface Variable {
|
|
|
476
2555
|
valuesByMode: Record<string, VariableValue>;
|
|
477
2556
|
description: string;
|
|
478
2557
|
hiddenFromPublishing: boolean;
|
|
2558
|
+
/** Absent means every scope. */
|
|
2559
|
+
scopes?: VariableScope[];
|
|
2560
|
+
/**
|
|
2561
|
+
* Per-platform code snippets, as Figma's Dev Mode shows them. A `WEB` snippet of `--x` or
|
|
2562
|
+
* `var(--x)` names the token's CSS custom property; otherwise the name is derived.
|
|
2563
|
+
*/
|
|
2564
|
+
codeSyntax?: Partial<Record<CodeSyntaxPlatform, string>>;
|
|
2565
|
+
/** FLOAT only. Absent means inferred when written as CSS. */
|
|
2566
|
+
unit?: TokenUnit;
|
|
2567
|
+
/** Raw CSS by mode id, for values a number cannot express (`clamp()`, `calc()`). */
|
|
2568
|
+
expressions?: Record<string, TokenExpression>;
|
|
2569
|
+
pluginData?: PluginDataEntry[];
|
|
479
2570
|
/** Published library key (from NodeChange.key). Used for assetRef resolution in colorVar. */
|
|
480
2571
|
key?: string;
|
|
481
2572
|
/** Published library version (from NodeChange.version). Used for assetRef resolution in colorVar. */
|
|
@@ -486,14 +2577,29 @@ type NumericNodeProperty = { [K in keyof SceneNode]-?: SceneNode[K] extends numb
|
|
|
486
2577
|
interface VariableCollectionMode {
|
|
487
2578
|
modeId: string;
|
|
488
2579
|
name: string;
|
|
2580
|
+
/**
|
|
2581
|
+
* Where the mode applies in CSS: a selector (`[data-theme="dark"]`, `.compact`) or an
|
|
2582
|
+
* at-rule prelude (`@media (max-width: 640px)`). Absent means the default for its axis.
|
|
2583
|
+
*/
|
|
2584
|
+
condition?: string;
|
|
489
2585
|
}
|
|
490
2586
|
interface VariableCollection {
|
|
491
2587
|
id: string;
|
|
492
2588
|
name: string;
|
|
2589
|
+
/** The default mode comes first, as in Figma. */
|
|
493
2590
|
modes: VariableCollectionMode[];
|
|
494
2591
|
defaultModeId: string;
|
|
495
2592
|
variableIds: string[];
|
|
2593
|
+
/**
|
|
2594
|
+
* The attribute that switches a mode with no condition of its own, `data-theme` for
|
|
2595
|
+
* `[data-theme="dark"]`. Absent means one named after the collection.
|
|
2596
|
+
*/
|
|
2597
|
+
modeAttribute?: string;
|
|
2598
|
+
pluginData?: PluginDataEntry[];
|
|
496
2599
|
}
|
|
2600
|
+
/** An HTML attribute name a stylesheet can select on unescaped: `data-theme`, `theme`. */
|
|
2601
|
+
declare const MODE_ATTRIBUTE_PATTERN: RegExp;
|
|
2602
|
+
declare function isModeAttributeName(name: string): boolean;
|
|
497
2603
|
//#endregion
|
|
498
|
-
export { ArcData, BlendMode, CharacterStyleOverride, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConstraintType, DerivedTextGlyph, DocumentColorSpace, Effect, EnabledLibraryBinding, ExportFormatId, ExportSetting, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, ImageScaleMode, InstanceOverrideField, InstanceOverrideState, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MaskType, NodeType, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, SerializedInstanceOverrideState, SerializedOverrideValue, SharedStyle, SharedStyleKind, SharedStyleType, SourceMetadata, Stroke, StrokeCap, StrokeJoin, StyleRun, SymbolLink, TextAlignVertical, TextAutoResize, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextPathData, Variable, VariableCollection, VariableCollectionMode, VariableModeMap, VariableType, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule, clearInstanceOverrides, cloneInstanceOverrideState, createInstanceOverrideState, deleteInstanceOverride, deserializeInstanceOverrideState, forEachInstanceOverride, getInstanceOverride, serializeInstanceOverrideState, setInstanceOverride };
|
|
2604
|
+
export { AUTO_LAYOUT_GRID_COUNT, ArcData, AutoLayoutDirection, AxisSizingMode, BEHAVIOUR_CONTRACTS, BEHAVIOUR_KINDS, Behaviour, BehaviourBooleanBinding, BehaviourContract, BehaviourInteractionStates, BehaviourKind, BehaviourNumberSettings, BehaviourPartContract, BehaviourSpec, BehaviourValueContract, BehaviourValueType, BindingScope, BlendMode, CODE_SYNTAX_PLATFORMS, COMMENT_SORTS, CONTAINER_TYPES, CanvasGuide, CharacterStyleOverride, CodeSyntaxPlatform, CollectedSceneMutation, CommentAuthor, CommentListOptions, CommentReply, CommentSort, CommentThread, CommittedGraphEventError, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyTarget, ComponentPropertyType, ConstraintType, DEFAULT_NUMBER_SETTINGS, DEFAULT_SLOT_SETTINGS, DerivedTextGlyph, DocumentColorSpace, DropTargetOptions, EXPORT_FORMAT_IDS, Effect, EnabledLibraryBinding, ExportFormatId, ExportSetting, FITTED_CONTAINER_TYPES, FONT_WEIGHT_NAMES, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFamilyStyle, FontFeature, FontVariation, GeometryPath, GradientStop, GradientTransform, GraphTransferInput, GraphTransferPlan, GridPosition, GridTrack, GridTrackSizing, GroupFit, GroupFitOptions, HandleMirroring, HyperlinkTarget, ICON_NAME, ICON_PAINTS, INSTANCE_FOLLOWED_FIELDS, INSTANCE_OVERRIDE_FIELDS, INSTANCE_SYNC_FIELDS, INSTANCE_SYNC_PROPS, INSTANCE_SYNC_TEXT_PROPS, INTERACTION_STATES, Icon, IconPaint, ImageScaleMode, InstanceExposureIssue, InstanceOverrideField, InstanceOverrideReferenceMapper, InstanceOverrideState, InteractionState, LIST_BULLET, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutGuideLine, LayoutGuideSection, LayoutMode, LayoutSizing, LayoutSizingAxis, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, ListNumberFormat, MAX_EXPORT_SCALE, MAX_LIST_INDENTATION, MIN_EXPORT_SCALE, MODE_ATTRIBUTE_PATTERN, MaskType, MutationImpactListener, NodeChangeObserver, NodeCloneMode, NodePreviewObserver, NodeTransferReferences, NodeType, NoiseType, NormalizableVectorNetwork, NumericNodeProperty, OPEN_PENCIL_PLUGIN_DATA, OPEN_PENCIL_PLUGIN_ID, OkHCLColor, OkHCLColorSpace, OkHCLPayload, PLAIN_PARAGRAPH, ParkedSlotContent, ParsedFontStyle, PatternAlignment, PatternTileType, PluginDataEntry, PluginDataField, PluginDataKey, PluginDataRole, PluginRelaunchDataEntry, ROOT_FONT_SIZE_PX, SHARED_TEXT_STYLE_FIELDS, SIZE_FIELDS, SceneGraph, SceneGraphEventHandlers, SceneGraphEvents, SceneMutationImpact, SceneNode, SerializedInstanceOverrideState, SerializedOverrideValue, ShaderComponent, ShaderPaint, ShaderPreset, SharedStyle, SharedStyleKind, SharedStyleType, SlotLimitViolation, SlotPropertyPatch, SlotScope, SlotSettings, SnapGuide, SnapResult, SourceLibraryPublication, SourceMetadata, StoredToken, Stroke, StrokeCap, StrokeJoin, StyleRun, StyleRunReferences, SwapInstanceOptions, SymbolLink, TEXT_BINDABLE_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_PARAGRAPH_SPACING_FIELDS, TEXT_SHAPING_FIELDS, TOKEN_UNITS, TRANSFORM_FIELDS, TextAlignVertical, TextAutoResize, TextBindableField, TextBoundVariables, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextListItem, TextListType, TextParagraphRange, TextParagraphSpacingField, TextParagraphStyle, TextPathData, TokenExpression, TokenUnit, VARIABLE_SCOPES, Variable, VariableCollection, VariableCollectionMode, VariableModeFallback, VariableModeMap, VariableScope, VariableTransferReferences, VariableType, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, VisualBounds, VisualBoundsNode, WindingRule, addCollection, addMode, addVariable, applyComponentPropertyValue, applyGraphTransfer, aspectRatioLockEditable, assignVariableBindingUnits, autoLayoutSizingFields, behaviourContract, behaviourFromSpec, behaviourOwner, behaviourProperties, behaviourSpecSchema, behaviourToSpec, bindVariable, booleanBinding, byCreatedAt, canCreateInstance, canCreateSlot, captureGraphCheckpoint, captureTransferredState, claimSlotContent, clampExportScale, clearInstanceOverrides, clearNodeFillOkHCL, clearNodeStrokeOkHCL, clearSlotContent, clipBoundsToPolygon, clipPolygon, cloneInstanceOverrideState, cloneNodeProps, cloneVectorNetwork, collectSceneMutation, commentAnchor, commentPosition, commentThreadNumbers, commentTimestamp, compareCanvasPosition, componentPropertyDefinitions, componentPropertyOwners, computeAbsoluteBounds, computeBounds, computeDescendantVisualBounds, computeSelectionBounds, computeSnap, computeVisualBounds, contentPluginData, copyDerivedGlyphs, copyEffect, copyEffects, copyFill, copyFills, copyGeometryPaths, copyInstanceComponentProps, copyLayoutGrids, copyStroke, copyStrokes, copyStyleRun, copyStyleRuns, createCollection, createCommentReply, createCommentThread, createComponentPropertyId, createDefaultNode, createDefaultSourceMetadata, createInstance, createInstanceOverrideState, createMode, createSceneMutationImpact, createShaderPaint, createSlotProperty, createVariable, createsComponentCycle, cycleSafeParent, defaultStrokeAlign, defaultVariant, degToRad, deleteCommentReply, deleteCommentThread, deleteInstanceOverride, deserializeInstanceOverrideState, detachInstance, detachOwnedSlotContent, editCommentThread, effectOverflow, emptyBehaviour, enforcedAspectRatio, exposableInstances, exposedInstances, fillSizingFields, findComponentPropertyTarget, findComponentPropertyTargets, findInstanceAncestor, findLayerByPath, findLiveCommentThread, fitEnclosingGroups, forEachInstanceOverride, formatListNumber, generateId, geometryBlobBounds, geometryCommandCoordCount, getAbsolutePosition, getAbsolutePositionFull, getAbsoluteRotation, getActiveModeId, getAxisAlignedBoundsInParent, getAxisAlignedWorldBounds, getFillOkHCL, getInstanceOverride, getInstances, getMainComponent, getNodeLocalMatrix, getNodeOkHCLPayloads, getNodeRotationOrigin, getNodeVariableModeId, getNodeWorldBounds, getParentToContainerMatrix, getParentWorldMatrix, getSharedStyles, getStrokeOkHCL, getVariablesByType, getVariablesForCollection, getWorldHandles, getWorldMatrix, guessInteractionStates, guessOnOff, guideOwnersOnPage, hasBehaviour, hasInstanceOverride, hasNewerComments, hasParagraphSpacing, hasPluginData, hasSameCopySource, hasShaderPaint, hasTextList, hitTest, hitTestDeep, hitTestDropTarget, hitTestOpenContainer, hitTestSelectable, iconGlyph, iconLayerName, iconNames, iconSchema, iconTintSchema, instanceExposureIssue, instanceMainComponent, instanceSlotFrames, intersectVisualBounds, isAutoGridCount, isExportFormatId, isIconModified, isModeAttributeName, isNumberRange, isNumericVariableBindingField, isOpenContainer, isPlacedIconName, isPluginDataEntry, isPointInNode, isPreferredComponent, isShaderFrameCurrent, isTranslationOnly, isValidExportScale, jsonPluginDataField, layerPath, layoutGridCount, layoutGuideLines, layoutGuideSections, layoutSizing, layoutSizingError, layoutSizingInParent, layoutSizingOptions, layoutSizingUpdates, listCommentThreads, listNumberFormat, liveReplies, localTransformFromWorld, lockedAspectRatioTarget, markCopySource, mergeCommentThreads, mergeVectorNetworks, missingBindings, modesDefaultFirst, mutationLayoutScopeIds, newStrokeGeometry, nodeVisualBounds, nonPreferredLayers, normalizeFontFamily, normalizeFontStyleName, normalizeVectorNetwork, numberSettings, okhclToRGBA, ownsSlotContent, paddingFromShorthand, paragraphCount, paragraphIndexAt, paragraphSpacingAt, paragraphStyleAt, paragraphStylesAfterEdit, paragraphStylesAfterTextChange, paragraphStylesInRange, paragraphStylesWithoutSpacing, parseAutoLayoutDirection, parseCounterAxisAlign, parseFontStyle, parseLayoutAlignSelf, parseOkHCLPayload, parsePrimaryAxisAlign, partBinding, pluginDataEntry, polygonVertices, populateInstanceChildren, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, radToDeg, readAllPluginData, readBehaviour, readComments, readIcon, readIconTint, readPluginData, readShaderPaints, recapturedAspectRatio, reconcileVariableBindings, recordInstanceOverride, recordSceneMutations, redoGroupFit, remapInstanceOverrideState, remapStyleRunReferences, removeCollection, removeComponentProperty, removeGraphTransfer, removeMode, removeVariable, renameBehaviourProperties, renameMode, replyToCommentThread, rescaleNodeTree, resetSlotContent, resolveColorVariable, resolveColorVariableForNode, resolveCommentThread, resolveComponentPropertyValue, resolveNumberVariable, resolveNumberVariableForNode, resolveStringVariableForNode, resolveVariable, resolveVariableForNode, resolvedNumericBindings, resolvedPaintBindings, resolvedRunBindings, resolvedValueBindings, restingVariant, restoreOwnedSlotContent, rgbaToOkHCL, rotatePoint, rotatedBBox, rotatedCorners, scaleGeometryPaths, scaleNodeChanges, serializeInstanceOverrideState, serializeOkHCLPayload, setActiveMode, setDefaultMode, setIdSession, setInstanceOverride, setNodeFillOkHCL, setNodeStrokeOkHCL, shaderOfPaint, shaderPaintSchema, shaderPresetKey, shaderPresetSchema, sharedParagraphSpacing, sharedStyleRefKey, sharedStyleTypeForKind, sizeKeepingAspectRatio, slotLimitViolations, slotOwner, slotPropertyId, slotScope, strokeOverflow, styleDetachmentChanges, styleRunReferences, styleToVariant, styleToWeight, swapInstanceComponent, syncInstance, syncInstances, syncInstancesTogether, takesPartInThread, textAutoResizeFor, textBinding, textListItems, textParagraphRanges, textPluginDataField, tokenNumberFromUnit, tokenNumberInUnit, topLevelNumberDigits, transformGeometryBlob, transformGeometryPaths, transformVectorNetwork, trimParagraphStyles, unbindVariable, undoGroupFit, unionVisualBounds, updateNodePreview, updateSlotProperty, validateVectorNetwork, variableBindingOwner, variablesResolvingThrough, variantDefaultValue, vectorNetworksEqual, weightToStyle, withAllPluginData, withBehaviour, withIcon, withIconTint, withIndentation, withListType, withLiveComments, withParagraphSpacing, withPluginData, withShaderPaints, withoutPluginData, writeComments };
|
|
499
2605
|
//# sourceMappingURL=types.d.ts.map
|