openpencil/packages/core/src/index.ts
Danila Poyarkov d1159a7d07
refactor(kiwi)!: drop the colorVariableBinding paint field
`fig.kiwi` never defined the field, so nothing Figma writes carries one
and nothing OpenPencil writes has since `colorVar` replaced it. What
remained were readers kept so that files written by earlier OpenPencil
builds still restored their bindings — a compatibility path the project
does not keep before 1.0.

The field, the `VariableBinding` type and both readers are gone.
Reopening one of those files leaves the paint's colour unbound; binding
it again records it the way Figma does.
2026-10-01 23:47:51 +04:00

376 lines
8.5 KiB
TypeScript

export { CODEGEN_PROMPT } from './tools/prompts'
export { randomHex, randomInt, randomIndex } from './random'
export * from './constants'
export { createDefaultEditorState, createEditor, EDITOR_TOOLS, TOOL_SHORTCUTS } from './editor'
export type {
ClipboardImageResolution,
Editor,
EditorContext,
EditorOptions,
EditorState,
EditorToolDef,
FigmaClipboardImageResolver,
Tool
} from './editor'
export {
SceneGraph,
generateId,
cloneVectorNetwork,
normalizeVectorNetwork,
validateVectorNetwork,
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 LayoutAlignSelf,
type LayoutCounterAlign,
type LayoutWrap,
type GridTrack,
type GridTrackSizing,
type GridPosition,
type ConstraintType,
type TextAutoResize,
type TextDirection,
type TextAlignVertical,
type TextCase,
type TextDecoration,
type LayoutDirection,
type ArcData,
type VectorNetwork,
type VectorVertex,
type VectorSegment,
type VectorRegion,
type GeometryPath,
type HandleMirroring,
type WindingRule,
type VariableType,
type VariableValue,
type Variable,
type VariableCollection,
type VariableCollectionMode,
type CharacterStyleOverride,
type StyleRun,
type SceneGraphEvents,
type DocumentColorSpace
} from '@open-pencil/scene-graph'
export { FigmaAPI, FigmaNodeProxy, computeImageHash, type FigmaFontName } from './figma-api'
export {
ALL_TOOLS,
CORE_TOOLS,
EXTENDED_TOOLS,
defineTool,
toolsToAI,
buildDebugLog,
requireNode,
NodeNotFoundError,
calcClusterConfidence
} from './tools'
export type {
ToolDef,
ToolExecution,
ToolCapability,
ToolLogEntry,
ToolDebugLog,
AIAdapterOptions,
StepBudget
} from './tools'
export { executeRPCCommand, ALL_RPC_COMMANDS } from './rpc'
export { queryByXPath, matchByXPath, nodeToXPath } from './xpath'
export type { XPathQueryOptions } from './xpath'
export {
okhclToRGBA,
rgbaToOkHCL,
serializeOkHCLPayload,
parseOkHCLPayload,
setNodeFillOkHCL,
setNodeStrokeOkHCL,
clearNodeFillOkHCL,
clearNodeStrokeOkHCL,
getNodeOkHCLPayloads,
getFillOkHCL,
getStrokeOkHCL,
type OkHCLColor,
type OkHCLPayload
} from '@open-pencil/scene-graph/color'
export type {
InfoResult,
PageItem,
TreeArgs,
TreeResult,
TreeNodeResult,
FindArgs,
FindNodeResult,
QueryArgs,
QueryNodeResult,
NodeArgs,
NodeResult,
VariablesArgs,
VariablesResult,
AnalyzeColorsArgs,
AnalyzeColorsResult,
AnalyzeTypographyArgs,
AnalyzeTypographyResult,
AnalyzeSpacingResult,
SpacingValue,
AnalyzeClustersArgs,
AnalyzeClustersResult,
TypographyStyle
} from './rpc'
export { SkiaRenderer, type RenderOverlays } from './canvas'
export { LabelCache, type CachedSection, type CachedComponent } from './canvas/labels/cache'
export {
RenderProfiler,
FrameStats,
GPUTimer,
DrawCallCounter,
PhaseTimer,
CaptureStack,
toSpeedscopeJSON
} from './profiler'
export type { FrameCapture, NodeProfile } from './profiler'
export { computeLayout, computeAllLayouts, setTextMeasurer } from './layout'
export type { TextMeasurer } from './layout'
export { getCanvasKit, type CanvasKitOptions } from './canvaskit'
export {
detectTextDirection,
resolveTextDirection,
resolveNodeTextDirection,
resolveNodeLayoutDirection,
isLogicalTextAlignStart,
isLogicalTextAlignEnd
} from '@open-pencil/scene-graph/text-direction'
export {
FONT_WEIGHT_NAMES,
FontManager,
chooseLocalFontMatch,
fontManager,
styleToWeight,
weightToFigmaStyle,
weightToStyle,
normalizeFontFamily,
isVariableFont,
styleToVariant,
type DownloadedFontCache,
type FontInfo,
type FontLoadedSource,
type LocalFontAccessState
} from './text/fonts'
export {
documentFontStatus,
type DocumentFontFaceStatus,
type DocumentFontStatus,
type FontFaceStatus
} from './text/font/status'
export {
fontFaceFromFigmaFontName,
fontFaceRenderFamily,
normalizeFontStyleName,
parseFontStyle,
type FontFaceRef,
type ParsedFontStyle
} from './text/face'
export {
ARABIC_LOCAL_FALLBACK_FAMILIES,
ARABIC_REMOTE_FALLBACK_FAMILIES,
cjkLocalFallbackFamilies,
fontFallbackEntry,
fontFallbackManifest,
type FontFallbackManifestEntry,
type FontFallbackScript
} from './text/fallbacks'
export {
parseColor,
normalizeColor,
colorToHex,
colorToHex8,
colorToHexRaw,
colorToRgba255,
colorToCSS,
colorToCSSCompact,
rgba255ToColor,
colorToFill,
colorDistance
} from '@open-pencil/scene-graph/color'
export {
resolveOkHCLForPreview,
resolveRGBAForPreview,
resolveNodeFillColor,
resolveNodeStrokeColor,
colorToDisplayCSS,
getDefaultRenderColorSpace,
type RenderColorSpace,
type ColorIntentSpace,
type ColorPreviewOptions,
type ResolvedRenderColor
} from '@open-pencil/scene-graph/color'
export {
vectorNetworkToPath,
geometryBlobToPath,
decodeVectorNetworkBlob,
encodeVectorNetworkBlob,
buildStyleOverrideTable,
regenerateFillGeometry
} from './vector'
export {
evalCubic,
splitCubicAt,
segmentToAbsolute,
isLineSegment,
cubicExtrema,
computeAccurateBounds,
nearestPointOnCubic,
nearestPointOnNetwork,
splitSegmentAt,
removeVertex,
breakAtVertex,
deleteVertex,
mirrorHandle,
findOppositeHandle,
findAllHandles,
findConnectedComponents,
extractSubNetwork,
type CubicPoints,
type NearestResult,
type NetworkNearestResult
} from './vector/bezier'
export { computeSelectionBounds, computeSnap, type SnapGuide } from '@open-pencil/scene-graph/snap'
export { UndoManager, type UndoEntry, type UndoManagerOptions } from '@open-pencil/scene-graph/undo'
export { TextEditor, type TextCaret, type TextEditorState } from './text/editor'
export {
getStyleAt,
applyStyleToRange,
removeStyleFromRange,
selectionHasStyle,
toggleBoldInRange,
toggleItalicInRange,
toggleDecorationInRange,
adjustRunsForInsert,
adjustRunsForDelete
} from './text/style-runs'
export {
renderNodesToImage,
renderThumbnail,
computeContentBounds,
initCanvasKit,
headlessRenderNodes,
headlessRenderThumbnail,
type RasterExportFormat,
type ExportFormat
} from './io/formats/raster'
export {
renderNodesToSVG,
geometryBlobToSVGPath,
vectorNetworkToSVGPaths,
type SVGExportOptions
} from './io/formats/svg/export'
export { svg, renderSVGNode, type SVGNode } from './io/formats/svg/node'
export { parseSVGPath } from '@open-pencil/scene-graph/parse-path'
export {
fetchIcon,
fetchIcons,
searchIcons,
searchIconsBatch,
clearIconCache,
type IconData,
type IconPath,
type IconSearchResult
} from './icons'
export { exportFigFile, compressFigData, compressFigDataSync } from './io/formats/fig/export'
export {
FIG_KIWI_DEFAULT_VERSION,
buildFigKiwi,
parseFigKiwiChunks,
decompressFigKiwiDataAsync,
buildFontDigestMap,
sceneNodeToKiwi,
fractionalPosition,
mapToFigmaType
} from './kiwi/fig/node-change/serialize'
export { buildDerivedTextDataV4 } from './text/derived-text/clipboard'
export { renderJSX, renderTree } from './design-jsx'
export {
parseFigmaClipboard,
importClipboardNodes,
figmaNodesBounds,
parseOpenPencilClipboard,
buildFigmaClipboardHTML,
buildOpenPencilClipboardHTML,
prefetchFigmaSchema,
type TextPictureBuilder,
type OpenPencilClipboardData
} from './clipboard'
export { probeGlyphOutlineCommands, type GlyphOutlineProbe } from './text/opentype'
export { readPenFile, parsePenFile } from '@open-pencil/pen'
export {
readFigFile,
parseFigFile,
initCodec,
encodeMessage,
decodeMessage,
compress,
decompress,
getCompiledSchema,
getSchemaBytes,
isCodecReady,
peekMessageType,
createNodeChangesMessage,
createNodeChange,
parseVariableId,
type NodeChange,
type GUID as KiwiGUID,
type Color as KiwiColor,
type Paint as KiwiPaint,
type Effect as KiwiEffect,
type ParentIndex,
type FigmaMessage,
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'
export * from './io'
export * from './lint'
export {
setPexelsAPIKey,
setUnsplashAccessKey,
registerStockPhotoProvider,
setActiveStockPhotoProvider,
getStockPhotoProviders
} from './tools/stock-photo'
export type { StockPhotoProvider, StockPhotoResult } from './tools/stock-photo'