openpencil/packages/core/src/index.ts
Danila Poyarkov d7e2015967 Estimate text width for WIDTH_AND_HEIGHT auto-resize in layout
Text nodes with textAutoResize=WIDTH_AND_HEIGHT now use an estimated
content width instead of the node's current width when computing
auto-layout. Fixes month headers (and similar centered text in
auto-layout) appearing left-aligned after paste.
2026-03-04 00:11:48 +03:00

180 lines
4 KiB
TypeScript

export type { GUID, Color, Vector, Matrix, Rect } from './types'
export * from './constants'
export {
SceneGraph,
generateId,
type SceneNode,
type NodeType,
type Fill,
type FillType,
type Stroke,
type StrokeCap,
type StrokeJoin,
type MaskType,
type Effect,
type BlendMode,
type ImageScaleMode,
type GradientStop,
type GradientTransform,
type LayoutMode,
type LayoutSizing,
type LayoutAlign,
type LayoutCounterAlign,
type LayoutWrap,
type ConstraintType,
type TextAutoResize,
type TextAlignVertical,
type TextCase,
type TextDecoration,
type ArcData,
type VectorNetwork,
type VectorVertex,
type VectorSegment,
type VectorRegion,
type HandleMirroring,
type WindingRule,
type VariableType,
type VariableValue,
type Variable,
type VariableCollection,
type VariableCollectionMode,
type CharacterStyleOverride,
type StyleRun
} from './scene-graph'
export { FigmaAPI, FigmaNodeProxy, type FigmaFontName } from './figma-api'
export { ALL_TOOLS, defineTool, toolsToAI } from './tools'
export type { ToolDef, ParamDef, ParamType } from './tools'
export { SkiaRenderer, type RenderOverlays } from './renderer'
export { computeLayout, computeAllLayouts, setTextMeasurer } from './layout'
export type { TextMeasurer } from './layout'
export { getCanvasKit, getGpuBackend, type CanvasKitOptions, type GpuBackend } from './canvaskit'
export {
loadFont,
listFamilies,
initFontService,
getFontProvider,
isFontLoaded,
ensureNodeFont,
styleToWeight,
weightToStyle
} from './fonts'
export { parseColor, colorToHex, colorToHexRaw, colorToRgba255 } from './color'
export {
vectorNetworkToPath,
decodeVectorNetworkBlob,
encodeVectorNetworkBlob,
computeVectorBounds
} from './vector'
export { computeSelectionBounds, computeSnap, type SnapGuide } from './snap'
export { UndoManager } from './undo'
export { TextEditor, type TextCaret, type TextEditorState } from './text-editor'
export {
toggleBoldInRange,
toggleItalicInRange,
toggleDecorationInRange,
adjustRunsForInsert,
adjustRunsForDelete
} from './style-runs'
export { renderNodesToImage, renderThumbnail, type ExportFormat } from './render-image'
export { exportFigFile } from './fig-export'
export {
FIG_KIWI_VERSION,
buildFigKiwi,
parseFigKiwiChunks,
decompressFigKiwiData,
decompressFigKiwiDataAsync,
sceneNodeToKiwi,
fractionalPosition,
mapToFigmaType
} from './kiwi-serialize'
export {
renderTree,
renderJsx,
renderTreeNode,
buildComponent,
Frame,
Text,
Rectangle,
Ellipse,
Line,
Star,
Polygon,
Vector as VectorNode,
Group,
Section,
View,
Rect as RectNode,
Component as ComponentNode,
Instance as InstanceNode,
Page as PageNode,
INTRINSIC_ELEMENTS,
isTreeNode,
node,
type TreeNode,
type BaseProps,
type TextProps,
type StyleProps,
type RenderResult,
sceneNodeToJsx,
selectionToJsx
} from './render'
export {
parseFigmaClipboard,
importClipboardNodes,
figmaNodesBounds,
parseOpenPencilClipboard,
buildFigmaClipboardHTML,
buildOpenPencilClipboardHTML,
prefetchFigmaSchema,
type TextPictureBuilder
} from './clipboard'
export { readFigFile, parseFigFile } from './kiwi/fig-file'
export { importNodeChanges } from './kiwi/fig-import'
export {
initCodec,
encodeMessage,
decodeMessage,
compress,
decompress,
getCompiledSchema,
getSchemaBytes,
createNodeChangesMessage,
createNodeChange,
parseVariableId,
encodePaintWithVariableBinding,
encodeNodeChangeWithVariables,
type NodeChange,
type GUID as KiwiGUID,
type Color as KiwiColor,
type Paint as KiwiPaint,
type Effect as KiwiEffect,
type VariableBinding,
type ParentIndex,
type FigmaMessage
} from './kiwi/codec'
export {
MESSAGE_TYPES,
NODE_TYPES,
NODE_PHASES,
BLEND_MODES,
PAINT_TYPES,
PROTOCOL_VERSION,
KIWI,
SESSION_ID,
ZSTD_MAGIC,
buildMultiplayerUrl,
isZstdCompressed,
hasFigWireHeader,
skipFigWireHeader,
isKiwiMessage,
getKiwiMessageType,
parseVarint,
FIG_WIRE_MAGIC
} from './kiwi/protocol'