AI-native design editor. Open-source Figma alternative.
Deduplicate kiwi and serialization code
Danila Poyarkovf92a8835f466
diff --git a/packages/core/src/clipboard.ts b/packages/core/src/clipboard.tsindex abf68f769..598cd30af 100644--- a/packages/core/src/clipboard.ts+++ b/packages/core/src/clipboard.ts@@ -2,8 +2,9 @@ import { inflateSync, deflateSync } from 'fflate'import { initCodec, getCompiledSchema, getSchemaBytes } from './kiwi/codec'import { decodeBinarySchema, compileSchema, ByteBuffer } from './kiwi/kiwi-schema'+import { sceneNodeToKiwi } from './kiwi-serialize'-import { decodeVectorNetworkBlob, encodeVectorNetworkBlob } from './vector'+import { decodeVectorNetworkBlob } from './vector'import type {SceneGraph,@@ -385,167 +386,6 @@ function mapNodeType(type?: string): SceneNode['type'] {}}-// --- Copy to Figma-compatible fig-kiwi -----function mapToFigmaType(type: SceneNode['type']): string {- switch (type) {- case 'FRAME':- return 'FRAME'- case 'RECTANGLE':- return 'RECTANGLE'- case 'ELLIPSE':- return 'ELLIPSE'- case 'TEXT':- return 'TEXT'- case 'LINE':- return 'LINE'- case 'STAR':- return 'STAR'- case 'POLYGON':- return 'REGULAR_POLYGON'- case 'VECTOR':- return 'VECTOR'- case 'GROUP':- return 'FRAME'- case 'SECTION':- return 'SECTION'- default:- return 'RECTANGLE'- }-}--function fractionalPosition(index: number): string {- const base = '!'- return String.fromCharCode(base.charCodeAt(0) + index)-}--function sceneNodeToKiwi(- node: SceneNode,- parentGuid: { sessionID: number; localID: number },- childIndex: number,- localIdCounter: { value: number },- graph: SceneGraph,- blobs: Uint8Array[]-): KiwiNodeChange[] {- const localID = localIdCounter.value++- const guid = { sessionID: 1, localID }- const cos = Math.cos((node.rotation * Math.PI) / 180)- const sin = Math.sin((node.rotation * Math.PI) / 180)-- const fillPaints = node.fills- .filter((f) => f.type === 'SOLID')- .map((f) => ({- type: 'SOLID' as const,- color: f.color,- opacity: f.opacity,- visible: f.visible,- blendMode: 'NORMAL' as const- }))-- const strokePaints = node.strokes- .filter((s) => s.visible)- .map((s) => ({- type: 'SOLID' as const,- color: s.color,- opacity: s.opacity,- visible: true,- blendMode: 'NORMAL' as const- }))-- const nc: KiwiNodeChange = {- guid,- parentIndex: { guid: parentGuid, position: fractionalPosition(childIndex) },- type: mapToFigmaType(node.type),- name: node.name,- visible: node.visible,- opacity: node.opacity,- phase: 'CREATED',- size: { x: node.width, y: node.height },- transform: { m00: cos, m01: -sin, m02: node.x, m10: sin, m11: cos, m12: node.y },- strokeWeight: node.strokes.length > 0 ? node.strokes[0].weight : 1,- strokeAlign: 'INSIDE'- }-- if (fillPaints.length > 0) nc.fillPaints = fillPaints- if (strokePaints.length > 0) nc.strokePaints = strokePaints-- if (node.cornerRadius > 0) {- nc.cornerRadius = node.cornerRadius- nc.rectangleTopLeftCornerRadius = node.independentCorners- ? node.topLeftRadius- : node.cornerRadius- nc.rectangleTopRightCornerRadius = node.independentCorners- ? node.topRightRadius- : node.cornerRadius- nc.rectangleBottomLeftCornerRadius = node.independentCorners- ? node.bottomLeftRadius- : node.cornerRadius- nc.rectangleBottomRightCornerRadius = node.independentCorners- ? node.bottomRightRadius- : node.cornerRadius- }-- if (node.type === 'TEXT') {- nc.fontSize = node.fontSize- nc.fontName = { family: node.fontFamily, style: 'Regular', postscript: '' }- nc.textData = {- characters: node.text,- lines: [- {- lineType: 'PLAIN',- styleId: 0,- indentationLevel: 0,- sourceDirectionality: 'AUTO',- listStartOffset: 0,- isFirstLineOfList: false- }- ]- }- nc.textAutoResize = 'WIDTH_AND_HEIGHT'- nc.textAlignHorizontal = node.textAlignHorizontal- }-- if (node.type === 'FRAME' || node.type === 'GROUP') {- nc.frameMaskDisabled = node.type === 'GROUP'- }-- if (node.layoutMode !== 'NONE') {- nc.stackMode = node.layoutMode- nc.stackSpacing = node.itemSpacing- nc.stackVerticalPadding = node.paddingTop- nc.stackHorizontalPadding = node.paddingLeft- nc.stackPaddingBottom = node.paddingBottom- nc.stackPaddingRight = node.paddingRight- nc.stackPrimarySizing = node.primaryAxisSizing === 'HUG' ? 'RESIZE_TO_FIT' : 'FIXED'- nc.stackCounterSizing =- node.counterAxisSizing === 'HUG' ? 'RESIZE_TO_FIT_WITH_IMPLICIT_SIZE' : undefined- }-- if (node.layoutPositioning === 'ABSOLUTE') {- nc.stackPositioning = 'ABSOLUTE'- }- if (node.layoutGrow > 0) {- nc.stackChildPrimaryGrow = node.layoutGrow- }-- if (node.vectorNetwork && node.type === 'VECTOR') {- const blobIdx = blobs.length- blobs.push(encodeVectorNetworkBlob(node.vectorNetwork))- nc.vectorData = {- vectorNetworkBlob: blobIdx,- normalizedSize: { x: node.width, y: node.height }- }- }-- const result: KiwiNodeChange[] = [nc]- const children = graph.getChildren(node.id)- for (let i = 0; i < children.length; i++) {- result.push(...sceneNodeToKiwi(children[i], guid, i, localIdCounter, graph, blobs))- }-- return result-}-export function buildFigmaClipboardHTML(nodes: SceneNode[], graph: SceneGraph): string | null {const compiled = getCompiledSchema()const schemaDeflated = deflateSync(getSchemaBytes())diff --git a/packages/core/src/fig-export.ts b/packages/core/src/fig-export.tsindex 1a3f8df8a..c103d4493 100644--- a/packages/core/src/fig-export.ts+++ b/packages/core/src/fig-export.ts@@ -2,13 +2,12 @@ import { zipSync, deflateSync } from 'fflate'import { IS_TAURI } from './constants'import { initCodec, getCompiledSchema, getSchemaBytes } from './kiwi/codec'-+import { sceneNodeToKiwi, fractionalPosition } from './kiwi-serialize'import { renderThumbnail } from './render-image'-import { encodeVectorNetworkBlob } from './vector'import type { SkiaRenderer } from './renderer'-import type { SceneGraph, SceneNode, CharacterStyleOverride } from './scene-graph'-import type { NodeChange, Paint } from './kiwi/codec'+import type { SceneGraph } from './scene-graph'+import type { NodeChange } from './kiwi/codec'import type { CanvasKit } from 'canvaskit-wasm'const THUMBNAIL_1X1 = Uint8Array.from(@@ -20,196 +19,6 @@ const THUMBNAIL_1X1 = Uint8Array.from(type KiwiNodeChange = NodeChange & Record<string, unknown>-function mapToFigmaType(type: SceneNode['type']): string {- switch (type) {- case 'FRAME':- return 'FRAME'- case 'RECTANGLE':- return 'RECTANGLE'- case 'ROUNDED_RECTANGLE':- return 'ROUNDED_RECTANGLE'- case 'ELLIPSE':- return 'ELLIPSE'- case 'TEXT':- return 'TEXT'- case 'LINE':- return 'LINE'- case 'STAR':- return 'STAR'- case 'POLYGON':- return 'REGULAR_POLYGON'- case 'VECTOR':- return 'VECTOR'- case 'GROUP':- return 'FRAME'- case 'SECTION':- return 'SECTION'- case 'COMPONENT':- return 'COMPONENT'- case 'COMPONENT_SET':- return 'COMPONENT_SET'- case 'INSTANCE':- return 'INSTANCE'- case 'CONNECTOR':- return 'CONNECTOR'- case 'SHAPE_WITH_TEXT':- return 'SHAPE_WITH_TEXT'- default:- return 'RECTANGLE'- }-}--function fractionalPosition(index: number): string {- return String.fromCharCode('!'.charCodeAt(0) + index)-}--function sceneNodeToKiwi(- node: SceneNode,- parentGuid: { sessionID: number; localID: number },- childIndex: number,- localIdCounter: { value: number },- graph: SceneGraph,- blobs: Uint8Array[]-): KiwiNodeChange[] {- const localID = localIdCounter.value++- const guid = { sessionID: 1, localID }- const cos = Math.cos((node.rotation * Math.PI) / 180)- const sin = Math.sin((node.rotation * Math.PI) / 180)-- const fillPaints = node.fills.map((f) => {- const paint: Paint = {- type: f.type,- color: f.color,- opacity: f.opacity,- visible: f.visible,- blendMode: f.blendMode ?? 'NORMAL'- }- if (f.gradientStops) {- paint.stops = f.gradientStops.map((s) => ({ color: s.color, position: s.position }))- }- if (f.gradientTransform) paint.transform = f.gradientTransform- if (f.imageHash) paint.image = { hash: f.imageHash }- if (f.imageScaleMode) paint.imageScaleMode = f.imageScaleMode- if (f.imageTransform) paint.transform = f.imageTransform- return paint- })-- const strokePaints = node.strokes.map((s) => ({- type: 'SOLID' as const,- color: s.color,- opacity: s.opacity,- visible: s.visible,- blendMode: 'NORMAL' as const- }))-- const nc: KiwiNodeChange = {- guid,- parentIndex: { guid: parentGuid, position: fractionalPosition(childIndex) },- type: mapToFigmaType(node.type),- name: node.name,- visible: node.visible,- opacity: node.opacity,- phase: 'CREATED',- size: { x: node.width, y: node.height },- transform: { m00: cos, m01: -sin, m02: node.x, m10: sin, m11: cos, m12: node.y },- strokeWeight: node.strokes.length > 0 ? node.strokes[0].weight : 1,- strokeAlign: 'INSIDE'- }-- if (fillPaints.length > 0) nc.fillPaints = fillPaints- if (strokePaints.length > 0) nc.strokePaints = strokePaints-- if (node.cornerRadius > 0 || node.independentCorners) {- nc.cornerRadius = node.cornerRadius- nc.rectangleCornerRadiiIndependent = node.independentCorners- nc.rectangleTopLeftCornerRadius = node.independentCorners- ? node.topLeftRadius- : node.cornerRadius- nc.rectangleTopRightCornerRadius = node.independentCorners- ? node.topRightRadius- : node.cornerRadius- nc.rectangleBottomLeftCornerRadius = node.independentCorners- ? node.bottomLeftRadius- : node.cornerRadius- nc.rectangleBottomRightCornerRadius = node.independentCorners- ? node.bottomRightRadius- : node.cornerRadius- }-- if (node.cornerSmoothing > 0) {- nc.cornerSmoothing = node.cornerSmoothing- }-- if (node.effects.length > 0) {- nc.effects = node.effects.map((e) => ({- type: e.type,- color: e.color,- offset: e.offset,- radius: e.radius,- spread: e.spread,- visible: e.visible- }))- }-- if (node.type === 'TEXT') {- nc.fontSize = node.fontSize- nc.fontName = {- family: node.fontFamily,- style: fontStyleLabel(node.fontWeight, node.italic),- postscript: ''- }- nc.textData = exportTextData(node)- nc.textAutoResize = 'WIDTH_AND_HEIGHT'- nc.textAlignHorizontal = node.textAlignHorizontal- if (node.lineHeight != null) nc.lineHeight = { value: node.lineHeight, units: 'PIXELS' }- if (node.letterSpacing !== 0) nc.letterSpacing = { value: node.letterSpacing, units: 'PIXELS' }- if (node.textDecoration !== 'NONE') {- ;(nc as Record<string, unknown>).textDecoration =- node.textDecoration === 'UNDERLINE' ? 'UNDERLINE' : 'STRIKETHROUGH'- }- }-- if (node.type === 'FRAME' || node.type === 'GROUP') {- nc.frameMaskDisabled = node.type === 'GROUP'- if (node.clipsContent) nc.clipsContent = true- }-- if (node.layoutMode !== 'NONE') {- nc.stackMode = node.layoutMode- nc.stackSpacing = node.itemSpacing- nc.stackVerticalPadding = node.paddingTop- nc.stackHorizontalPadding = node.paddingLeft- nc.stackPaddingBottom = node.paddingBottom- nc.stackPaddingRight = node.paddingRight- nc.stackPrimarySizing = node.primaryAxisSizing === 'HUG' ? 'RESIZE_TO_FIT' : 'FIXED'- nc.stackCounterSizing = node.counterAxisSizing === 'HUG' ? 'RESIZE_TO_FIT' : 'FIXED'- nc.stackPrimaryAlignItems = node.primaryAxisAlign- nc.stackCounterAlignItems = node.counterAxisAlign- if (node.layoutWrap === 'WRAP') nc.stackWrap = 'WRAP'- if (node.counterAxisSpacing > 0) nc.stackCounterSpacing = node.counterAxisSpacing- }-- if (node.layoutPositioning === 'ABSOLUTE') nc.stackPositioning = 'ABSOLUTE'- if (node.layoutGrow > 0) nc.stackChildPrimaryGrow = node.layoutGrow-- if (node.vectorNetwork && node.type === 'VECTOR') {- const blobIdx = blobs.length- blobs.push(encodeVectorNetworkBlob(node.vectorNetwork))- nc.vectorData = {- vectorNetworkBlob: blobIdx,- normalizedSize: { x: node.width, y: node.height }- }- }-- const result: KiwiNodeChange[] = [nc]- const children = graph.getChildren(node.id)- for (let i = 0; i < children.length; i++) {- result.push(...sceneNodeToKiwi(children[i], guid, i, localIdCounter, graph, blobs))- }-- return result-}-function buildFigKiwi(schemaDeflated: Uint8Array, dataCompressed: Uint8Array): Uint8Array {const FIG_KIWI_VERSION = 106const total = 8 + 4 + 4 + schemaDeflated.length + 4 + dataCompressed.length@@ -340,66 +149,4 @@ export async function exportFigFile(})}-function fontStyleLabel(weight: number, italic: boolean): string {- let label = 'Regular'- if (weight >= 900) label = 'Black'- else if (weight >= 800) label = 'ExtraBold'- else if (weight >= 700) label = 'Bold'- else if (weight >= 600) label = 'SemiBold'- else if (weight >= 500) label = 'Medium'- else if (weight >= 300) label = 'Light'- else if (weight >= 200) label = 'ExtraLight'- else if (weight >= 100) label = 'Thin'- if (italic) label += ' Italic'- return label-}--function exportTextData(node: SceneNode): NodeChange['textData'] {- const runs = node.styleRuns- if (runs.length === 0) {- return { characters: node.text }- }-- const charIds = new Array<number>(node.text.length).fill(0)- const styleMap = new Map<string, { id: number; style: CharacterStyleOverride }>()- let nextId = 1- for (const run of runs) {- const key = JSON.stringify(run.style)- let entry = styleMap.get(key)- if (!entry) {- entry = { id: nextId++, style: run.style }- styleMap.set(key, entry)- }- for (let i = run.start; i < run.start + run.length && i < charIds.length; i++) {- charIds[i] = entry.id- }- }-- const overrideTable: NodeChange[] = []- for (const { id, style } of styleMap.values()) {- const override: Record<string, unknown> = { styleID: id }- const weight = style.fontWeight ?? node.fontWeight- const italic = style.italic ?? node.italic- override.fontName = {- family: style.fontFamily ?? node.fontFamily,- style: fontStyleLabel(weight, italic),- postscript: ''- }- if (style.fontSize !== undefined) override.fontSize = style.fontSize- if (style.letterSpacing !== undefined) {- override.letterSpacing = { value: style.letterSpacing, units: 'PIXELS' }- }- if (style.lineHeight !== undefined && style.lineHeight !== null) {- override.lineHeight = { value: style.lineHeight, units: 'PIXELS' }- }- if (style.textDecoration) override.textDecoration = style.textDecoration- overrideTable.push(override as unknown as NodeChange)- }-- return {- characters: node.text,- characterStyleIDs: charIds,- styleOverrideTable: overrideTable- }-}diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 5eb008991..544d1f434 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -111,10 +111,41 @@ 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'diff --git a/packages/core/src/kiwi-serialize.ts b/packages/core/src/kiwi-serialize.tsnew file mode 100644index 000000000..f9cd93e1b--- /dev/null+++ b/packages/core/src/kiwi-serialize.ts@@ -0,0 +1,260 @@+import { encodeVectorNetworkBlob } from './vector'++import type { SceneGraph, SceneNode, CharacterStyleOverride } from './scene-graph'+import type { NodeChange, Paint } from './kiwi/codec'++type KiwiNodeChange = NodeChange & Record<string, unknown>++export function mapToFigmaType(type: SceneNode['type']): string {+ switch (type) {+ case 'FRAME':+ return 'FRAME'+ case 'RECTANGLE':+ return 'RECTANGLE'+ case 'ROUNDED_RECTANGLE':+ return 'ROUNDED_RECTANGLE'+ case 'ELLIPSE':+ return 'ELLIPSE'+ case 'TEXT':+ return 'TEXT'+ case 'LINE':+ return 'LINE'+ case 'STAR':+ return 'STAR'+ case 'POLYGON':+ return 'REGULAR_POLYGON'+ case 'VECTOR':+ return 'VECTOR'+ case 'GROUP':+ return 'FRAME'+ case 'SECTION':+ return 'SECTION'+ case 'COMPONENT':+ return 'COMPONENT'+ case 'COMPONENT_SET':+ return 'COMPONENT_SET'+ case 'INSTANCE':+ return 'INSTANCE'+ case 'CONNECTOR':+ return 'CONNECTOR'+ case 'SHAPE_WITH_TEXT':+ return 'SHAPE_WITH_TEXT'+ default:+ return 'RECTANGLE'+ }+}++export function fractionalPosition(index: number): string {+ return String.fromCharCode('!'.charCodeAt(0) + index)+}++function fontStyleLabel(weight: number, italic: boolean): string {+ let label = 'Regular'+ if (weight >= 900) label = 'Black'+ else if (weight >= 800) label = 'ExtraBold'+ else if (weight >= 700) label = 'Bold'+ else if (weight >= 600) label = 'SemiBold'+ else if (weight >= 500) label = 'Medium'+ else if (weight >= 300) label = 'Light'+ else if (weight >= 200) label = 'ExtraLight'+ else if (weight >= 100) label = 'Thin'+ if (italic) label += ' Italic'+ return label+}++function exportTextData(node: SceneNode): NodeChange['textData'] {+ const runs = node.styleRuns+ if (runs.length === 0) {+ return { characters: node.text }+ }++ const charIds = new Array<number>(node.text.length).fill(0)+ const styleMap = new Map<string, { id: number; style: CharacterStyleOverride }>()+ let nextId = 1++ for (const run of runs) {+ const key = JSON.stringify(run.style)+ let entry = styleMap.get(key)+ if (!entry) {+ entry = { id: nextId++, style: run.style }+ styleMap.set(key, entry)+ }+ for (let i = run.start; i < run.start + run.length && i < charIds.length; i++) {+ charIds[i] = entry.id+ }+ }++ const overrideTable: NodeChange[] = []+ for (const { id, style } of styleMap.values()) {+ const override: Record<string, unknown> = { styleID: id }+ const weight = style.fontWeight ?? node.fontWeight+ const italic = style.italic ?? node.italic+ override.fontName = {+ family: style.fontFamily ?? node.fontFamily,+ style: fontStyleLabel(weight, italic),+ postscript: ''+ }+ if (style.fontSize !== undefined) override.fontSize = style.fontSize+ if (style.letterSpacing !== undefined) {+ override.letterSpacing = { value: style.letterSpacing, units: 'PIXELS' }+ }+ if (style.lineHeight !== undefined && style.lineHeight !== null) {+ override.lineHeight = { value: style.lineHeight, units: 'PIXELS' }+ }+ if (style.textDecoration) override.textDecoration = style.textDecoration+ overrideTable.push(override as unknown as NodeChange)+ }++ return {+ characters: node.text,+ characterStyleIDs: charIds,+ styleOverrideTable: overrideTable+ }+}++export function sceneNodeToKiwi(+ node: SceneNode,+ parentGuid: { sessionID: number; localID: number },+ childIndex: number,+ localIdCounter: { value: number },+ graph: SceneGraph,+ blobs: Uint8Array[]+): KiwiNodeChange[] {+ const localID = localIdCounter.value+++ const guid = { sessionID: 1, localID }+ const cos = Math.cos((node.rotation * Math.PI) / 180)+ const sin = Math.sin((node.rotation * Math.PI) / 180)++ const fillPaints = node.fills.map((f) => {+ const paint: Paint = {+ type: f.type,+ color: f.color,+ opacity: f.opacity,+ visible: f.visible,+ blendMode: f.blendMode ?? 'NORMAL'+ }+ if (f.gradientStops) {+ paint.stops = f.gradientStops.map((s) => ({ color: s.color, position: s.position }))+ }+ if (f.gradientTransform) paint.transform = f.gradientTransform+ if (f.imageHash) paint.image = { hash: f.imageHash }+ if (f.imageScaleMode) paint.imageScaleMode = f.imageScaleMode+ if (f.imageTransform) paint.transform = f.imageTransform+ return paint+ })++ const strokePaints = node.strokes.map((s) => ({+ type: 'SOLID' as const,+ color: s.color,+ opacity: s.opacity,+ visible: s.visible,+ blendMode: 'NORMAL' as const+ }))++ const nc: KiwiNodeChange = {+ guid,+ parentIndex: { guid: parentGuid, position: fractionalPosition(childIndex) },+ type: mapToFigmaType(node.type),+ name: node.name,+ visible: node.visible,+ opacity: node.opacity,+ phase: 'CREATED',+ size: { x: node.width, y: node.height },+ transform: { m00: cos, m01: -sin, m02: node.x, m10: sin, m11: cos, m12: node.y },+ strokeWeight: node.strokes.length > 0 ? node.strokes[0].weight : 1,+ strokeAlign: 'INSIDE'+ }++ if (fillPaints.length > 0) nc.fillPaints = fillPaints+ if (strokePaints.length > 0) nc.strokePaints = strokePaints++ if (node.cornerRadius > 0 || node.independentCorners) {+ nc.cornerRadius = node.cornerRadius+ nc.rectangleCornerRadiiIndependent = node.independentCorners+ nc.rectangleTopLeftCornerRadius = node.independentCorners+ ? node.topLeftRadius+ : node.cornerRadius+ nc.rectangleTopRightCornerRadius = node.independentCorners+ ? node.topRightRadius+ : node.cornerRadius+ nc.rectangleBottomLeftCornerRadius = node.independentCorners+ ? node.bottomLeftRadius+ : node.cornerRadius+ nc.rectangleBottomRightCornerRadius = node.independentCorners+ ? node.bottomRightRadius+ : node.cornerRadius+ }++ if (node.cornerSmoothing > 0) {+ nc.cornerSmoothing = node.cornerSmoothing+ }++ if (node.effects.length > 0) {+ nc.effects = node.effects.map((e) => ({+ type: e.type,+ color: e.color,+ offset: e.offset,+ radius: e.radius,+ spread: e.spread,+ visible: e.visible+ }))+ }++ if (node.type === 'TEXT') {+ nc.fontSize = node.fontSize+ nc.fontName = {+ family: node.fontFamily,+ style: fontStyleLabel(node.fontWeight, node.italic),+ postscript: ''+ }+ nc.textData = exportTextData(node)+ nc.textAutoResize = 'WIDTH_AND_HEIGHT'+ nc.textAlignHorizontal = node.textAlignHorizontal+ if (node.lineHeight != null) nc.lineHeight = { value: node.lineHeight, units: 'PIXELS' }+ if (node.letterSpacing !== 0) nc.letterSpacing = { value: node.letterSpacing, units: 'PIXELS' }+ if (node.textDecoration !== 'NONE') {+ ;(nc as Record<string, unknown>).textDecoration =+ node.textDecoration === 'UNDERLINE' ? 'UNDERLINE' : 'STRIKETHROUGH'+ }+ }++ if (node.type === 'FRAME' || node.type === 'GROUP') {+ nc.frameMaskDisabled = node.type === 'GROUP'+ if (node.clipsContent) nc.clipsContent = true+ }++ if (node.layoutMode !== 'NONE') {+ nc.stackMode = node.layoutMode+ nc.stackSpacing = node.itemSpacing+ nc.stackVerticalPadding = node.paddingTop+ nc.stackHorizontalPadding = node.paddingLeft+ nc.stackPaddingBottom = node.paddingBottom+ nc.stackPaddingRight = node.paddingRight+ nc.stackPrimarySizing = node.primaryAxisSizing === 'HUG' ? 'RESIZE_TO_FIT' : 'FIXED'+ nc.stackCounterSizing = node.counterAxisSizing === 'HUG' ? 'RESIZE_TO_FIT' : 'FIXED'+ nc.stackPrimaryAlignItems = node.primaryAxisAlign+ nc.stackCounterAlignItems = node.counterAxisAlign+ if (node.layoutWrap === 'WRAP') nc.stackWrap = 'WRAP'+ if (node.counterAxisSpacing > 0) nc.stackCounterSpacing = node.counterAxisSpacing+ }++ if (node.layoutPositioning === 'ABSOLUTE') nc.stackPositioning = 'ABSOLUTE'+ if (node.layoutGrow > 0) nc.stackChildPrimaryGrow = node.layoutGrow++ if (node.vectorNetwork && node.type === 'VECTOR') {+ const blobIdx = blobs.length+ blobs.push(encodeVectorNetworkBlob(node.vectorNetwork))+ nc.vectorData = {+ vectorNetworkBlob: blobIdx,+ normalizedSize: { x: node.width, y: node.height }+ }+ }++ const result: KiwiNodeChange[] = [nc]+ const children = graph.getChildren(node.id)+ for (let i = 0; i < children.length; i++) {+ result.push(...sceneNodeToKiwi(children[i], guid, i, localIdCounter, graph, blobs))+ }++ return result+}diff --git a/src/kiwi/codec.ts b/src/kiwi/codec.tsindex 65623a851..314c3d1b4 100644--- a/src/kiwi/codec.ts+++ b/src/kiwi/codec.ts@@ -1,557 +1,21 @@-/**- * Message Encoding/Decoding for Figma Multiplayer- *- * Uses:- * - kiwi-schema: Binary serialization (by Evan Wallace, Figma co-founder)- * - fzstd: Browser-compatible Zstd decompression- */--import { decompress as zstdDecompress } from 'fzstd'--import { parseColor } from '@/engine/color'--import { compileSchema, encodeBinarySchema } from './kiwi-schema'-import { isZstdCompressed, getKiwiMessageType } from './protocol.ts'-import figmaSchema from './schema.ts'--import type { Schema } from './kiwi-schema'--interface CompiledSchema {- encodeMessage(message: unknown): Uint8Array- decodeMessage(data: Uint8Array): unknown- encodePaint(paint: unknown): Uint8Array- encodeNodeChange(nodeChange: unknown): Uint8Array-}--let compiledSchema: CompiledSchema | null = null--/**- * Initialize the codec (compiles Kiwi schema)- */-export async function initCodec(): Promise<void> {- if (compiledSchema) return- compiledSchema = compileSchema(figmaSchema as Schema) as CompiledSchema-}--export function getCompiledSchema() {- if (!compiledSchema) throw new Error('Codec not initialized')- return compiledSchema-}--export function getSchemaBytes(): Uint8Array {- return encodeBinarySchema(figmaSchema as Schema)-}--/**- * Check if codec is initialized- */-export function isCodecReady(): boolean {- return compiledSchema !== null-}--/**- * Compress data using Zstd (Bun native)- */-export function compress(data: Uint8Array): Uint8Array {- return data-}--/**- * Decompress Zstd data (Bun native)- */-export function decompress(data: Uint8Array): Uint8Array {- if (!isZstdCompressed(data)) return data- return zstdDecompress(data)-}--/**- * Encode a message for sending to Figma- * Handles variable bindings in fillPaints which require custom encoding- */-export function encodeMessage(message: FigmaMessage): Uint8Array {- if (!compiledSchema) {- throw new Error('Codec not initialized. Call initCodec() first.')- }-- // Check if any nodeChange has variable bindings (fill or stroke)- const hasVariables = message.nodeChanges?.some(- (nc) =>- nc.fillPaints?.some((p) => p.colorVariableBinding) ||- nc.strokePaints?.some((p) => p.colorVariableBinding)- )-- if (!hasVariables) {- // Standard encoding- const encoded = compiledSchema.encodeMessage(message)- return compress(encoded)- }-- // Need custom encoding for variable bindings- // Strategy: encode each nodeChange separately, then combine- const messageWithoutNodes = { ...message, nodeChanges: [] }- const baseEncoded = compiledSchema.encodeMessage(messageWithoutNodes)- const baseHex = Buffer.from(baseEncoded).toString('hex')-- // Encode nodeChanges with variable support- const nodeChangeBytes: Uint8Array[] = []- for (const nc of message.nodeChanges || []) {- const encoded = encodeNodeChangeWithVariables(nc)- nodeChangeBytes.push(encoded)- }-- // Combine: base message + nodeChanges- // Message structure: type, sessionID, ackID, reconnectSeqNum, nodeChanges[]- // nodeChanges is field 5-- // Message structure in kiwi:- // - Field 1 (type): enum MessageType- // - Field 2 (sessionID): uint- // - Field 3 (ackID): uint- // - Field 4 (nodeChanges): NodeChange[] - this is what we need to replace- // - Field 25 (reconnectSequenceNumber): uint- //- // Empty array: "04 00" (field 4, length 0)- // We need to replace "04 00" with "04 <count> <nodes>"-- const emptyArrayPattern = '0400' // field 4, length 0- const emptyArrayIdx = baseHex.indexOf(emptyArrayPattern)-- if (emptyArrayIdx === -1) {- // Fallback to standard encoding- const encoded = compiledSchema.encodeMessage(message)- return compress(encoded)- }-- // Build nodeChanges array with our encoded nodes- const ncBytes: number[] = [0x04] // field 4- ncBytes.push(...encodeVarint(nodeChangeBytes.length)) // array length- for (const ncArr of nodeChangeBytes) {- ncBytes.push(...Array.from(ncArr))- }-- // Replace "0400" with our nodeChanges- const beforeArray = baseHex.slice(0, emptyArrayIdx)- const afterArray = baseHex.slice(emptyArrayIdx + 4) // skip "0400"-- const ncHex = Buffer.from(ncBytes).toString('hex')- const finalHex = beforeArray + ncHex + afterArray-- const finalBytes = new Uint8Array(finalHex.match(/.{2}/g)?.map((b) => parseInt(b, 16)) ?? [])- return compress(finalBytes)-}--/**- * Decode a message received from Figma- */-export function decodeMessage(data: Uint8Array): FigmaMessage {- if (!compiledSchema) {- throw new Error('Codec not initialized. Call initCodec() first.')- }-- const decompressed = decompress(data)- return compiledSchema.decodeMessage(decompressed) as FigmaMessage-}--/**- * Quick peek at message type without full decoding- */-export function peekMessageType(data: Uint8Array): number | null {- try {- const decompressed = decompress(data)- return getKiwiMessageType(decompressed)- } catch {- return null- }-}--// Type definitions--export type { GUID, Color } from '@/types'--import type { Color, GUID, Matrix, Vector } from '@/types'--export type { Matrix, Vector }--export interface ParentIndex {- guid: GUID- position: string-}--export interface VariableBinding {- variableID: GUID-}--export interface Paint {- type:- | 'SOLID'- | 'GRADIENT_LINEAR'- | 'GRADIENT_RADIAL'- | 'GRADIENT_ANGULAR'- | 'GRADIENT_DIAMOND'- | 'IMAGE'- color?: Color- opacity?: number- visible?: boolean- blendMode?: string- stops?: { color: Color; position: number }[]- transform?: { m00: number; m01: number; m02: number; m10: number; m11: number; m12: number }- image?: { hash: string }- imageScaleMode?: string- colorVariableBinding?: VariableBinding-}--export interface Effect {- type: 'DROP_SHADOW' | 'INNER_SHADOW' | 'LAYER_BLUR' | 'BACKGROUND_BLUR' | 'FOREGROUND_BLUR'- color?: Color- offset?: Vector- radius?: number- visible?: boolean- spread?: number- blendMode?: string-}--export interface NodeChange {- guid: GUID- phase?: 'CREATED' | 'REMOVED'- parentIndex?: ParentIndex- type?: string- name?: string- visible?: boolean- locked?: boolean- opacity?: number- blendMode?: string- size?: Vector- transform?: Matrix- cornerRadius?: number- fillPaints?: Paint[]- strokePaints?: Paint[]- strokeWeight?: number- strokeAlign?: string- strokeCap?: string- strokeJoin?: string- dashPattern?: number[]- effects?: Effect[]- // Layout- stackMode?: 'NONE' | 'HORIZONTAL' | 'VERTICAL'- stackSpacing?: number- stackPadding?: number- stackPaddingRight?: number- stackPaddingBottom?: number- stackCounterAlign?: string- stackJustify?: string- stackCounterAlignItems?: string- stackPrimaryAlignItems?: string- stackPrimarySizing?: 'FIXED' | 'RESIZE_TO_FIT' | 'RESIZE_TO_FIT_WITH_IMPLICIT_SIZE'- stackCounterSizing?: 'FIXED' | 'RESIZE_TO_FIT' | 'RESIZE_TO_FIT_WITH_IMPLICIT_SIZE'- stackVerticalPadding?: number- stackHorizontalPadding?: number- stackWrap?: string- stackPositioning?: string- stackChildPrimaryGrow?: number- stackCounterSpacing?: number- // Frame- clipsContent?: boolean- frameMaskDisabled?: boolean- // Vector- vectorData?: unknown- // Text- fontSize?: number- fontName?: { family: string; style: string; postscript?: string }- textAlignHorizontal?: string- textAlignVertical?: string- textAutoResize?: string- textData?: { characters: string; lines?: unknown[] }- lineHeight?: { value: number; units: string }- letterSpacing?: { value: number; units: string }- // Symbol/Instance- symbolData?: { symbolID: GUID }- // ComponentSet- isStateGroup?: boolean- stateGroupPropertyValueOrders?: Array<{ property: string; values: string[] }>- // Corners- rectangleTopLeftCornerRadius?: number- rectangleTopRightCornerRadius?: number- rectangleBottomLeftCornerRadius?: number- rectangleBottomRightCornerRadius?: number- rectangleCornerRadiiIndependent?: boolean- cornerSmoothing?: number- // Constraints- horizontalConstraint?: string- verticalConstraint?: string-}--export interface FigmaMessage {- type: string- sessionID?: number- ackID?: number- reconnectSequenceNumber?: number- nodeChanges?: NodeChange[]-}--/**- * Create a NODE_CHANGES message- */-export function createNodeChangesMessage(- sessionID: number,- reconnectSequenceNumber: number,- nodeChanges: NodeChange[],- ackID = 1-): FigmaMessage {- return {- type: 'NODE_CHANGES',- sessionID,- ackID,- reconnectSequenceNumber,- nodeChanges- }-}--/**- * Create a node change for a new shape- */-export function createNodeChange(opts: {- sessionID: number- localID: number- parentSessionID: number- parentLocalID: number- position?: string- type: string- name: string- x: number- y: number- width: number- height: number- fill?: Color | string- stroke?: Color | string- strokeWeight?: number- cornerRadius?: number- opacity?: number-}): NodeChange {- const change: NodeChange = {- guid: { sessionID: opts.sessionID, localID: opts.localID },- phase: 'CREATED',- parentIndex: {- guid: { sessionID: opts.parentSessionID, localID: opts.parentLocalID },- position: opts.position || '!'- },- type: opts.type,- name: opts.name,- visible: true,- opacity: opts.opacity ?? 1.0,- size: { x: opts.width, y: opts.height },- transform: {- m00: 1,- m01: 0,- m02: opts.x,- m10: 0,- m11: 1,- m12: opts.y- }- }-- if (opts.fill) {- const color = typeof opts.fill === 'string' ? parseColor(opts.fill) : opts.fill- change.fillPaints = [- {- type: 'SOLID',- color,- opacity: 1.0,- visible: true,- blendMode: 'NORMAL'- }- ]- }-- if (opts.stroke) {- const color = typeof opts.stroke === 'string' ? parseColor(opts.stroke) : opts.stroke- change.strokePaints = [- {- type: 'SOLID',- color,- opacity: 1.0,- visible: true,- blendMode: 'NORMAL'- }- ]- change.strokeWeight = opts.strokeWeight ?? 1- }-- if (opts.cornerRadius !== undefined) {- change.cornerRadius = opts.cornerRadius- }-- return change-}--/**- * Encode a varint (variable-length integer)- */-function encodeVarint(value: number): number[] {- const bytes: number[] = []- while (value > 0x7f) {- bytes.push((value & 0x7f) | 0x80)- value >>>= 7- }- bytes.push(value)- return bytes-}--/**- * Encode a Paint with optional variable binding- *- * Figma's variable binding format (discovered via WS traffic analysis):- * - Field 21 = 1 (binding type)- * - Field 4 = 1 (flag)- * - Raw sessionID varint (no field number)- * - Raw localID varint (no field number)- * - Terminators: 00 00 02 03 03 04 00 00- */-export function encodePaintWithVariableBinding(- paint: Paint,- variableSessionID: number,- variableLocalID: number-): Uint8Array {- if (!compiledSchema) {- throw new Error('Codec not initialized. Call initCodec() first.')- }-- const { colorVariableBinding: _, ...basePaint } = paint-- const baseBytes = compiledSchema.encodePaint(basePaint)- const baseArray = Array.from(baseBytes) as number[]-- // Remove trailing 00- if (baseArray[baseArray.length - 1] === 0) {- baseArray.pop()- }-- // Add variable binding in Figma's exact format:- // Field 21 (0x15) = 1 (binding type)- baseArray.push(0x15, 0x01)- // Field 4 = 1 (flag)- baseArray.push(0x04, 0x01)- // Raw varints: sessionID, localID (no field numbers!)- baseArray.push(...encodeVarint(variableSessionID))- baseArray.push(...encodeVarint(variableLocalID))- // Terminators observed in Figma traffic- baseArray.push(0x00, 0x00, 0x02, 0x03, 0x03, 0x04)- // Final terminators- baseArray.push(0x00, 0x00)-- return new Uint8Array(baseArray)-}--/**- * Parse a variable ID string (e.g., "VariableID:38448:122296")- * Returns sessionID and localID- */-export function parseVariableId(variableId: string): { sessionID: number; localID: number } | null {- const match = variableId.match(/VariableID:(\d+):(\d+)/)- if (!match) return null- return {- sessionID: parseInt(match[1] ?? '0', 10),- localID: parseInt(match[2] ?? '0', 10)- }-}--/**- * Encode a NodeChange with variable bindings in fillPaints and/or strokePaints- * This is needed because kiwi-schema cannot produce Figma's exact variable binding format- */-export function encodeNodeChangeWithVariables(nodeChange: NodeChange): Uint8Array {- if (!compiledSchema) {- throw new Error('Codec not initialized. Call initCodec() first.')- }-- const hasFillBinding = nodeChange.fillPaints?.some((p) => p.colorVariableBinding)- const hasStrokeBinding = nodeChange.strokePaints?.some((p) => p.colorVariableBinding)-- if (!hasFillBinding && !hasStrokeBinding) {- return compiledSchema.encodeNodeChange(nodeChange)- }-- // Create a copy without variable bindings for base encoding- const cleanNodeChange = { ...nodeChange }- if (cleanNodeChange.fillPaints) {- cleanNodeChange.fillPaints = cleanNodeChange.fillPaints.map(- ({ colorVariableBinding: _, ...rest }) => rest- )- }- if (cleanNodeChange.strokePaints) {- cleanNodeChange.strokePaints = cleanNodeChange.strokePaints.map(- ({ colorVariableBinding: _, ...rest }) => rest- )- }-- // Encode clean version- const baseBytes = compiledSchema.encodeNodeChange(cleanNodeChange)- let hex = Buffer.from(baseBytes).toString('hex')-- // Inject fill variable binding (field 38 = 0x26)- const fillBinding = nodeChange.fillPaints?.[0]?.colorVariableBinding- if (hasFillBinding && fillBinding) {- hex = injectVariableBinding(hex, '2601', fillBinding)- }-- // Inject stroke variable binding (field 39 = 0x27)- const strokeBinding = nodeChange.strokePaints?.[0]?.colorVariableBinding- if (hasStrokeBinding && strokeBinding) {- hex = injectVariableBinding(hex, '2701', strokeBinding)- }-- return new Uint8Array(hex.match(/.{2}/g)?.map((b) => parseInt(b, 16)) ?? [])-}--/**- * Inject variable binding into a paint at the specified marker- */-function injectVariableBinding(- hex: string,- marker: string,- binding: { variableID: { sessionID: number; localID: number } }-): string {- const markerIdx = hex.indexOf(marker)- if (markerIdx === -1) return hex-- // Find visible=true pattern (04 01) after the marker- const visiblePattern = '0401'- let patternIdx = hex.indexOf(visiblePattern, markerIdx)- if (patternIdx === -1) return hex-- // Move past 0401 to find where to insert- let insertPoint = patternIdx + visiblePattern.length-- // Check if blendMode follows (05 01)- if (hex.slice(insertPoint, insertPoint + 4) === '0501') {- insertPoint += 4- }-- // Build variable binding bytes- const varBytes = [- 0x15,- 0x01, // Field 21 (variableBinding) = 1- 0x04,- 0x01, // Nested field 4 = 1- ...encodeVarint(binding.variableID.sessionID),- ...encodeVarint(binding.variableID.localID),- 0x00,- 0x00,- 0x02,- 0x03,- 0x03,- 0x04,- 0x00,- 0x00 // Terminators- ]- const varHex = Buffer.from(varBytes).toString('hex')-- const beforeVar = hex.slice(0, insertPoint)- // Skip original paint terminator (00) - our varHex includes terminators- let afterIdx = insertPoint- if (hex.slice(afterIdx, afterIdx + 2) === '00') {- afterIdx += 2- }- const afterVar = hex.slice(afterIdx)-- return beforeVar + varHex + afterVar-}+export {+ initCodec,+ encodeMessage,+ decodeMessage,+ compress,+ decompress,+ getCompiledSchema,+ getSchemaBytes,+ createNodeChangesMessage,+ createNodeChange,+ parseVariableId,+ encodePaintWithVariableBinding,+ encodeNodeChangeWithVariables,+ type NodeChange,+ type KiwiGUID as GUID,+ type KiwiColor as Color,+ type KiwiPaint as Paint,+ type VariableBinding,+ type ParentIndex,+ type FigmaMessage+} from '@open-pencil/core'diff --git a/src/kiwi/index.ts b/src/kiwi/index.tsindex 2ff2b124d..07aa31b63 100644--- a/src/kiwi/index.ts+++ b/src/kiwi/index.ts@@ -3,25 +3,6 @@** Direct WebSocket access to Figma's multiplayer protocol.* Enables creating nodes 1000-5000x faster than the plugin API.- *- * @example- * ```ts- * import { FigmaMultiplayerClient, getCookiesFromDevTools } from './multiplayer'- *- * const cookies = await getCookiesFromDevTools()- * const client = new FigmaMultiplayerClient('fileKey')- * await client.connect(cookies)- *- * await client.createNodes([{- * guid: { sessionID: client.getSessionInfo()!.sessionID, localID: 1 },- * phase: 'CREATED',- * type: 'RECTANGLE',- * name: 'My Rect',- * // ...- * }])- *- * client.close()- * ```*/export {@@ -46,7 +27,6 @@ export {type Paint,type VariableBinding,type ParentIndex,- type NodeChange,type FigmaMessage} from './codec.ts'diff --git a/src/kiwi/kiwi-schema/bb.ts b/src/kiwi/kiwi-schema/bb.tsdeleted file mode 100644index 84f703c84..000000000--- a/src/kiwi/kiwi-schema/bb.ts+++ /dev/null@@ -1,281 +0,0 @@-let int32 = new Int32Array(1)-let float32 = new Float32Array(int32.buffer)--export class ByteBuffer {- private _data: Uint8Array- private _index: number- length: number-- constructor(data?: Uint8Array) {- if (data && !(data instanceof Uint8Array)) {- throw new Error('Must initialize a ByteBuffer with a Uint8Array')- }- this._data = data || new Uint8Array(256)- this._index = 0- this.length = data ? data.length : 0- }-- toUint8Array(): Uint8Array {- return this._data.subarray(0, this.length)- }-- readByte(): number {- if (this._index + 1 > this._data.length) {- throw new Error('Index out of bounds')- }- return this._data[this._index++]- }-- readByteArray(): Uint8Array {- let length = this.readVarUint()- let start = this._index- let end = start + length- if (end > this._data.length) {- throw new Error('Read array out of bounds')- }- this._index = end- // Copy into a new array instead of just creating another view.- let result = new Uint8Array(length)- result.set(this._data.subarray(start, end))- return result- }-- readVarFloat(): number {- let index = this._index- let data = this._data- let length = data.length-- // Optimization: use a single byte to store zero- if (index + 1 > length) {- throw new Error('Index out of bounds')- }- let first = data[index]- if (first === 0) {- this._index = index + 1- return 0- }-- // Endian-independent 32-bit read- if (index + 4 > length) {- throw new Error('Index out of bounds')- }- let bits = first | (data[index + 1] << 8) | (data[index + 2] << 16) | (data[index + 3] << 24)- this._index = index + 4-- // Move the exponent back into place- bits = (bits << 23) | (bits >>> 9)-- // Reinterpret as a floating-point number- int32[0] = bits- return float32[0]- }-- readVarUint(): number {- let value = 0- let shift = 0- do {- var byte = this.readByte()- value |= (byte & 127) << shift- shift += 7- } while (byte & 128 && shift < 35)- return value >>> 0- }-- readVarInt(): number {- let value = this.readVarUint() | 0- return value & 1 ? ~(value >>> 1) : value >>> 1- }-- readVarUint64(): bigint {- let value = BigInt(0)- let shift = BigInt(0)- let seven = BigInt(7)- let byte: number- while ((byte = this.readByte()) & 128 && shift < 56) {- value |= BigInt(byte & 127) << shift- shift += seven- }- value |= BigInt(byte) << shift- return value- }-- readVarInt64(): bigint {- let value = this.readVarUint64()- let one = BigInt(1)- let sign = value & one- value >>= one- return sign ? ~value : value- }-- readString(): string {- let result = ''-- while (true) {- let codePoint-- // Decode UTF-8- let a = this.readByte()- if (a < 0xc0) {- codePoint = a- } else {- let b = this.readByte()- if (a < 0xe0) {- codePoint = ((a & 0x1f) << 6) | (b & 0x3f)- } else {- let c = this.readByte()- if (a < 0xf0) {- codePoint = ((a & 0x0f) << 12) | ((b & 0x3f) << 6) | (c & 0x3f)- } else {- let d = this.readByte()- codePoint = ((a & 0x07) << 18) | ((b & 0x3f) << 12) | ((c & 0x3f) << 6) | (d & 0x3f)- }- }- }-- // Strings are null-terminated- if (codePoint === 0) {- break- }-- // Encode UTF-16- if (codePoint < 0x10000) {- result += String.fromCharCode(codePoint)- } else {- codePoint -= 0x10000- result += String.fromCharCode(- (codePoint >> 10) + 0xd800,- (codePoint & ((1 << 10) - 1)) + 0xdc00- )- }- }-- return result- }-- private _growBy(amount: number): void {- if (this.length + amount > this._data.length) {- let data = new Uint8Array((this.length + amount) << 1)- data.set(this._data)- this._data = data- }- this.length += amount- }-- writeByte(value: number): void {- let index = this.length- this._growBy(1)- this._data[index] = value- }-- writeByteArray(value: Uint8Array): void {- this.writeVarUint(value.length)- let index = this.length- this._growBy(value.length)- this._data.set(value, index)- }-- writeVarFloat(value: number): void {- let index = this.length-- // Reinterpret as an integer- float32[0] = value- let bits = int32[0]-- // Move the exponent to the first 8 bits- bits = (bits >>> 23) | (bits << 9)-- // Optimization: use a single byte to store zero and denormals (check for an exponent of 0)- if ((bits & 255) === 0) {- this.writeByte(0)- return- }-- // Endian-independent 32-bit write- this._growBy(4)- let data = this._data- data[index] = bits- data[index + 1] = bits >> 8- data[index + 2] = bits >> 16- data[index + 3] = bits >> 24- }-- writeVarUint(value: number): void {- if (value < 0 || value > 0xffff_ffff) throw new Error('Outside uint range: ' + value)- do {- let byte = value & 127- value >>>= 7- this.writeByte(value ? byte | 128 : byte)- } while (value)- }-- writeVarInt(value: number): void {- if (value < -0x8000_0000 || value > 0x7fff_ffff) throw new Error('Outside int range: ' + value)- this.writeVarUint(((value << 1) ^ (value >> 31)) >>> 0)- }-- writeVarUint64(value: bigint | string): void {- if (typeof value === 'string') value = BigInt(value)- else if (typeof value !== 'bigint')- throw new Error('Expected bigint but got ' + typeof value + ': ' + value)- if (value < 0 || value > BigInt('0xFFFFFFFFFFFFFFFF'))- throw new Error('Outside uint64 range: ' + value)- let mask = BigInt(127)- let seven = BigInt(7)- for (let i = 0; value > mask && i < 8; i++) {- this.writeByte(Number(value & mask) | 128)- value >>= seven- }- this.writeByte(Number(value))- }-- writeVarInt64(value: bigint | string): void {- if (typeof value === 'string') value = BigInt(value)- else if (typeof value !== 'bigint')- throw new Error('Expected bigint but got ' + typeof value + ': ' + value)- if (value < -BigInt('0x8000000000000000') || value > BigInt('0x7FFFFFFFFFFFFFFF'))- throw new Error('Outside int64 range: ' + value)- let one = BigInt(1)- this.writeVarUint64(value < 0 ? ~(value << one) : value << one)- }-- writeString(value: string): void {- let codePoint-- for (let i = 0; i < value.length; i++) {- // Decode UTF-16- let a = value.charCodeAt(i)- if (i + 1 === value.length || a < 0xd800 || a >= 0xdc00) {- codePoint = a- } else {- let b = value.charCodeAt(++i)- codePoint = (a << 10) + b + (0x10000 - (0xd800 << 10) - 0xdc00)- }-- // Strings are null-terminated- if (codePoint === 0) {- throw new Error('Cannot encode a string containing the null character')- }-- // Encode UTF-8- if (codePoint < 0x80) {- this.writeByte(codePoint)- } else {- if (codePoint < 0x800) {- this.writeByte(((codePoint >> 6) & 0x1f) | 0xc0)- } else {- if (codePoint < 0x10000) {- this.writeByte(((codePoint >> 12) & 0x0f) | 0xe0)- } else {- this.writeByte(((codePoint >> 18) & 0x07) | 0xf0)- this.writeByte(((codePoint >> 12) & 0x3f) | 0x80)- }- this.writeByte(((codePoint >> 6) & 0x3f) | 0x80)- }- this.writeByte((codePoint & 0x3f) | 0x80)- }- }-- // Strings are null-terminated- this.writeByte(0)- }-}diff --git a/src/kiwi/kiwi-schema/binary.ts b/src/kiwi/kiwi-schema/binary.tsdeleted file mode 100644index 9e6af4691..000000000--- a/src/kiwi/kiwi-schema/binary.ts+++ /dev/null@@ -1,102 +0,0 @@-import { ByteBuffer } from './bb'-import { Schema, Field, Definition, DefinitionKind } from './schema'--let types: (string | null)[] = ['bool', 'byte', 'int', 'uint', 'float', 'string', 'int64', 'uint64']-let kinds: DefinitionKind[] = ['ENUM', 'STRUCT', 'MESSAGE']--export function decodeBinarySchema(buffer: Uint8Array | ByteBuffer): Schema {- let bb = buffer instanceof ByteBuffer ? buffer : new ByteBuffer(buffer)- let definitionCount = bb.readVarUint()- let definitions: Definition[] = []-- // Read in the schema- for (let i = 0; i < definitionCount; i++) {- let definitionName = bb.readString()- let kind = bb.readByte()- let fieldCount = bb.readVarUint()- let fields: Field[] = []-- for (let j = 0; j < fieldCount; j++) {- let fieldName = bb.readString()- let type = bb.readVarInt()- let isArray = !!(bb.readByte() & 1)- let value = bb.readVarUint()-- fields.push({- name: fieldName,- line: 0,- column: 0,- type: kinds[kind] === 'ENUM' ? null : (type as any),- isArray: isArray,- isDeprecated: false,- value: value- })- }-- definitions.push({- name: definitionName,- line: 0,- column: 0,- kind: kinds[kind],- fields: fields- })- }-- // Bind type names afterwards- for (let i = 0; i < definitionCount; i++) {- let fields = definitions[i].fields- for (let j = 0; j < fields.length; j++) {- let field = fields[j]- let type = field.type as any as number | null-- if (type !== null && type < 0) {- if (~type >= types.length) {- throw new Error('Invalid type ' + type)- }- field.type = types[~type]- } else {- if (type !== null && type >= definitions.length) {- throw new Error('Invalid type ' + type)- }- field.type = type === null ? null : definitions[type].name- }- }- }-- return {- package: null,- definitions: definitions- }-}--export function encodeBinarySchema(schema: Schema): Uint8Array {- let bb = new ByteBuffer()- let definitions = schema.definitions- let definitionIndex: { [name: string]: number } = {}-- bb.writeVarUint(definitions.length)-- for (let i = 0; i < definitions.length; i++) {- definitionIndex[definitions[i].name] = i- }-- for (let i = 0; i < definitions.length; i++) {- let definition = definitions[i]-- bb.writeString(definition.name)- bb.writeByte(kinds.indexOf(definition.kind))- bb.writeVarUint(definition.fields.length)-- for (let j = 0; j < definition.fields.length; j++) {- let field = definition.fields[j]- let type = types.indexOf(field.type)-- bb.writeString(field.name)- bb.writeVarInt(type === -1 ? definitionIndex[field.type!] : ~type)- bb.writeByte(field.isArray ? 1 : 0)- bb.writeVarUint(field.value)- }- }-- return bb.toUint8Array()-}diff --git a/src/kiwi/kiwi-schema/index.ts b/src/kiwi/kiwi-schema/index.tsdeleted file mode 100644index 7d45da2f9..000000000--- a/src/kiwi/kiwi-schema/index.ts+++ /dev/null@@ -1,5 +0,0 @@-export type { Schema, Definition, Field } from './schema'-export { ByteBuffer } from './bb'-export { compileSchema } from './js'-export { decodeBinarySchema, encodeBinarySchema } from './binary'-export { parseSchema } from './parser'diff --git a/src/kiwi/kiwi-schema/js.ts b/src/kiwi/kiwi-schema/js.tsdeleted file mode 100644index 63649e7e8..000000000--- a/src/kiwi/kiwi-schema/js.ts+++ /dev/null@@ -1,339 +0,0 @@-import { ByteBuffer } from './bb'-import { Schema, Definition } from './schema'-import { error, quote } from './util'--function compileDecode(- definition: Definition,- definitions: { [name: string]: Definition }-): string {- let lines: string[] = []- let indent = ' '-- lines.push('function (bb) {')- lines.push(' var result = {};')- lines.push(' if (!(bb instanceof this.ByteBuffer)) {')- lines.push(' bb = new this.ByteBuffer(bb);')- lines.push(' }')- lines.push('')-- if (definition.kind === 'MESSAGE') {- lines.push(' while (true) {')- lines.push(' switch (bb.readVarUint()) {')- lines.push(' case 0:')- lines.push(' return result;')- lines.push('')- indent = ' '- }-- for (let i = 0; i < definition.fields.length; i++) {- let field = definition.fields[i]- let code: string-- switch (field.type) {- case 'bool': {- code = '!!bb.readByte()'- break- }-- case 'byte': {- code = 'bb.readByte()' // only used if not array- break- }-- case 'int': {- code = 'bb.readVarInt()'- break- }-- case 'uint': {- code = 'bb.readVarUint()'- break- }-- case 'float': {- code = 'bb.readVarFloat()'- break- }-- case 'string': {- code = 'bb.readString()'- break- }-- case 'int64': {- code = 'bb.readVarInt64()'- break- }-- case 'uint64': {- code = 'bb.readVarUint64()'- break- }-- default: {- let type = definitions[field.type!]- if (!type) {- error(- 'Invalid type ' + quote(field.type!) + ' for field ' + quote(field.name),- field.line,- field.column- )- } else if (type.kind === 'ENUM') {- code = 'this[' + quote(type.name) + '][bb.readVarUint()]'- } else {- code = 'this[' + quote('decode' + type.name) + '](bb)'- }- }- }-- if (definition.kind === 'MESSAGE') {- lines.push(' case ' + field.value + ':')- }-- if (field.isArray) {- if (field.isDeprecated) {- if (field.type === 'byte') {- lines.push(indent + 'bb.readByteArray();')- } else {- lines.push(indent + 'var length = bb.readVarUint();')- lines.push(indent + 'while (length-- > 0) ' + code + ';')- }- } else {- if (field.type === 'byte') {- lines.push(indent + 'result[' + quote(field.name) + '] = bb.readByteArray();')- } else {- lines.push(indent + 'var length = bb.readVarUint();')- lines.push(indent + 'var values = result[' + quote(field.name) + '] = Array(length);')- lines.push(indent + 'for (var i = 0; i < length; i++) values[i] = ' + code + ';')- }- }- } else {- if (field.isDeprecated) {- lines.push(indent + code + ';')- } else {- lines.push(indent + 'result[' + quote(field.name) + '] = ' + code + ';')- }- }-- if (definition.kind === 'MESSAGE') {- lines.push(' break;')- lines.push('')- }- }-- if (definition.kind === 'MESSAGE') {- lines.push(' default:')- lines.push(' throw new Error("Attempted to parse invalid message");')- lines.push(' }')- lines.push(' }')- } else {- lines.push(' return result;')- }-- lines.push('}')-- return lines.join('\n')-}--function compileEncode(- definition: Definition,- definitions: { [name: string]: Definition }-): string {- let lines: string[] = []-- lines.push('function (message, bb) {')- lines.push(' var isTopLevel = !bb;')- lines.push(' if (isTopLevel) bb = new this.ByteBuffer();')-- for (let j = 0; j < definition.fields.length; j++) {- let field = definition.fields[j]- let code: string-- if (field.isDeprecated) {- continue- }-- switch (field.type) {- case 'bool': {- code = 'bb.writeByte(value);'- break- }-- case 'byte': {- code = 'bb.writeByte(value);' // only used if not array- break- }-- case 'int': {- code = 'bb.writeVarInt(value);'- break- }-- case 'uint': {- code = 'bb.writeVarUint(value);'- break- }-- case 'float': {- code = 'bb.writeVarFloat(value);'- break- }-- case 'string': {- code = 'bb.writeString(value);'- break- }-- case 'int64': {- code = 'bb.writeVarInt64(value);'- break- }-- case 'uint64': {- code = 'bb.writeVarUint64(value);'- break- }-- default: {- let type = definitions[field.type!]- if (!type) {- throw new Error('Invalid type ' + quote(field.type!) + ' for field ' + quote(field.name))- } else if (type.kind === 'ENUM') {- code =- 'var encoded = this[' +- quote(type.name) +- '][value]; ' +- 'if (encoded === void 0) throw new Error("Invalid value " + JSON.stringify(value) + ' +- quote(' for enum ' + quote(type.name)) +- '); ' +- 'bb.writeVarUint(encoded);'- } else {- code = 'this[' + quote('encode' + type.name) + '](value, bb);'- }- }- }-- lines.push('')- lines.push(' var value = message[' + quote(field.name) + '];')- lines.push(' if (value != null) {') // Comparing with null using "!=" also checks for undefined-- if (definition.kind === 'MESSAGE') {- lines.push(' bb.writeVarUint(' + field.value + ');')- }-- if (field.isArray) {- if (field.type === 'byte') {- lines.push(' bb.writeByteArray(value);')- } else {- lines.push(' var values = value, n = values.length;')- lines.push(' bb.writeVarUint(n);')- lines.push(' for (var i = 0; i < n; i++) {')- lines.push(' value = values[i];')- lines.push(' ' + code)- lines.push(' }')- }- } else {- lines.push(' ' + code)- }-- if (definition.kind === 'STRUCT') {- lines.push(' } else {')- lines.push(- ' throw new Error(' + quote('Missing required field ' + quote(field.name)) + ');'- )- }-- lines.push(' }')- }-- // A field id of zero is reserved to indicate the end of the message- if (definition.kind === 'MESSAGE') {- lines.push(' bb.writeVarUint(0);')- }-- lines.push('')- lines.push(' if (isTopLevel) return bb.toUint8Array();')- lines.push('}')-- return lines.join('\n')-}--export function compileSchemaJS(schema: Schema): string {- let definitions: { [name: string]: Definition } = {}- let name = schema.package- let js: string[] = []-- if (name !== null) {- js.push('var ' + name + ' = exports || ' + name + ' || {}, exports;')- } else {- js.push('var exports = exports || {};')- name = 'exports'- }-- js.push(name + '.ByteBuffer = ' + name + '.ByteBuffer || require("kiwi-schema").ByteBuffer;')-- for (let i = 0; i < schema.definitions.length; i++) {- let definition = schema.definitions[i]- definitions[definition.name] = definition- }-- for (let i = 0; i < schema.definitions.length; i++) {- let definition = schema.definitions[i]-- switch (definition.kind) {- case 'ENUM': {- let value: any = {}- for (let j = 0; j < definition.fields.length; j++) {- let field = definition.fields[j]- value[field.name] = field.value- value[field.value] = field.name- }- js.push(name + '[' + quote(definition.name) + '] = ' + JSON.stringify(value, null, 2) + ';')- break- }-- case 'STRUCT':- case 'MESSAGE': {- js.push('')- js.push(- name +- '[' +- quote('decode' + definition.name) +- '] = ' +- compileDecode(definition, definitions) +- ';'- )- js.push('')- js.push(- name +- '[' +- quote('encode' + definition.name) +- '] = ' +- compileEncode(definition, definitions) +- ';'- )- break- }-- default: {- error(- 'Invalid definition kind ' + quote(definition.kind),- definition.line,- definition.column- )- break- }- }- }-- js.push('')- return js.join('\n')-}--export function compileSchema(schema: Schema): any {- let result = {- ByteBuffer: ByteBuffer- }- new Function('exports', compileSchemaJS(schema))(result)- return result-}diff --git a/src/kiwi/kiwi-schema/parser.ts b/src/kiwi/kiwi-schema/parser.tsdeleted file mode 100644index c2a0a80ff..000000000--- a/src/kiwi/kiwi-schema/parser.ts+++ /dev/null@@ -1,287 +0,0 @@-import { Schema, Definition, Field, DefinitionKind } from './schema'-import { error, quote } from './util'--export let nativeTypes = ['bool', 'byte', 'float', 'int', 'int64', 'string', 'uint', 'uint64']--// These are special names on the object returned by compileSchema()-export let reservedNames = ['ByteBuffer', 'package']--let regex = /((?:-|\b)\d+\b|[=;{}]|\[\]|\[deprecated\]|\b[A-Za-z_][A-Za-z0-9_]*\b|\/\/.*|\s+)/g-let identifier = /^[A-Za-z_][A-Za-z0-9_]*$/-let whitespace = /^\/\/.*|\s+$/-let equals = /^=$/-let endOfFile = /^$/-let semicolon = /^;$/-let integer = /^-?\d+$/-let leftBrace = /^\{$/-let rightBrace = /^\}$/-let arrayToken = /^\[\]$/-let enumKeyword = /^enum$/-let structKeyword = /^struct$/-let messageKeyword = /^message$/-let packageKeyword = /^package$/-let deprecatedToken = /^\[deprecated\]$/--interface Token {- text: string- line: number- column: number-}--function tokenize(text: string): Token[] {- let parts = text.split(regex)- let tokens = []- let column = 0- let line = 0-- for (let i = 0; i < parts.length; i++) {- let part = parts[i]-- // Keep non-whitespace tokens- if (i & 1) {- if (!whitespace.test(part)) {- tokens.push({- text: part,- line: line + 1,- column: column + 1- })- }- }-- // Detect syntax errors- else if (part !== '') {- error('Syntax error ' + quote(part), line + 1, column + 1)- }-- // Keep track of the line and column counts- let lines = part.split('\n')- if (lines.length > 1) column = 0- line += lines.length - 1- column += lines[lines.length - 1].length- }-- // End-of-file token- tokens.push({- text: '',- line: line,- column: column- })-- return tokens-}--function parse(tokens: Token[]): Schema {- function current(): Token {- return tokens[index]- }-- function eat(test: RegExp): boolean {- if (test.test(current().text)) {- index++- return true- }- return false- }-- function expect(test: RegExp, expected: string): void {- if (!eat(test)) {- let token = current()- error('Expected ' + expected + ' but found ' + quote(token.text), token.line, token.column)- }- }-- function unexpectedToken(): never {- let token = current()- error('Unexpected token ' + quote(token.text), token.line, token.column)- }-- let definitions: Definition[] = []- let packageText = null- let index = 0-- if (eat(packageKeyword)) {- packageText = current().text- expect(identifier, 'identifier')- expect(semicolon, '";"')- }-- while (index < tokens.length && !eat(endOfFile)) {- let fields: Field[] = []- let kind: DefinitionKind-- if (eat(enumKeyword)) kind = 'ENUM'- else if (eat(structKeyword)) kind = 'STRUCT'- else if (eat(messageKeyword)) kind = 'MESSAGE'- else unexpectedToken()-- // All definitions start off the same- let name = current()- expect(identifier, 'identifier')- expect(leftBrace, '"{"')-- // Parse fields- while (!eat(rightBrace)) {- let type: string | null = null- let isArray = false- let isDeprecated = false-- // Enums don't have types- if (kind !== 'ENUM') {- type = current().text- expect(identifier, 'identifier')- isArray = eat(arrayToken)- }-- let field = current()- expect(identifier, 'identifier')-- // Structs don't have explicit values- let value: Token | null = null- if (kind !== 'STRUCT') {- expect(equals, '"="')- value = current()- expect(integer, 'integer')-- if ((+value.text | 0) + '' !== value.text) {- error('Invalid integer ' + quote(value.text), value.line, value.column)- }- }-- let deprecated = current()- if (eat(deprecatedToken)) {- if (kind !== 'MESSAGE') {- error('Cannot deprecate this field', deprecated.line, deprecated.column)- }-- isDeprecated = true- }-- expect(semicolon, '";"')-- fields.push({- name: field.text,- line: field.line,- column: field.column,- type: type,- isArray: isArray,- isDeprecated: isDeprecated,- value: value !== null ? +value.text | 0 : fields.length + 1- })- }-- definitions.push({- name: name.text,- line: name.line,- column: name.column,- kind: kind,- fields: fields- })- }-- return {- package: packageText,- definitions: definitions- }-}--function verify(root: Schema): void {- let definedTypes = nativeTypes.slice()- let definitions: { [name: string]: Definition } = {}-- // Define definitions- for (let i = 0; i < root.definitions.length; i++) {- let definition = root.definitions[i]- if (definedTypes.indexOf(definition.name) !== -1) {- error(- 'The type ' + quote(definition.name) + ' is defined twice',- definition.line,- definition.column- )- }- if (reservedNames.indexOf(definition.name) !== -1) {- error(- 'The type name ' + quote(definition.name) + ' is reserved',- definition.line,- definition.column- )- }- definedTypes.push(definition.name)- definitions[definition.name] = definition- }-- // Check fields- for (let i = 0; i < root.definitions.length; i++) {- let definition = root.definitions[i]- let fields = definition.fields-- if (definition.kind === 'ENUM' || fields.length === 0) {- continue- }-- // Check types- for (let j = 0; j < fields.length; j++) {- let field = fields[j]- if (definedTypes.indexOf(field.type!) === -1) {- error(- 'The type ' + quote(field.type!) + ' is not defined for field ' + quote(field.name),- field.line,- field.column- )- }- }-- // Check values- let values: number[] = []- for (let j = 0; j < fields.length; j++) {- let field = fields[j]- if (values.indexOf(field.value) !== -1) {- error('The id for field ' + quote(field.name) + ' is used twice', field.line, field.column)- }- if (field.value <= 0) {- error(- 'The id for field ' + quote(field.name) + ' must be positive',- field.line,- field.column- )- }- // Figma schema uses sparse field IDs (up to 435), so skip sequential check- values.push(field.value)- }- }-- // Check that structs don't contain themselves- let state: { [name: string]: number } = {}- let check = (name: string): boolean => {- let definition = definitions[name]- if (definition && definition.kind === 'STRUCT') {- if (state[name] === 1) {- error(- 'Recursive nesting of ' + quote(name) + ' is not allowed',- definition.line,- definition.column- )- }- if (state[name] !== 2 && definition) {- state[name] = 1- let fields = definition.fields- for (let i = 0; i < fields.length; i++) {- let field = fields[i]- if (!field.isArray) {- check(field.type!)- }- }- state[name] = 2- }- }- return true- }- for (let i = 0; i < root.definitions.length; i++) {- check(root.definitions[i].name)- }-}--export function parseSchema(text: string): Schema {- let schema = parse(tokenize(text))- verify(schema)- return schema-}diff --git a/src/kiwi/kiwi-schema/schema.ts b/src/kiwi/kiwi-schema/schema.tsdeleted file mode 100644index 82786ef59..000000000--- a/src/kiwi/kiwi-schema/schema.ts+++ /dev/null@@ -1,24 +0,0 @@-export interface Schema {- package: string | null- definitions: Definition[]-}--export type DefinitionKind = 'ENUM' | 'STRUCT' | 'MESSAGE'--export interface Definition {- name: string- line: number- column: number- kind: DefinitionKind- fields: Field[]-}--export interface Field {- name: string- line: number- column: number- type: string | null- isArray: boolean- isDeprecated: boolean- value: number-}diff --git a/src/kiwi/kiwi-schema/util.ts b/src/kiwi/kiwi-schema/util.tsdeleted file mode 100644index 2925ed6dd..000000000--- a/src/kiwi/kiwi-schema/util.ts+++ /dev/null@@ -1,10 +0,0 @@-export function quote(text: string): string {- return JSON.stringify(text)-}--export function error(text: string, line: number, column: number): never {- var error = new Error(text)- ;(error as any).line = line- ;(error as any).column = column- throw error-}diff --git a/src/kiwi/protocol.ts b/src/kiwi/protocol.tsindex d44aee9c9..29d6d5e06 100644--- a/src/kiwi/protocol.ts+++ b/src/kiwi/protocol.ts@@ -1,238 +1,19 @@-/**- * Figma Multiplayer Protocol- *- * This module handles the low-level WebSocket communication with Figma's- * multiplayer server. The protocol uses:- *- * - Kiwi binary serialization (schema-based, like Protocol Buffers)- * - Zstd compression for all messages- * - Session-based authentication via cookies- *- * Message types (from Figma's schema):- * 0 = JOIN_START - Server sends session info- * 1 = NODE_CHANGES - Create/update/delete nodes- * 2 = USER_CHANGES - User presence updates- * 3 = JOIN_END - Initial sync complete- * 4 = SIGNAL - Various metadata (reconnect info, etc.)- * 5 = STYLE - Style updates- * ...and more- *- * Wire format:- * All messages are Zstd-compressed Kiwi-encoded binary data.- * Zstd magic bytes: 0x28 0xB5 0x2F 0xFD- */--export const MESSAGE_TYPES = {- JOIN_START: 0,- NODE_CHANGES: 1,- USER_CHANGES: 2,- JOIN_END: 3,- SIGNAL: 4,- STYLE: 5,- STYLE_SET: 6,- JOIN_START_SKIP_RELOAD: 7,- NOTIFY_SHOULD_UPGRADE: 8,- UPGRADE_DONE: 9,- UPGRADE_REFRESH: 10,- SCENE_GRAPH_QUERY: 11,- SCENE_GRAPH_REPLY: 12,- DIFF: 13,- CLIENT_BROADCAST: 14-} as const--export const NODE_TYPES = {- NONE: 0,- DOCUMENT: 1,- CANVAS: 2,- GROUP: 3,- FRAME: 4,- BOOLEAN_OPERATION: 5,- VECTOR: 6,- STAR: 7,- LINE: 8,- ELLIPSE: 9,- RECTANGLE: 10,- REGULAR_POLYGON: 11,- ROUNDED_RECTANGLE: 12,- TEXT: 13,- SLICE: 14,- SYMBOL: 15,- INSTANCE: 16,- STICKY: 17,- SHAPE_WITH_TEXT: 18,- CONNECTOR: 19,- CODE_BLOCK: 20,- WIDGET: 21,- STAMP: 22,- MEDIA: 23,- HIGHLIGHT: 24,- SECTION: 25,- SECTION_OVERLAY: 26,- WASHI_TAPE: 27,- VARIABLE: 28-} as const--export const NODE_PHASES = {- CREATED: 0,- REMOVED: 1-} as const--export const BLEND_MODES = {- PASS_THROUGH: 0,- NORMAL: 1,- DARKEN: 2,- MULTIPLY: 3,- LINEAR_BURN: 4,- COLOR_BURN: 5,- LIGHTEN: 6,- SCREEN: 7,- LINEAR_DODGE: 8,- COLOR_DODGE: 9,- OVERLAY: 10,- SOFT_LIGHT: 11,- HARD_LIGHT: 12,- DIFFERENCE: 13,- EXCLUSION: 14,- HUE: 15,- SATURATION: 16,- COLOR: 17,- LUMINOSITY: 18-} as const--export const PAINT_TYPES = {- SOLID: 0,- GRADIENT_LINEAR: 1,- GRADIENT_RADIAL: 2,- GRADIENT_ANGULAR: 3,- GRADIENT_DIAMOND: 4,- IMAGE: 5,- EMOJI: 6,- VIDEO: 7-} as const--/**- * Zstd magic bytes- */-export const ZSTD_MAGIC = new Uint8Array([0x28, 0xb5, 0x2f, 0xfd])--// ============================================================================-// Kiwi Binary Format Constants-// ============================================================================--/**- * Kiwi uses field numbers to identify message fields.- * Field 1 with value = message type indicates the message kind.- */-export const KIWI = {- /** First byte of valid Kiwi messages (field number 1) */- MESSAGE_MARKER: 1,-- /** Field number for sessionID in JOIN_START message */- SESSION_ID_FIELD: 2,-- /** Varint continuation bit (MSB set = more bytes follow) */- VARINT_CONTINUE_BIT: 0x80,-- /** Varint value mask (lower 7 bits contain data) */- VARINT_VALUE_MASK: 0x7f,-- /** Bits per varint byte */- VARINT_BITS_PER_BYTE: 7-} as const--/**- * Valid session ID range (based on observed Figma behavior)- */-export const SESSION_ID = {- MIN: 10000,- MAX: 1000000-} as const--/**- * Parse a varint from a Uint8Array at given position- * Returns [value, newPosition]- */-export function parseVarint(data: Uint8Array, pos: number): [number, number] {- let value = 0- let shift = 0-- while (pos < data.length) {- const byte = data[pos]- if (byte === undefined) break- pos++- value |= (byte & KIWI.VARINT_VALUE_MASK) << shift-- if (!(byte & KIWI.VARINT_CONTINUE_BIT)) {- break- }- shift += KIWI.VARINT_BITS_PER_BYTE- }-- return [value, pos]-}--/**- * Check if data is a valid Kiwi message- */-export function isKiwiMessage(data: Uint8Array): boolean {- return data.length >= 2 && data[0] === KIWI.MESSAGE_MARKER-}--/**- * Get message type from Kiwi message- */-export function getKiwiMessageType(data: Uint8Array): number | null {- if (!isKiwiMessage(data)) return null- return data[1] ?? null-}--/**- * fig-wire header magic (first 8 bytes of some messages)- */-export const FIG_WIRE_MAGIC = 'fig-wire'--/**- * Check if data is Zstd-compressed- */-export function isZstdCompressed(data: Uint8Array): boolean {- return (- data.length >= 4 && data[0] === 0x28 && data[1] === 0xb5 && data[2] === 0x2f && data[3] === 0xfd- )-}--/**- * Check if data has fig-wire header- */-export function hasFigWireHeader(data: Uint8Array): boolean {- if (data.length < 8) return false- const header = new TextDecoder().decode(data.slice(0, 8))- return header === FIG_WIRE_MAGIC-}--/**- * Skip fig-wire header and find zstd data- * Header format: "fig-wire" (8 bytes) + version (4 bytes LE) + zstd data- */-export function skipFigWireHeader(data: Uint8Array): Uint8Array {- if (!hasFigWireHeader(data)) return data- // Skip 8 bytes header + 4 bytes version- return data.slice(12)-}--/**- * Current multiplayer protocol version- */-export const PROTOCOL_VERSION = 151--/**- * Build WebSocket URL for Figma multiplayer- */-export function buildMultiplayerUrl(fileKey: string, trackingId?: string): string {- const params = new URLSearchParams({- role: 'editor',- version: String(PROTOCOL_VERSION),- recentReload: '0',- tracking_session_id: trackingId || `ws-${Date.now()}`- })- return `wss://www.figma.com/api/multiplayer/${fileKey}?${params}`-}+export {+ MESSAGE_TYPES,+ NODE_TYPES,+ NODE_PHASES,+ BLEND_MODES,+ PAINT_TYPES,+ PROTOCOL_VERSION,+ KIWI,+ SESSION_ID,+ ZSTD_MAGIC,+ FIG_WIRE_MAGIC,+ buildMultiplayerUrl,+ isZstdCompressed,+ hasFigWireHeader,+ skipFigWireHeader,+ isKiwiMessage,+ getKiwiMessageType,+ parseVarint+} from '@open-pencil/core'diff --git a/src/kiwi/schema.ts b/src/kiwi/schema.tsdeleted file mode 100644index c9d56990d..000000000--- a/src/kiwi/schema.ts+++ /dev/null@@ -1,2178 +0,0 @@-import { parseSchema } from './kiwi-schema'--const schemaText = `-package Fig;--enum MessageType {- JOIN_START = 0;- NODE_CHANGES = 1;- USER_CHANGES = 2;- JOIN_END = 3;- SIGNAL = 4;- STYLE = 5;- STYLE_SET = 6;- JOIN_START_SKIP_RELOAD = 7;- NOTIFY_SHOULD_UPGRADE = 8;- UPGRADE_DONE = 9;- UPGRADE_REFRESH = 10;- SCENE_GRAPH_QUERY = 11;- SCENE_GRAPH_REPLY = 12;- DIFF = 13;- CLIENT_BROADCAST = 14;-}--enum Axis {- X = 0;- Y = 1;-}--enum Access {- READ_ONLY = 0;- READ_WRITE = 1;-}--enum NodePhase {- CREATED = 0;- REMOVED = 1;-}--enum WindingRule {- NONZERO = 0;- ODD = 1;-}--enum NodeType {- NONE = 0;- DOCUMENT = 1;- CANVAS = 2;- GROUP = 3;- FRAME = 4;- BOOLEAN_OPERATION = 5;- VECTOR = 6;- STAR = 7;- LINE = 8;- ELLIPSE = 9;- RECTANGLE = 10;- REGULAR_POLYGON = 11;- ROUNDED_RECTANGLE = 12;- TEXT = 13;- SLICE = 14;- SYMBOL = 15;- INSTANCE = 16;- STICKY = 17;- SHAPE_WITH_TEXT = 18;- CONNECTOR = 19;- CODE_BLOCK = 20;- WIDGET = 21;- STAMP = 22;- MEDIA = 23;- HIGHLIGHT = 24;- SECTION = 25;- SECTION_OVERLAY = 26;- WASHI_TAPE = 27;- VARIABLE = 28;-}--enum ShapeWithTextType {- SQUARE = 0;- ELLIPSE = 1;- DIAMOND = 2;- TRIANGLE_UP = 3;- TRIANGLE_DOWN = 4;- ROUNDED_RECTANGLE = 5;- PARALLELOGRAM_RIGHT = 6;- PARALLELOGRAM_LEFT = 7;- ENG_DATABASE = 8;- ENG_QUEUE = 9;- ENG_FILE = 10;- ENG_FOLDER = 11;-}--enum BlendMode {- PASS_THROUGH = 0;- NORMAL = 1;- DARKEN = 2;- MULTIPLY = 3;- LINEAR_BURN = 4;- COLOR_BURN = 5;- LIGHTEN = 6;- SCREEN = 7;- LINEAR_DODGE = 8;- COLOR_DODGE = 9;- OVERLAY = 10;- SOFT_LIGHT = 11;- HARD_LIGHT = 12;- DIFFERENCE = 13;- EXCLUSION = 14;- HUE = 15;- SATURATION = 16;- COLOR = 17;- LUMINOSITY = 18;-}--enum PaintType {- SOLID = 0;- GRADIENT_LINEAR = 1;- GRADIENT_RADIAL = 2;- GRADIENT_ANGULAR = 3;- GRADIENT_DIAMOND = 4;- IMAGE = 5;- EMOJI = 6;-}--enum ImageScaleMode {- STRETCH = 0;- FIT = 1;- FILL = 2;- TILE = 3;-}--enum EffectType {- INNER_SHADOW = 0;- DROP_SHADOW = 1;- FOREGROUND_BLUR = 2;- BACKGROUND_BLUR = 3;-}--enum TextCase {- ORIGINAL = 0;- UPPER = 1;- LOWER = 2;- TITLE = 3;- SMALL_CAPS = 4;- SMALL_CAPS_FORCED = 5;-}--enum TextDecoration {- NONE = 0;- UNDERLINE = 1;- STRIKETHROUGH = 2;-}--enum NumberUnits {- RAW = 0;- PIXELS = 1;- PERCENT = 2;-}--enum ConstraintType {- MIN = 0;- CENTER = 1;- MAX = 2;- STRETCH = 3;- SCALE = 4;- FIXED_MIN = 5;- FIXED_MAX = 6;-}--enum StrokeAlign {- CENTER = 0;- INSIDE = 1;- OUTSIDE = 2;-}--enum StrokeCap {- NONE = 0;- ROUND = 1;- SQUARE = 2;- ARROW_LINES = 3;- ARROW_EQUILATERAL = 4;- DIAMOND_FILLED = 5;- TRIANGLE_FILLED = 6;- HIGHLIGHT = 7;- WASHI_TAPE_1 = 8;- WASHI_TAPE_2 = 9;- WASHI_TAPE_3 = 10;- WASHI_TAPE_4 = 11;- WASHI_TAPE_5 = 12;- WASHI_TAPE_6 = 13;- CIRCLE_FILLED = 14;-}--enum StrokeJoin {- MITER = 0;- BEVEL = 1;- ROUND = 2;-}--enum BooleanOperation {- UNION = 0;- INTERSECT = 1;- SUBTRACT = 2;- XOR = 3;-}--enum TextAlignHorizontal {- LEFT = 0;- CENTER = 1;- RIGHT = 2;- JUSTIFIED = 3;-}--enum TextAlignVertical {- TOP = 0;- CENTER = 1;- BOTTOM = 2;-}--enum MouseCursor {- DEFAULT = 0;- CROSSHAIR = 1;- EYEDROPPER = 2;- HAND = 3;- PAINT_BUCKET = 4;- PEN = 5;- PENCIL = 6;- MARKER = 7;- ERASER = 8;- HIGHLIGHTER = 9;-}--enum VectorMirror {- NONE = 0;- ANGLE = 1;- ANGLE_AND_LENGTH = 2;-}--enum DashMode {- CLIP = 0;- STRETCH = 1;-}--enum ImageType {- PNG = 0;- JPEG = 1;- SVG = 2;- PDF = 3;-}--enum ExportConstraintType {- CONTENT_SCALE = 0;- CONTENT_WIDTH = 1;- CONTENT_HEIGHT = 2;-}--enum LayoutGridType {- MIN = 0;- CENTER = 1;- STRETCH = 2;- MAX = 3;-}--enum LayoutGridPattern {- STRIPES = 0;- GRID = 1;-}--enum TextAutoResize {- NONE = 0;- WIDTH_AND_HEIGHT = 1;- HEIGHT = 2;-}--enum TextTruncation {- DISABLED = 0;- ENDING = 1;-}--enum StyleSetType {- PERSONAL = 0;- TEAM = 1;- CUSTOM = 2;- FREQUENCY = 3;- TEMPORARY = 4;-}--enum StyleSetContentType {- SOLID = 0;- GRADIENT = 1;- IMAGE = 2;-}--enum StackMode {- NONE = 0;- HORIZONTAL = 1;- VERTICAL = 2;- GRID = 3;-}--enum GridTrackSizeType {- FIXED = 0;- FLEX = 1;- HUG = 2;-}--message GridTrackSize {- GridTrackSizeType type = 1;- float value = 2;-}--enum StackAlign {- MIN = 0;- CENTER = 1;- MAX = 2;- BASELINE = 3;-}--enum StackCounterAlign {- MIN = 0;- CENTER = 1;- MAX = 2;- STRETCH = 3;- AUTO = 4;- BASELINE = 5;-}--enum StackJustify {- MIN = 0;- CENTER = 1;- MAX = 2;- SPACE_BETWEEN = 3;-}--enum StackSize {- FIXED = 0;- RESIZE_TO_FIT = 1;- RESIZE_TO_FIT_WITH_IMPLICIT_SIZE = 2;-}--enum StackPositioning {- AUTO = 0;- ABSOLUTE = 1;-}--enum ConnectionType {- NONE = 0;- INTERNAL_NODE = 1;- URL = 2;- BACK = 3;- CLOSE = 4;- SET_VARIABLE = 5;-}--enum InteractionType {- ON_CLICK = 0;- AFTER_TIMEOUT = 1;- MOUSE_IN = 2;- MOUSE_OUT = 3;- ON_HOVER = 4;- MOUSE_DOWN = 5;- MOUSE_UP = 6;- ON_PRESS = 7;- NONE = 8;- DRAG = 9;- ON_KEY_DOWN = 10;- ON_VOICE = 11;-}--enum TransitionType {- INSTANT_TRANSITION = 0;- DISSOLVE = 1;- FADE = 2;- SLIDE_FROM_LEFT = 3;- SLIDE_FROM_RIGHT = 4;- SLIDE_FROM_TOP = 5;- SLIDE_FROM_BOTTOM = 6;- PUSH_FROM_LEFT = 7;- PUSH_FROM_RIGHT = 8;- PUSH_FROM_TOP = 9;- PUSH_FROM_BOTTOM = 10;- MOVE_FROM_LEFT = 11;- MOVE_FROM_RIGHT = 12;- MOVE_FROM_TOP = 13;- MOVE_FROM_BOTTOM = 14;- SLIDE_OUT_TO_LEFT = 15;- SLIDE_OUT_TO_RIGHT = 16;- SLIDE_OUT_TO_TOP = 17;- SLIDE_OUT_TO_BOTTOM = 18;- MOVE_OUT_TO_LEFT = 19;- MOVE_OUT_TO_RIGHT = 20;- MOVE_OUT_TO_TOP = 21;- MOVE_OUT_TO_BOTTOM = 22;- MAGIC_MOVE = 23;- SMART_ANIMATE = 24;- SCROLL_ANIMATE = 25;-}--enum EasingType {- IN_CUBIC = 0;- OUT_CUBIC = 1;- INOUT_CUBIC = 2;- LINEAR = 3;- IN_BACK_CUBIC = 4;- OUT_BACK_CUBIC = 5;- INOUT_BACK_CUBIC = 6;- CUSTOM_CUBIC = 7;- SPRING = 8;- GENTLE_SPRING = 9;- CUSTOM_SPRING = 10;- SPRING_PRESET_ONE = 11;- SPRING_PRESET_TWO = 12;- SPRING_PRESET_THREE = 13;-}--enum ScrollDirection {- NONE = 0;- HORIZONTAL = 1;- VERTICAL = 2;- BOTH = 3;-}--enum ScrollContractedState {- EXPANDED = 0;- CONTRACTED = 1;-}--struct GUID {- uint sessionID;- uint localID;-}--struct Color {- float r;- float g;- float b;- float a;-}--struct Vector {- float x;- float y;-}--struct Rect {- float x;- float y;- float w;- float h;-}--struct ColorStop {- Color color;- float position;-}--struct Matrix {- float m00;- float m01;- float m02;- float m10;- float m11;- float m12;-}--struct ParentIndex {- GUID guid;- string position;-}--struct Number {- float value;- NumberUnits units;-}--struct FontName {- string family;- string style;- string postscript;-}--enum FontVariantNumericFigure {- NORMAL = 0;- LINING = 1;- OLDSTYLE = 2;-}--enum FontVariantNumericSpacing {- NORMAL = 0;- PROPORTIONAL = 1;- TABULAR = 2;-}--enum FontVariantNumericFraction {- NORMAL = 0;- DIAGONAL = 1;- STACKED = 2;-}--enum FontVariantCaps {- NORMAL = 0;- SMALL = 1;- ALL_SMALL = 2;- PETITE = 3;- ALL_PETITE = 4;- UNICASE = 5;- TITLING = 6;-}--enum FontVariantPosition {- NORMAL = 0;- SUB = 1;- SUPER = 2;-}--enum FontStyle {- NORMAL = 0;- ITALIC = 1;-}--enum OpenTypeFeature {- PCAP = 0;- C2PC = 1;- CASE = 2;- CPSP = 3;- TITL = 4;- UNIC = 5;- ZERO = 6;- SINF = 7;- ORDN = 8;- AFRC = 9;- DNOM = 10;- NUMR = 11;- LIGA = 12;- CLIG = 13;- DLIG = 14;- HLIG = 15;- RLIG = 16;- AALT = 17;- CALT = 18;- RCLT = 19;- SALT = 20;- RVRN = 21;- VERT = 22;- SWSH = 23;- CSWH = 24;- NALT = 25;- CCMP = 26;- STCH = 27;- HIST = 28;- SIZE = 29;- ORNM = 30;- ITAL = 31;- RAND = 32;- DTLS = 33;- FLAC = 34;- MGRK = 35;- SSTY = 36;- KERN = 37;- FWID = 38;- HWID = 39;- HALT = 40;- TWID = 41;- QWID = 42;- PWID = 43;- JUST = 44;- LFBD = 45;- OPBD = 46;- RTBD = 47;- PALT = 48;- PKNA = 49;- LTRA = 50;- LTRM = 51;- RTLA = 52;- RTLM = 53;- ABRV = 54;- ABVM = 55;- ABVS = 56;- VALT = 57;- VHAL = 58;- BLWF = 59;- BLWM = 60;- BLWS = 61;- AKHN = 62;- CJCT = 63;- CFAR = 64;- CPCT = 65;- CURS = 66;- DIST = 67;- EXPT = 68;- FALT = 69;- FINA = 70;- FIN2 = 71;- FIN3 = 72;- HALF = 73;- HALN = 74;- HKNA = 75;- HNGL = 76;- HOJO = 77;- INIT = 78;- ISOL = 79;- JP78 = 80;- JP83 = 81;- JP90 = 82;- JP04 = 83;- LJMO = 84;- LOCL = 85;- MARK = 86;- MEDI = 87;- MED2 = 88;- MKMK = 89;- NLCK = 90;- NUKT = 91;- PREF = 92;- PRES = 93;- VPAL = 94;- PSTF = 95;- PSTS = 96;- RKRF = 97;- RPHF = 98;- RUBY = 99;- SMPL = 100;- TJMO = 101;- TNAM = 102;- TRAD = 103;- VATU = 104;- VJMO = 105;- VKNA = 106;- VKRN = 107;- VRTR = 108;- VRT2 = 109;- SS01 = 110;- SS02 = 111;- SS03 = 112;- SS04 = 113;- SS05 = 114;- SS06 = 115;- SS07 = 116;- SS08 = 117;- SS09 = 118;- SS10 = 119;- SS11 = 120;- SS12 = 121;- SS13 = 122;- SS14 = 123;- SS15 = 124;- SS16 = 125;- SS17 = 126;- SS18 = 127;- SS19 = 128;- SS20 = 129;- CV01 = 130;- CV02 = 131;- CV03 = 132;- CV04 = 133;- CV05 = 134;- CV06 = 135;- CV07 = 136;- CV08 = 137;- CV09 = 138;- CV10 = 139;- CV11 = 140;- CV12 = 141;- CV13 = 142;- CV14 = 143;- CV15 = 144;- CV16 = 145;- CV17 = 146;- CV18 = 147;- CV19 = 148;- CV20 = 149;- CV21 = 150;- CV22 = 151;- CV23 = 152;- CV24 = 153;- CV25 = 154;- CV26 = 155;- CV27 = 156;- CV28 = 157;- CV29 = 158;- CV30 = 159;- CV31 = 160;- CV32 = 161;- CV33 = 162;- CV34 = 163;- CV35 = 164;- CV36 = 165;- CV37 = 166;- CV38 = 167;- CV39 = 168;- CV40 = 169;- CV41 = 170;- CV42 = 171;- CV43 = 172;- CV44 = 173;- CV45 = 174;- CV46 = 175;- CV47 = 176;- CV48 = 177;- CV49 = 178;- CV50 = 179;- CV51 = 180;- CV52 = 181;- CV53 = 182;- CV54 = 183;- CV55 = 184;- CV56 = 185;- CV57 = 186;- CV58 = 187;- CV59 = 188;- CV60 = 189;- CV61 = 190;- CV62 = 191;- CV63 = 192;- CV64 = 193;- CV65 = 194;- CV66 = 195;- CV67 = 196;- CV68 = 197;- CV69 = 198;- CV70 = 199;- CV71 = 200;- CV72 = 201;- CV73 = 202;- CV74 = 203;- CV75 = 204;- CV76 = 205;- CV77 = 206;- CV78 = 207;- CV79 = 208;- CV80 = 209;- CV81 = 210;- CV82 = 211;- CV83 = 212;- CV84 = 213;- CV85 = 214;- CV86 = 215;- CV87 = 216;- CV88 = 217;- CV89 = 218;- CV90 = 219;- CV91 = 220;- CV92 = 221;- CV93 = 222;- CV94 = 223;- CV95 = 224;- CV96 = 225;- CV97 = 226;- CV98 = 227;- CV99 = 228;-}--struct ExportConstraint {- ExportConstraintType type;- float value;-}--struct GUIDMapping {- GUID from;- GUID to;-}--struct Blob {- byte[] bytes;-}--message Image {- byte[] hash = 1;- string name = 2;- uint dataBlob = 3;-}--message Video {- byte[] hash = 1;- string s3Url = 2;-}--struct FilterColorAdjust {- float tint;- float shadows;- float highlights;- float detail;- float exposure;- float vignette;- float temperature;- float vibrance;-}--message PaintFilterMessage {- float tint = 1;- float shadows = 2;- float highlights = 3;- float detail = 4 [deprecated];- float exposure = 5;- float vignette = 6 [deprecated];- float temperature = 7;- float vibrance = 8;- float contrast = 9;- float brightness = 10 [deprecated];-}--// Variable binding embedded in Paint - discovered via WS sniffing 2026-01-// Figma wire format: 15 01 04 01 {sessionID varint} {localID varint}-// - 15 = field 21 in Paint-// - 01 = always 1 (binding type for color)-// - 04 = field 4-// - 01 = always 1 (flag)-// - then GUID as raw sessionID + localID varints (no field numbers)-// NOTE: kiwi-schema cannot produce this exact format, handled manually in codec-message PaintVariableBinding {- uint bindingType = 1; // Always 1 for color- uint flag = 2; // Placeholder- uint flag2 = 3; // Placeholder- GUID variableID = 4; // Variable GUID-}--message Paint {- PaintType type = 1;- Color color = 2;- float opacity = 3;- bool visible = 4;- BlendMode blendMode = 5;- ColorStop[] stops = 6;- Matrix transform = 7;- Image image = 8;- Image imageThumbnail = 9;- Image animatedImage = 16;- uint animationFrame = 17;- ImageScaleMode imageScaleMode = 10;- float rotation = 11;- float scale = 12;- FilterColorAdjust filterColorAdjust = 13 [deprecated];- PaintFilterMessage paintFilter = 14;- uint[] emojiCodePoints = 15;- Video video = 18;- uint originalImageWidth = 19;- uint originalImageHeight = 20;- PaintVariableBinding variableBinding = 21; // Not in fig-kiwi. Discovered via WS sniffing 2026-01-}--message FontMetaData {- FontName key = 1;- float fontLineHeight = 2;- byte[] fontDigest = 3;- FontStyle fontStyle = 4;- int fontWeight = 5;-}--message FontVariation {- uint axisTag = 1;- string axisName = 2;- float value = 3;-}--message TextData {- string characters = 1;- uint[] characterStyleIDs = 2;- NodeChange[] styleOverrideTable = 3;- Vector layoutSize = 4;- Baseline[] baselines = 5;- Glyph[] glyphs = 6;- Decoration[] decorations = 7;- uint layoutVersion = 8;- FontMetaData[] fontMetaData = 9;- FontName[] fallbackFonts = 10;- HyperlinkBox[] hyperlinkBoxes = 11;- TextLineData[] lines = 12;- int truncationStartIndex = 13;- float truncatedHeight = 14;-}--message HyperlinkBox {- Rect bounds = 1;- string url = 2;- GUID guid = 3;- int hyperlinkID = 4;-}--message Baseline {- Vector position = 1;- float width = 2;- float lineY = 3;- float lineHeight = 4;- float lineAscent = 7;- uint firstCharacter = 5;- uint endCharacter = 6;-}--message Glyph {- uint commandsBlob = 1;- Vector position = 2;- uint styleID = 3;- float fontSize = 4;- uint firstCharacter = 5;- float advance = 6;-}--message Decoration {- Rect[] rects = 1;- uint styleID = 2;-}--message VectorData {- uint vectorNetworkBlob = 1;- Vector normalizedSize = 2;- NodeChange[] styleOverrideTable = 3;-}--message GUIDPath {- GUID[] guids = 1;-}--message SymbolData {- GUID symbolID = 1;- NodeChange[] symbolOverrides = 2;- float uniformScaleFactor = 3;-}--message GUIDPathMapping {- GUID id = 1;- GUIDPath path = 2;-}--message NodeGenerationData {- NodeChange[] overrides = 1;-}--message DerivedImmutableFrameData {- NodeChange[] overrides = 1;- uint version = 2;-}--message SharedSymbolReference {- string fileKey = 1;- GUID symbolID = 2;- string versionHash = 3;- GUIDPathMapping[] guidPathMappings = 4;- byte[] bytes = 5;- GUIDMapping[] libraryGUIDToSubscribingGUID = 6 [deprecated];- string componentKey = 7;- GUIDPathMapping[] unflatteningMappings = 8;- bool isUnflattened = 9;-}--message SharedComponentMasterData {- string componentKey = 1;- GUIDPathMapping[] publishingGUIDPathToTeamLibraryGUID = 2;- bool isUnflattened = 3;-}--message InstanceOverrideStash {- GUIDPath overridePathOfSwappedInstance = 1;- string componentKey = 2;- NodeChange[] overrides = 3;-}--message InstanceOverrideStashV2 {- GUIDPath overridePathOfSwappedInstance = 1;- GUID localSymbolID = 2;- NodeChange[] overrides = 3;-}--message Effect {- EffectType type = 1;- Color color = 2;- Vector offset = 3;- float radius = 4;- bool visible = 5;- BlendMode blendMode = 6;- float spread = 7;- bool showShadowBehindNode = 8;-}--message TransitionInfo {- TransitionType type = 1;- float duration = 2;-}--enum PrototypeDeviceType {- NONE = 0;- PRESET = 1;- CUSTOM = 2;- PRESENTATION = 3;-}--enum DeviceRotation {- NONE = 0;- CCW_90 = 1;-}--message PrototypeDevice {- PrototypeDeviceType type = 1;- Vector size = 2;- string presetIdentifier = 3;- DeviceRotation rotation = 4;-}--enum OverlayPositionType {- CENTER = 0;- TOP_LEFT = 1;- TOP_CENTER = 2;- TOP_RIGHT = 3;- BOTTOM_LEFT = 4;- BOTTOM_CENTER = 5;- BOTTOM_RIGHT = 6;- MANUAL = 7;-}--enum OverlayBackgroundInteraction {- NONE = 0;- CLOSE_ON_CLICK_OUTSIDE = 1;-}--enum OverlayBackgroundType {- NONE = 0;- SOLID_COLOR = 1;-}--message OverlayBackgroundAppearance {- OverlayBackgroundType backgroundType = 1;- Color backgroundColor = 2;-}--enum NavigationType {- NAVIGATE = 0;- OVERLAY = 1;- SWAP = 2;- SWAP_STATE = 3;- SCROLL_TO = 4;-}--message ExportSettings {- string suffix = 1;- ImageType imageType = 2;- ExportConstraint constraint = 3;- bool svgDataName = 4;- ExportSVGIDMode svgIDMode = 5;- bool svgOutlineText = 6;- bool contentsOnly = 7;- bool svgForceStrokeMasks = 8;- bool useAbsoluteBounds = 9;-}--enum ExportSVGIDMode {- IF_NEEDED = 0;- ALWAYS = 1;-}--message LayoutGrid {- LayoutGridType type = 1;- Axis axis = 2;- bool visible = 3;- int numSections = 4;- float offset = 5;- float sectionSize = 6;- float gutterSize = 7;- Color color = 8;- LayoutGridPattern pattern = 9;-}--message Guide {- Axis axis = 1;- float offset = 2;- GUID guid = 3;-}--message Path {- WindingRule windingRule = 1;- uint commandsBlob = 2;- uint styleID = 3;-}--enum StyleType {- NONE = 0;- FILL = 1;- STROKE = 2;- TEXT = 3;- EFFECT = 4;- EXPORT = 5;- GRID = 6;-}--message SharedStyleReference {- string styleKey = 1;- string versionHash = 2;-}--message SharedStyleMasterData {- string styleKey = 1;- string sortPosition = 2;- string fileKey = 3;-}--enum ScrollBehavior {- SCROLLS = 0;- FIXED_WHEN_CHILD_OF_SCROLLING_FRAME = 1;-}--message ArcData {- float startingAngle = 1;- float endingAngle = 2;- float innerRadius = 3;-}--message SymbolLink {- string uri = 1;- string displayName = 2;- string displayText = 3;-}--message PluginData {- string pluginID = 1;- string value = 2;- string key = 3;-}--message PluginRelaunchData {- string pluginID = 1;- string message = 2;- string command = 3;- bool isDeleted = 4;-}--enum ConnectorMagnet {- NONE = 0;- AUTO = 1;- TOP = 2;- LEFT = 3;- BOTTOM = 4;- RIGHT = 5;-}--message ConnectorEndpoint {- GUID endpointNodeID = 1;- Vector position = 2;- ConnectorMagnet magnet = 3;-}--message ConnectorControlPoint {- Vector position = 1;- Vector axis = 2;-}--enum ConnectorTextSection {- MIDDLE_TO_START = 0;- MIDDLE_TO_END = 1;-}--message ConnectorTextMidpoint {- ConnectorTextSection section = 1;- float offset = 2;-}--enum ConnectorLineStyle {- ELBOWED = 0;- STRAIGHT = 1;-}--message LibraryMoveInfo {- string oldKey = 1;- string pasteFileKey = 2;-}--message LibraryMoveHistoryItem {- GUID sourceNodeId = 1;- string sourceComponentKey = 2;-}--message WidgetPointer {- GUID nodeId = 1;-}--enum EditorType {- DESIGN = 0;- WHITEBOARD = 1;-}--message NodeChange {- GUID guid = 1;- uint guidTag = 53 [deprecated];- NodePhase phase = 2;- uint phaseTag = 54 [deprecated];- ParentIndex parentIndex = 3;- uint parentIndexTag = 55 [deprecated];- NodeType type = 4;- uint typeTag = 56 [deprecated];- string name = 5;- uint nameTag = 57 [deprecated];- bool visible = 6;- uint visibleTag = 58 [deprecated];- bool locked = 7;- uint lockedTag = 59 [deprecated];- float opacity = 8;- uint opacityTag = 60 [deprecated];- BlendMode blendMode = 9;- uint blendModeTag = 61 [deprecated];- uint count = 10;- uint countTag = 62 [deprecated];- Vector size = 11;- uint sizeTag = 63 [deprecated];- Matrix transform = 12;- uint transformTag = 64 [deprecated];- float[] dashPattern = 13;- uint dashPatternTag = 65 [deprecated];- bool autoRename = 14;- uint autoRenameTag = 66 [deprecated];- bool backgroundEnabled = 15;- uint backgroundEnabledTag = 67 [deprecated];- bool mask = 16;- uint maskTag = 68 [deprecated];- bool exportContentsOnly = 17;- uint exportContentsOnlyTag = 69 [deprecated];- bool maskIsOutline = 18;- uint maskIsOutlineTag = 70 [deprecated];- float backgroundOpacity = 19;- uint backgroundOpacityTag = 71 [deprecated];- float cornerRadius = 20;- uint cornerRadiusTag = 72 [deprecated];- float fontSize = 21;- uint fontSizeTag = 73 [deprecated];- float paragraphIndent = 22;- uint paragraphIndentTag = 74 [deprecated];- float paragraphSpacing = 23;- uint paragraphSpacingTag = 75 [deprecated];- float starInnerScale = 24;- uint starInnerScaleTag = 76 [deprecated];- float miterLimit = 25;- uint miterLimitTag = 77 [deprecated];- float strokeWeight = 26;- uint strokeWeightTag = 78 [deprecated];- float textTracking = 27;- uint textTrackingTag = 79 [deprecated];- ConstraintType horizontalConstraint = 28;- uint horizontalConstraintTag = 80 [deprecated];- StrokeAlign strokeAlign = 29;- uint strokeAlignTag = 81 [deprecated];- StrokeCap strokeCap = 30;- uint strokeCapTag = 82 [deprecated];- StrokeJoin strokeJoin = 31;- uint strokeJoinTag = 83 [deprecated];- TextAlignHorizontal textAlignHorizontal = 32;- uint textAlignHorizontalTag = 84 [deprecated];- TextAlignVertical textAlignVertical = 33;- uint textAlignVerticalTag = 85 [deprecated];- TextCase textCase = 34;- uint textCaseTag = 86 [deprecated];- TextDecoration textDecoration = 35;- uint textDecorationTag = 87 [deprecated];- BooleanOperation booleanOperation = 36;- uint booleanOperationTag = 88 [deprecated];- ConstraintType verticalConstraint = 37;- uint verticalConstraintTag = 89 [deprecated];- Paint[] fillPaints = 38;- uint fillPaintsTag = 90 [deprecated];- Paint[] strokePaints = 39;- uint strokePaintsTag = 91 [deprecated];- Number lineHeight = 40;- uint lineHeightTag = 92 [deprecated];- FontName fontName = 41;- uint fontNameTag = 93 [deprecated];- TextData textData = 42;- uint textDataTag = 94 [deprecated];- Effect[] effects = 43;- uint effectsTag = 95 [deprecated];- VectorMirror handleMirroring = 44;- uint handleMirroringTag = 96 [deprecated];- ExportSettings[] exportSettings = 45;- uint exportSettingsTag = 97 [deprecated];- TextAutoResize textAutoResize = 46;- uint textAutoResizeTag = 98 [deprecated];- LayoutGrid[] layoutGrids = 47;- uint layoutGridsTag = 99 [deprecated];- VectorData vectorData = 48;- uint vectorDataTag = 100 [deprecated];- uint styleID = 49;- uint styleIDTag = 101 [deprecated];- Color backgroundColor = 50;- uint backgroundColorTag = 102 [deprecated];- Path[] fillGeometry = 51;- uint fillGeometryTag = 103 [deprecated];- Path[] strokeGeometry = 52;- uint strokeGeometryTag = 104 [deprecated];- StackMode stackMode = 105;- uint stackModeTag = 106 [deprecated];- float stackSpacing = 107;- uint stackSpacingTag = 108 [deprecated];- float stackPadding = 109;- uint stackPaddingTag = 110 [deprecated];- GUIDPath guidPath = 111;- uint guidPathTag = 112 [deprecated];- SymbolData symbolData = 113;- uint symbolDataTag = 114 [deprecated];- bool frameMaskDisabled = 115;- uint frameMaskDisabledTag = 116 [deprecated];- bool resizeToFit = 117;- uint resizeToFitTag = 118 [deprecated];- bool exportBackgroundDisabled = 119;- StackCounterAlign stackCounterAlign = 120;- StackJustify stackJustify = 121;- SharedSymbolReference sharedSymbolReference = 122;- bool isSymbolPublishable = 123;- GUIDPathMapping[] sharedSymbolMappings = 124;- NodeChange[] derivedSymbolData = 125;- string sharedSymbolVersion = 126;- bool fontVariantCommonLigatures = 127;- bool fontVariantContextualLigatures = 128;- bool fontVariantDiscretionaryLigatures = 129;- bool fontVariantHistoricalLigatures = 130;- bool fontVariantOrdinal = 131;- bool fontVariantSlashedZero = 132;- FontVariantNumericFigure fontVariantNumericFigure = 133;- FontVariantNumericSpacing fontVariantNumericSpacing = 134;- FontVariantNumericFraction fontVariantNumericFraction = 135;- FontVariantCaps fontVariantCaps = 136;- FontVariantPosition fontVariantPosition = 137;- Guide[] guides = 138;- GUID transitionNodeID = 139;- GUID prototypeStartNodeID = 140;- Color prototypeBackgroundColor = 141;- bool internalOnly = 142;- GUID overriddenSymbolID = 143;- string symbolDescription = 144;- float rectangleTopLeftCornerRadius = 145;- float rectangleTopRightCornerRadius = 146;- float rectangleBottomLeftCornerRadius = 147;- float rectangleBottomRightCornerRadius = 148;- bool rectangleCornerRadiiIndependent = 149;- bool rectangleCornerToolIndependent = 150;- bool proportionsConstrained = 151;- SharedComponentMasterData sharedComponentMasterData = 152;- TransitionInfo transitionInfo = 153 [deprecated];- TransitionType transitionType = 154;- float transitionDuration = 155;- EasingType easingType = 156;- ScrollDirection scrollDirection = 159;- float cornerSmoothing = 160;- GUID inheritFillStyleID = 158;- GUID inheritStrokeStyleID = 162;- GUID inheritTextStyleID = 167;- GUID inheritExportStyleID = 168;- GUID inheritEffectStyleID = 169;- GUID inheritGridStyleID = 170;- GUID inheritFillStyleIDForStroke = 185;- bool isFillStyle = 157 [deprecated];- bool isStrokeStyle = 161 [deprecated];- StyleType styleType = 163;- string styleDescription = 191;- GUIDPathMapping[] unflatteningMappings = 164;- Number letterSpacing = 165;- Vector scrollOffset = 166 [deprecated];- string version = 171;- SharedStyleMasterData sharedStyleMasterData = 172;- SharedStyleReference sharedStyleReference = 173;- bool isPublishable = 174;- bool exportTextAsSVGText = 175;- bool isSoftDeletedStyle = 176;- bool isNonUpdateable = 177;- ScrollContractedState scrollContractedState = 178 [deprecated];- Vector contractedSize = 179 [deprecated];- string fixedChildrenDivider = 180 [deprecated];- bool transitionPreserveScroll = 181;- ConnectionType connectionType = 182;- string connectionURL = 183;- PrototypeDevice prototypeDevice = 184;- ScrollBehavior scrollBehavior = 186;- InteractionType interactionType = 187;- float transitionTimeout = 188;- bool interactionMaintained = 189;- float interactionDuration = 190;- bool destinationIsOverlay = 192 [deprecated];- Paint[] backgroundPaints = 193;- GUID inheritFillStyleIDForBackground = 194;- ArcData arcData = 195;- int derivedSymbolDataLayoutVersion = 196;- NavigationType navigationType = 197;- OverlayPositionType overlayPositionType = 198;- Vector overlayRelativePosition = 199;- OverlayBackgroundInteraction overlayBackgroundInteraction = 200;- OverlayBackgroundAppearance overlayBackgroundAppearance = 201;- string fontVersion = 202;- uint textUserLayoutVersion = 203;- PluginData[] pluginData = 204;- OpenTypeFeature[] toggledOnOTFeatures = 205;- OpenTypeFeature[] toggledOffOTFeatures = 206;- bool transitionShouldSmartAnimate = 207;- StackAlign stackAlign = 208 [deprecated];- float stackHorizontalPadding = 209;- float stackVerticalPadding = 210;- StackSize stackWidth = 211 [deprecated];- StackSize stackHeight = 212 [deprecated];- GUID overrideKey = 213;- string publishFile = 214;- GUID publishID = 215;- string componentKey = 216;- bool isC2 = 217;- string publishedVersion = 218;- PluginRelaunchData[] pluginRelaunchData = 219;- bool containerSupportsFillStrokeAndCorners = 220;- StackSize stackCounterSizing = 221;- bool containersSupportFillStrokeAndCorners = 222 [deprecated];- Hyperlink hyperlink = 223;- KeyTrigger keyTrigger = 224;- bool isStateGroup = 225;- PrototypeInteraction[] prototypeInteractions = 226;- string voiceEventPhrase = 227;- GUIDPathMapping[] forceUnflatteningMappings = 228;- StackSize stackPrimarySizing = 229;- StackJustify stackPrimaryAlignItems = 230;- StackAlign stackCounterAlignItems = 231;- float stackChildPrimaryGrow = 232;- float stackPaddingRight = 233;- float stackPaddingBottom = 234;- GUID[] ancestorPathBeforeDeletion = 235;- StackCounterAlign stackChildAlignSelf = 236;- SymbolLink[] symbolLinks = 237;- StateGroupPropertyValueOrder[] stateGroupPropertyValueOrders = 238;- TextListData textListData = 239;- NodeGenerationData nodeGenerationData = 240;- ShapeWithTextType shapeWithTextType = 241;- ConnectorEndpoint connectorStart = 242;- ConnectorEndpoint connectorEnd = 243;- ConnectorLineStyle connectorLineStyle = 244;- StrokeCap connectorStartCap = 245;- StrokeCap connectorEndCap = 246;- float shapeUserHeight = 247;- InstanceOverrideStash[] overrideStash = 248;- PrototypeStartingPoint prototypeStartingPoint = 249;- InstanceOverrideStashV2[] overrideStashV2 = 250 [deprecated];- InternalEnumForTest internalEnumForTest = 251;- string originComponentKey = 252 [deprecated];- ConnectorControlPoint[] connectorControlPoints = 253;- DerivedImmutableFrameData derivedImmutableFrameData = 254;- ConnectorTextMidpoint connectorTextMidpoint = 255;- LibraryMoveInfo libraryMoveInfo = 256;- InternalDataForTest internalDataForTest = 257;- bool useAbsoluteBounds = 258 [deprecated];- CodeBlockLanguage codeBlockLanguage = 259;- FontVariation[] fontVariations = 260;- bool detachOpticalSizeFromFontSize = 261;- WidgetMetadata widgetMetadata = 262;- WidgetEvent[] widgetEvents = 263;- float listSpacing = 264;- WidgetPropertyMenuItem[] widgetPropertyMenuItems = 265;- ComponentPropDef[] componentPropDefs = 266;- ComponentPropRef[] componentPropRefs = 267;- ComponentPropAssignment[] componentPropAssignments = 268;- StackPositioning stackPositioning = 269;- EmbedData embedData = 270;- bool stackReverseZIndex = 271;- RichMediaData richMediaData = 272;- MultiplayerMap widgetSyncedState = 273;- uint widgetSyncCursor = 274 [deprecated];- WidgetDerivedSubtreeCursor widgetDerivedSubtreeCursor = 275 [deprecated];- WidgetPointer widgetCachedAncestor = 276;- MultiplayerMap renderedSyncedState = 277;- LinkPreviewData linkPreviewData = 278;- uint textBidiVersion = 279;- TextTruncation textTruncation = 280;- LibraryMoveHistoryItem[] libraryMoveHistory = 281;- bool shapeTruncates = 282;- bool sectionContentsHidden = 283;- bool simplifyInstancePanels = 284;- WidgetInputBehavior widgetInputBehavior = 285;- string widgetTooltip = 286;- bool borderTopHidden = 287 [deprecated];- bool borderBottomHidden = 288 [deprecated];- bool borderLeftHidden = 289 [deprecated];- bool borderRightHidden = 290 [deprecated];- WidgetHoverStyle widgetHoverStyle = 291;- bool hasHadRTLText = 292;- bool isWidgetStickable = 293;- bool bordersTakeSpace = 294;- float borderTopWeight = 295;- float borderBottomWeight = 296;- float borderLeftWeight = 297;- float borderRightWeight = 298;- bool borderStrokeWeightsIndependent = 299;- VideoPlayback videoPlayback = 300;- StampData stampData = 301;- HTMLTag htmlTag = 302;- ARIARole ariaRole = 303;- string accessibleLabel = 304;- bool propsAreBubbled = 305;- VariableData variableData = 306;- uint gridRowCount = 435;- uint gridColumnCount = 436;- float gridRowGap = 437;- float gridColumnGap = 438;- GridTrackSize[] gridColumnSizes = 474;- GridTrackSize[] gridRowSizes = 475;-}--message VideoPlayback {- bool autoplay = 1;- bool mediaLoop = 2;- bool muted = 3;-}--message WidgetHoverStyle {- Paint[] fillPaints = 1;- Paint[] strokePaints = 2;- float opacity = 3;- bool areFillPaintsSet = 4;- bool areStrokePaintsSet = 5;- bool isOpacitySet = 6;-}--message WidgetDerivedSubtreeCursor {- uint sessionID = 1;- uint counter = 2;-}--message MultiplayerMap {- MultiplayerMapEntry[] entries = 1;-}--message MultiplayerMapEntry {- string key = 1;- string value = 2;-}--message ComponentPropRef {- uint nodeField = 1;- GUID defID = 2;- string zombieFallbackName = 3;- ComponentPropNodeField componentPropNodeField = 4;- bool isDeleted = 5;-}--enum ComponentPropNodeField {- VISIBLE = 0;- TEXT_DATA = 1;- OVERRIDDEN_SYMBOL_ID = 2;- INHERIT_FILL_STYLE_ID = 3;-}--message ComponentPropAssignment {- GUID defID = 1;- ComponentPropValue value = 2;-}--message ComponentPropDef {- GUID id = 1;- string name = 2;- ComponentPropValue initialValue = 3;- string sortPosition = 4;- GUID parentPropDefId = 5;- ComponentPropType type = 6;- bool isDeleted = 7;- ComponentPropPreferredValues preferredValues = 8;-}--message ComponentPropValue {- bool boolValue = 1;- TextData textValue = 2;- GUID guidValue = 3;-}--enum ComponentPropType {- BOOL = 0;- TEXT = 1;- COLOR = 2;- INSTANCE_SWAP = 3;-}--message ComponentPropPreferredValues {- string[] stringValues = 1;-}--enum WidgetEvent {- MOUSE_DOWN = 0;- CLICK = 1;- TEXT_EDIT_END = 2;- ATTACHED_STICKABLES_CHANGED = 3;- STUCK_STATUS_CHANGED = 4;-}--enum WidgetInputBehavior {- WRAP = 0;- TRUNCATE = 1;- MULTILINE = 2;-}--message WidgetMetadata {- string pluginID = 1;- string pluginVersionID = 2;- string widgetName = 3;-}--enum WidgetPropertyMenuItemType {- ACTION = 0;- SEPARATOR = 1;- COLOR = 2;- DROPDOWN = 3;- COLOR_SELECTOR = 4;- TOGGLE = 5;- LINK = 6;-}--message WidgetPropertyMenuSelectorOption {- string option = 1;- string tooltip = 2;-}--message WidgetPropertyMenuItem {- string propertyName = 1;- string tooltip = 2;- WidgetPropertyMenuItemType itemType = 3;- string icon = 4;- WidgetPropertyMenuSelectorOption[] options = 5;- string selectedOption = 6;- bool isToggled = 7;- string href = 8;-}--enum CodeBlockLanguage {- TYPESCRIPT = 0;- CPP = 1;- RUBY = 2;- CSS = 3;- JAVASCRIPT = 4;- HTML = 5;- JSON = 6;- GRAPHQL = 7;- PYTHON = 8;- GO = 9;- SQL = 10;- SWIFT = 11;- KOTLIN = 12;- RUST = 13;-}--enum InternalEnumForTest {- OLD = 1;-}--message InternalDataForTest {- int testFieldA = 1;-}--message StateGroupPropertyValueOrder {- string property = 1;- string[] values = 2;-}--message TextListData {- int listID = 1 [deprecated];- BulletType bulletType = 2;- int indentationLevel = 3;- int lineNumber = 4 [deprecated];-}--message TextLineData {- LineType lineType = 1;- int indentationLevel = 2;- Directionality directionality = 3;- DirectionalityIntent directionalityIntent = 4;-}--enum BulletType {- ORDERED = 0;- UNORDERED = 1;- INDENT = 2;- NO_LIST = 3;-}--enum LineType {- PLAIN = 0;- ORDERED_LIST = 1;- UNORDERED_LIST = 2;-}--enum Directionality {- LTR = 0;- RTL = 1;-}--enum DirectionalityIntent {- IMPLICIT = 0;- EXPLICIT = 1;-}--message PrototypeInteraction {- GUID id = 1;- PrototypeEvent event = 2;- PrototypeAction[] actions = 3;- bool isDeleted = 4;-}--message PrototypeEvent {- InteractionType interactionType = 1;- bool interactionMaintained = 2;- float interactionDuration = 3;- KeyTrigger keyTrigger = 4;- string voiceEventPhrase = 5;- float transitionTimeout = 6;-}--message PrototypeAction {- GUID transitionNodeID = 1;- TransitionType transitionType = 2;- float transitionDuration = 3;- EasingType easingType = 4;- float transitionTimeout = 5 [deprecated];- bool transitionShouldSmartAnimate = 6;- ConnectionType connectionType = 7;- string connectionURL = 8;- Vector overlayRelativePosition = 9;- NavigationType navigationType = 10;- bool transitionPreserveScroll = 11;- float[] easingFunction = 12;- Vector extraScrollOffset = 13;- GUID targetVariableID = 14;-}--message PrototypeStartingPoint {- string name = 1;- string description = 2;- string position = 3;-}--enum TriggerDevice {- KEYBOARD = 0;- UNKNOWN_CONTROLLER = 1;- XBOX_ONE = 2;- PS4 = 3;- SWITCH_PRO = 4;-}--message KeyTrigger {- int[] keyCodes = 1;- TriggerDevice triggerDevice = 2;-}--message Hyperlink {- string url = 1;- GUID guid = 2;-}--message EmbedData {- string url = 1;- string srcUrl = 2;- string title = 3;- string thumbnailUrl = 4;- float width = 5;- float height = 6;- string embedType = 7;- string thumbnailImageHash = 8;- string faviconImageHash = 9;- string provider = 10;- string originalText = 11;- string description = 12;-}--message StampData {- string userId = 1;-}--message LinkPreviewData {- string url = 1;- string title = 2;- string provider = 3;- string description = 4;- string thumbnailImageHash = 5;- string faviconImageHash = 6;- float thumbnailImageWidth = 7;- float thumbnailImageHeight = 8;-}--message Viewport {- Rect canvasSpaceBounds = 1;- bool pixelPreview = 2;- float pixelDensity = 3;- GUID canvasGuid = 4;-}--message Mouse {- MouseCursor cursor = 1;- Vector canvasSpaceLocation = 2;- Rect canvasSpaceSelectionBox = 3;- GUID canvasGuid = 4;-}--struct Click {- uint id;- Vector point;-}--struct ScrollPosition {- GUID node;- Vector scrollOffset;-}--struct TriggeredOverlay {- GUID overlayGuid;- GUID hotspotGuid;- GUID swapGuid;-}--message TriggeredOverlayData {- GUID overlayGuid = 1;- GUID hotspotGuid = 2;- GUID swapGuid = 3;- GUID prototypeInteractionGuid = 4;- GUIDPath hotspotBlueprintId = 5;-}--message PresentedState {- GUID baseScreenID = 1;- TriggeredOverlayData[] overlays = 2;-}--enum TransitionDirection {- FORWARD = 0;- REVERSE = 1;-}--message TopLevelPlaybackChange {- PresentedState oldState = 1;- PresentedState newState = 2;- GUIDPath hotspotBlueprintID = 3;- GUID interactionID = 4;- bool isHotspotInNewPresentedState = 5;- TransitionDirection direction = 6;- GUIDPath instanceStablePath = 7;-}--message InstanceStateChange {- GUID stateID = 1;- GUID interactionID = 2;- GUIDPath hotspotStablePath = 3;- GUIDPath instanceStablePath = 4;- PlaybackChangePhase phase = 5;-}--enum PlaybackChangePhase {- INITIATED = 0;- ABORTED = 1;- COMMITTED = 2;-}--message PlaybackChangeKeyframe {- PlaybackChangePhase phase = 1;- float progress = 2;- float timestamp = 3;-}--message StateMapping {- GUIDPath stablePath = 1;- TopLevelPlaybackChange lastTopLevelChange = 2;- PlaybackChangeKeyframe lastTopLevelChangeStatus = 3;- float timestamp = 4;-}--message ScrollMapping {- GUIDPath blueprintID = 1;- uint overlayIndex = 2;- Vector scrollOffset = 3;-}--message PlaybackUpdate {- TopLevelPlaybackChange lastTopLevelChange = 1;- PlaybackChangeKeyframe lastTopLevelChangeStatus = 2;- ScrollMapping[] scrollMappings = 3;- float timestamp = 4;- Vector pointerLocation = 5;- bool isTopLevelFrameChange = 6;- StateMapping[] stateMappings = 7;-}--message ChatMessage {- string text = 1;- string previousText = 2;-}--message VoiceMetadata {- string connectedCallId = 1;-}--message UserChange {- uint sessionID = 1;- bool connected = 2;- string name = 3;- Color color = 4;- string imageURL = 5;- Viewport viewport = 6;- Mouse mouse = 7;- GUID[] selection = 8;- uint[] observing = 9;- string deviceName = 10;- Click[] recentClicks = 11;- ScrollPosition[] scrollPositions = 12;- TriggeredOverlay[] triggeredOverlays = 13 [deprecated];- string userID = 14;- GUID lastTriggeredHotspot = 15;- GUID lastTriggeredPrototypeInteractionID = 16;- TriggeredOverlayData[] triggeredOverlaysData = 17;- PlaybackUpdate[] playbackUpdates = 18 [deprecated];- ChatMessage chatMessage = 19;- VoiceMetadata voiceMetadata = 20;- bool canWrite = 21;- bool highFiveStatus = 22;- InstanceStateChange[] instanceStateChanges = 23;-}--message SceneGraphQuery {- GUID startingNode = 1;- uint depth = 2;-}--message NodeChangesMetadata {- uint blobsFieldOffset = 1;-}--message CursorReaction {- string imageUrl = 1;-}--message TimerInfo {- bool isPaused = 1;- uint timeRemainingMs = 2;- uint totalTimeMs = 3;- uint timerID = 4;- string setBy = 5;-}--message PresenterInfo {- uint sessionID = 1;-}--message ClientBroadcast {- uint sessionID = 1;- CursorReaction cursorReaction = 2;- TimerInfo timer = 3;- PresenterInfo presenter = 4;-}--message Message {- MessageType type = 1;- uint sessionID = 2;- uint ackID = 3;- NodeChange[] nodeChanges = 4;- UserChange[] userChanges = 5;- Blob[] blobs = 6;- string signalName = 7;- Access access = 8;- string styleSetName = 9;- StyleSetType styleSetType = 10;- StyleSetContentType styleSetContentType = 11;- int pasteID = 12;- Vector pasteOffset = 13;- string pasteFileKey = 14;- string signalPayload = 15;- SceneGraphQuery[] sceneGraphQueries = 16;- NodeChangesMetadata nodeChangesMetadata = 17 [deprecated];- uint fileVersion = 18;- bool pasteIsPartiallyOutsideEnclosingFrame = 19;- GUID pastePageId = 20;- bool isCut = 21;- Message[] localUndoStack = 22;- Message[] localRedoStack = 23;- ClientBroadcast[] broadcasts = 24;- uint reconnectSequenceNumber = 25;- string pasteBranchSourceFileKey = 26;- EditorType pasteEditorType = 27;- uint reserved28 = 28;- uint64 timestamp = 38;-}--message DiffChunk {- uint[] nodeChanges = 1;- NodePhase phase = 2 [deprecated];- NodeChange displayNode = 3;- GUID canvasId = 4;- string canvasName = 5;- bool canvasIsInternal = 6;- uint[] chunksAffectingThisChunk = 7;- NodeChange[] basisParentHierarchy = 8;- NodeChange[] parentHierarchy = 9;-}--message DiffPayload {- NodeChange[] nodeChanges = 1;- Blob[] blobs = 2;- DiffChunk[] diffChunks = 3;- NodeChange[] diffBasis = 4;-}--enum RichMediaType {- ANIMATED_IMAGE = 0;-}--message RichMediaData {- string mediaHash = 1;- RichMediaType richMediaType = 2;-}--enum VariableDataType {- BOOLEAN = 0;- FLOAT = 1;- STRING = 2;-}--message VariableAnyValue {- bool boolValue = 1;- string textValue = 2;- float floatValue = 3;-}--message VariableData {- VariableAnyValue value = 1;- VariableDataType dataType = 2;-}--enum HTMLTag {- AUTO = 0;- ARTICLE = 1;- SECTION = 2;- NAV = 3;- ASIDE = 4;- H1 = 5;- H2 = 6;- H3 = 7;- H4 = 8;- H5 = 9;- H6 = 10;- HGROUP = 11;- HEADER = 12;- FOOTER = 13;- ADDRESS = 14;- P = 15;- HR = 16;- PRE = 17;- BLOCKQUOTE = 18;- OL = 19;- UL = 20;- MENU = 21;- LI = 22;- DL = 23;- DT = 24;- DD = 25;- FIGURE = 26;- FIGCAPTION = 27;- MAIN = 28;- DIV = 29;- A = 30;- EM = 31;- STRONG = 32;- SMALL = 33;- S = 34;- CITE = 35;- Q = 36;- DFN = 37;- ABBR = 38;- RUBY = 39;- RT = 40;- RP = 41;- DATA = 42;- TIME = 43;- CODE = 44;- VAR = 45;- SAMP = 46;- KBD = 47;- SUB = 48;- SUP = 49;- I = 50;- B = 51;- U = 52;- MARK = 53;- BDI = 54;- BDO = 55;- SPAN = 56;- BR = 57;- WBR = 58;- PICTURE = 59;- SOURCE = 60;- IMG = 61;- FORM = 62;- LABEL = 63;- INPUT = 64;- BUTTON = 65;- SELECT = 66;- DATALIST = 67;- OPTGROUP = 68;- OPTION = 69;- TEXTAREA = 70;- OUTPUT = 71;- PROGRESS = 72;- METER = 73;- FIELDSET = 74;- LEGEND = 75;-}--enum ARIARole {- AUTO = 0;- BUTTON = 1;- CHECKBOX = 2;- GRIDCELL = 3;- LINK = 4;- MENUITEM = 5;- MENUITEMCHECKBOX = 6;- MENUITEMRADIO = 7;- OPTION = 8;- PROGRESSBAR = 9;- RADIO = 10;- SCROLLBAR = 11;- SEARCHBOX = 12;- SEPARATOR = 13;- SLIDER = 14;- SPINBUTTON = 15;- SWITCH = 16;- TAB = 17;- TABPANEL = 18;- TEXTBOX = 19;- TREEITEM = 20;- COMBOBOX = 21;- GRID = 22;- LISTBOX = 23;- MENU = 24;- MENUBAR = 25;- RADIOGROUP = 26;- TABLIST = 27;- TREE = 28;- TREEGRID = 29;- APPLICATION = 30;- ARTICLE = 31;- BLOCKQUOTE = 32;- CAPTION = 33;- CELL = 34;- COLUMNHEADER = 35;- DEFINITION = 36;- DELETION = 37;- DIRECTORY = 38;- DOCUMENT = 39;- EMPHASIS = 40;- FEED = 41;- FIGURE = 42;- GENERIC = 43;- GROUP = 44;- HEADING = 45;- IMG = 46;- INSERTION = 47;- LIST = 48;- LISTITEM = 49;- MATH = 50;- METER = 51;- NONE = 52;- NOTE = 53;- PARAGRAPH = 54;- PRESENTATION = 55;- ROW = 56;- ROWGROUP = 57;- ROWHEADER = 58;- STRONG = 59;- SUBSCRIPT = 60;- SUPERSCRIPT = 61;- TABLE = 62;- TERM = 63;- TIME = 64;- TOOLBAR = 65;- TOOLTIP = 66;- BANNER = 67;- COMPLEMENTARY = 68;- CONTENTINFO = 69;- FORM = 70;- MAIN = 71;- NAVIGATION = 72;- REGION = 73;- SEARCH = 74;- ALERT = 75;- LOG = 76;- MARQUEE = 77;- STATUS = 78;- TIMER = 79;- ALERTDIALOG = 80;- DIALOG = 81;-}-`--export default parseSchema(schemaText)