@llc3233149/core 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/dist/canvaskit.d.ts +9 -0
  2. package/dist/canvaskit.d.ts.map +1 -0
  3. package/dist/canvaskit.js +55 -0
  4. package/dist/canvaskit.js.map +1 -0
  5. package/dist/clipboard.d.ts +32 -0
  6. package/dist/clipboard.d.ts.map +1 -0
  7. package/dist/clipboard.js +345 -0
  8. package/dist/clipboard.js.map +1 -0
  9. package/dist/color.d.ts +28 -0
  10. package/dist/color.d.ts.map +1 -0
  11. package/dist/color.js +67 -0
  12. package/dist/color.js.map +1 -0
  13. package/dist/constants.d.ts +159 -0
  14. package/dist/constants.d.ts.map +1 -0
  15. package/dist/constants.js +224 -0
  16. package/dist/constants.js.map +1 -0
  17. package/dist/copy.d.ts +20 -0
  18. package/dist/copy.d.ts.map +1 -0
  19. package/dist/copy.js +64 -0
  20. package/dist/copy.js.map +1 -0
  21. package/dist/fig-export-worker.d.ts +2 -0
  22. package/dist/fig-export-worker.d.ts.map +1 -0
  23. package/dist/fig-export-worker.js +17 -0
  24. package/dist/fig-export-worker.js.map +1 -0
  25. package/dist/fig-export.d.ts +13 -0
  26. package/dist/fig-export.d.ts.map +1 -0
  27. package/dist/fig-export.js +243 -0
  28. package/dist/fig-export.js.map +1 -0
  29. package/dist/figma-api.d.ts +268 -0
  30. package/dist/figma-api.d.ts.map +1 -0
  31. package/dist/figma-api.js +1074 -0
  32. package/dist/figma-api.js.map +1 -0
  33. package/dist/figma-rest-import.d.ts +122 -0
  34. package/dist/figma-rest-import.d.ts.map +1 -0
  35. package/dist/figma-rest-import.js +319 -0
  36. package/dist/figma-rest-import.js.map +1 -0
  37. package/dist/fonts.d.ts +24 -0
  38. package/dist/fonts.d.ts.map +1 -0
  39. package/dist/fonts.js +356 -0
  40. package/dist/fonts.js.map +1 -0
  41. package/dist/geometry.d.ts +14 -0
  42. package/dist/geometry.d.ts.map +1 -0
  43. package/dist/geometry.js +47 -0
  44. package/dist/geometry.js.map +1 -0
  45. package/dist/index.d.ts +38 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +32 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/kiwi/codec.d.ts +292 -0
  50. package/dist/kiwi/codec.d.ts.map +1 -0
  51. package/dist/kiwi/codec.js +340 -0
  52. package/dist/kiwi/codec.js.map +1 -0
  53. package/dist/kiwi/fig-file.d.ts +4 -0
  54. package/dist/kiwi/fig-file.d.ts.map +1 -0
  55. package/dist/kiwi/fig-file.js +236 -0
  56. package/dist/kiwi/fig-file.js.map +1 -0
  57. package/dist/kiwi/fig-import.d.ts +4 -0
  58. package/dist/kiwi/fig-import.d.ts.map +1 -0
  59. package/dist/kiwi/fig-import.js +248 -0
  60. package/dist/kiwi/fig-import.js.map +1 -0
  61. package/dist/kiwi/fig-parse-worker.d.ts +7 -0
  62. package/dist/kiwi/fig-parse-worker.d.ts.map +1 -0
  63. package/dist/kiwi/fig-parse-worker.js +184 -0
  64. package/dist/kiwi/fig-parse-worker.js.map +1 -0
  65. package/dist/kiwi/instance-overrides.d.ts +66 -0
  66. package/dist/kiwi/instance-overrides.d.ts.map +1 -0
  67. package/dist/kiwi/instance-overrides.js +644 -0
  68. package/dist/kiwi/instance-overrides.js.map +1 -0
  69. package/dist/kiwi/kiwi-convert.d.ts +19 -0
  70. package/dist/kiwi/kiwi-convert.d.ts.map +1 -0
  71. package/dist/kiwi/kiwi-convert.js +678 -0
  72. package/dist/kiwi/kiwi-convert.js.map +1 -0
  73. package/dist/kiwi/kiwi-schema/bb.d.ts +25 -0
  74. package/dist/kiwi/kiwi-schema/bb.d.ts.map +1 -0
  75. package/dist/kiwi/kiwi-schema/bb.js +225 -0
  76. package/dist/kiwi/kiwi-schema/bb.js.map +1 -0
  77. package/dist/kiwi/kiwi-schema/binary.d.ts +5 -0
  78. package/dist/kiwi/kiwi-schema/binary.d.ts.map +1 -0
  79. package/dist/kiwi/kiwi-schema/binary.js +86 -0
  80. package/dist/kiwi/kiwi-schema/binary.js.map +1 -0
  81. package/dist/kiwi/kiwi-schema/index.d.ts +6 -0
  82. package/dist/kiwi/kiwi-schema/index.d.ts.map +1 -0
  83. package/dist/kiwi/kiwi-schema/index.js +5 -0
  84. package/dist/kiwi/kiwi-schema/index.js.map +1 -0
  85. package/dist/kiwi/kiwi-schema/js.d.ts +4 -0
  86. package/dist/kiwi/kiwi-schema/js.d.ts.map +1 -0
  87. package/dist/kiwi/kiwi-schema/js.js +282 -0
  88. package/dist/kiwi/kiwi-schema/js.js.map +1 -0
  89. package/dist/kiwi/kiwi-schema/parser.d.ts +5 -0
  90. package/dist/kiwi/kiwi-schema/parser.d.ts.map +1 -0
  91. package/dist/kiwi/kiwi-schema/parser.js +228 -0
  92. package/dist/kiwi/kiwi-schema/parser.js.map +1 -0
  93. package/dist/kiwi/kiwi-schema/schema.d.ts +22 -0
  94. package/dist/kiwi/kiwi-schema/schema.d.ts.map +1 -0
  95. package/dist/kiwi/kiwi-schema/schema.js +2 -0
  96. package/dist/kiwi/kiwi-schema/schema.js.map +1 -0
  97. package/dist/kiwi/kiwi-schema/util.d.ts +3 -0
  98. package/dist/kiwi/kiwi-schema/util.d.ts.map +1 -0
  99. package/dist/kiwi/kiwi-schema/util.js +10 -0
  100. package/dist/kiwi/kiwi-schema/util.js.map +1 -0
  101. package/dist/kiwi/protocol.d.ts +172 -0
  102. package/dist/kiwi/protocol.d.ts.map +1 -0
  103. package/dist/kiwi/protocol.js +214 -0
  104. package/dist/kiwi/protocol.js.map +1 -0
  105. package/dist/kiwi/schema.d.ts +3 -0
  106. package/dist/kiwi/schema.d.ts.map +1 -0
  107. package/dist/kiwi/schema.js +2285 -0
  108. package/dist/kiwi/schema.js.map +1 -0
  109. package/dist/kiwi-serialize.d.ts +17 -0
  110. package/dist/kiwi-serialize.d.ts.map +1 -0
  111. package/dist/kiwi-serialize.js +419 -0
  112. package/dist/kiwi-serialize.js.map +1 -0
  113. package/dist/layout.d.ts +9 -0
  114. package/dist/layout.d.ts.map +1 -0
  115. package/dist/layout.js +533 -0
  116. package/dist/layout.js.map +1 -0
  117. package/dist/profiler/draw-call-counter.d.ts +9 -0
  118. package/dist/profiler/draw-call-counter.d.ts.map +1 -0
  119. package/dist/profiler/draw-call-counter.js +37 -0
  120. package/dist/profiler/draw-call-counter.js.map +1 -0
  121. package/dist/profiler/frame-capture.d.ts +34 -0
  122. package/dist/profiler/frame-capture.d.ts.map +1 -0
  123. package/dist/profiler/frame-capture.js +90 -0
  124. package/dist/profiler/frame-capture.js.map +1 -0
  125. package/dist/profiler/frame-stats.d.ts +33 -0
  126. package/dist/profiler/frame-stats.d.ts.map +1 -0
  127. package/dist/profiler/frame-stats.js +103 -0
  128. package/dist/profiler/frame-stats.js.map +1 -0
  129. package/dist/profiler/gpu-timer.d.ts +15 -0
  130. package/dist/profiler/gpu-timer.d.ts.map +1 -0
  131. package/dist/profiler/gpu-timer.js +77 -0
  132. package/dist/profiler/gpu-timer.js.map +1 -0
  133. package/dist/profiler/hud-renderer.d.ts +22 -0
  134. package/dist/profiler/hud-renderer.d.ts.map +1 -0
  135. package/dist/profiler/hud-renderer.js +200 -0
  136. package/dist/profiler/hud-renderer.js.map +1 -0
  137. package/dist/profiler/index.d.ts +9 -0
  138. package/dist/profiler/index.d.ts.map +1 -0
  139. package/dist/profiler/index.js +8 -0
  140. package/dist/profiler/index.js.map +1 -0
  141. package/dist/profiler/phase-timer.d.ts +9 -0
  142. package/dist/profiler/phase-timer.d.ts.map +1 -0
  143. package/dist/profiler/phase-timer.js +51 -0
  144. package/dist/profiler/phase-timer.js.map +1 -0
  145. package/dist/profiler/render-profiler.d.ts +41 -0
  146. package/dist/profiler/render-profiler.d.ts.map +1 -0
  147. package/dist/profiler/render-profiler.js +142 -0
  148. package/dist/profiler/render-profiler.js.map +1 -0
  149. package/dist/render/components.d.ts +25 -0
  150. package/dist/render/components.d.ts.map +1 -0
  151. package/dist/render/components.js +55 -0
  152. package/dist/render/components.js.map +1 -0
  153. package/dist/render/emoji-icons.d.ts +5 -0
  154. package/dist/render/emoji-icons.d.ts.map +1 -0
  155. package/dist/render/emoji-icons.js +55 -0
  156. package/dist/render/emoji-icons.js.map +1 -0
  157. package/dist/render/export-code.d.ts +9 -0
  158. package/dist/render/export-code.d.ts.map +1 -0
  159. package/dist/render/export-code.js +335 -0
  160. package/dist/render/export-code.js.map +1 -0
  161. package/dist/render/export-jsx.d.ts +5 -0
  162. package/dist/render/export-jsx.d.ts.map +1 -0
  163. package/dist/render/export-jsx.js +621 -0
  164. package/dist/render/export-jsx.js.map +1 -0
  165. package/dist/render/index.d.ts +8 -0
  166. package/dist/render/index.d.ts.map +1 -0
  167. package/dist/render/index.js +8 -0
  168. package/dist/render/index.js.map +1 -0
  169. package/dist/render/jsx-runtime.d.ts +31 -0
  170. package/dist/render/jsx-runtime.d.ts.map +1 -0
  171. package/dist/render/jsx-runtime.js +13 -0
  172. package/dist/render/jsx-runtime.js.map +1 -0
  173. package/dist/render/mini-react.d.ts +14 -0
  174. package/dist/render/mini-react.d.ts.map +1 -0
  175. package/dist/render/mini-react.js +16 -0
  176. package/dist/render/mini-react.js.map +1 -0
  177. package/dist/render/render-jsx.d.ts +24 -0
  178. package/dist/render/render-jsx.d.ts.map +1 -0
  179. package/dist/render/render-jsx.js +51 -0
  180. package/dist/render/render-jsx.js.map +1 -0
  181. package/dist/render/renderer.d.ts +16 -0
  182. package/dist/render/renderer.d.ts.map +1 -0
  183. package/dist/render/renderer.js +437 -0
  184. package/dist/render/renderer.js.map +1 -0
  185. package/dist/render/tailwind.d.ts +20 -0
  186. package/dist/render/tailwind.d.ts.map +1 -0
  187. package/dist/render/tailwind.js +115 -0
  188. package/dist/render/tailwind.js.map +1 -0
  189. package/dist/render/tree.d.ts +72 -0
  190. package/dist/render/tree.d.ts.map +1 -0
  191. package/dist/render/tree.js +63 -0
  192. package/dist/render/tree.js.map +1 -0
  193. package/dist/render-image.d.ts +19 -0
  194. package/dist/render-image.d.ts.map +1 -0
  195. package/dist/render-image.js +84 -0
  196. package/dist/render-image.js.map +1 -0
  197. package/dist/renderer/effects.d.ts +9 -0
  198. package/dist/renderer/effects.d.ts.map +1 -0
  199. package/dist/renderer/effects.js +44 -0
  200. package/dist/renderer/effects.js.map +1 -0
  201. package/dist/renderer/fills.d.ts +9 -0
  202. package/dist/renderer/fills.d.ts.map +1 -0
  203. package/dist/renderer/fills.js +189 -0
  204. package/dist/renderer/fills.js.map +1 -0
  205. package/dist/renderer/index.d.ts +2 -0
  206. package/dist/renderer/index.d.ts.map +1 -0
  207. package/dist/renderer/index.js +2 -0
  208. package/dist/renderer/index.js.map +1 -0
  209. package/dist/renderer/label-cache.d.ts +43 -0
  210. package/dist/renderer/label-cache.d.ts.map +1 -0
  211. package/dist/renderer/label-cache.js +85 -0
  212. package/dist/renderer/label-cache.js.map +1 -0
  213. package/dist/renderer/labels.d.ts +6 -0
  214. package/dist/renderer/labels.d.ts.map +1 -0
  215. package/dist/renderer/labels.js +126 -0
  216. package/dist/renderer/labels.js.map +1 -0
  217. package/dist/renderer/lru-cache.d.ts +20 -0
  218. package/dist/renderer/lru-cache.d.ts.map +1 -0
  219. package/dist/renderer/lru-cache.js +65 -0
  220. package/dist/renderer/lru-cache.js.map +1 -0
  221. package/dist/renderer/overlays.d.ts +25 -0
  222. package/dist/renderer/overlays.d.ts.map +1 -0
  223. package/dist/renderer/overlays.js +783 -0
  224. package/dist/renderer/overlays.js.map +1 -0
  225. package/dist/renderer/renderer.d.ts +229 -0
  226. package/dist/renderer/renderer.d.ts.map +1 -0
  227. package/dist/renderer/renderer.js +909 -0
  228. package/dist/renderer/renderer.js.map +1 -0
  229. package/dist/renderer/rulers.d.ts +8 -0
  230. package/dist/renderer/rulers.d.ts.map +1 -0
  231. package/dist/renderer/rulers.js +147 -0
  232. package/dist/renderer/rulers.js.map +1 -0
  233. package/dist/renderer/scene.d.ts +11 -0
  234. package/dist/renderer/scene.d.ts.map +1 -0
  235. package/dist/renderer/scene.js +392 -0
  236. package/dist/renderer/scene.js.map +1 -0
  237. package/dist/renderer/shapes.d.ts +13 -0
  238. package/dist/renderer/shapes.d.ts.map +1 -0
  239. package/dist/renderer/shapes.js +160 -0
  240. package/dist/renderer/shapes.js.map +1 -0
  241. package/dist/renderer/strokes.d.ts +9 -0
  242. package/dist/renderer/strokes.d.ts.map +1 -0
  243. package/dist/renderer/strokes.js +180 -0
  244. package/dist/renderer/strokes.js.map +1 -0
  245. package/dist/rpc/commands.d.ts +202 -0
  246. package/dist/rpc/commands.d.ts.map +1 -0
  247. package/dist/rpc/commands.js +429 -0
  248. package/dist/rpc/commands.js.map +1 -0
  249. package/dist/rpc/index.d.ts +3 -0
  250. package/dist/rpc/index.d.ts.map +1 -0
  251. package/dist/rpc/index.js +2 -0
  252. package/dist/rpc/index.js.map +1 -0
  253. package/dist/scene-graph.d.ts +318 -0
  254. package/dist/scene-graph.d.ts.map +1 -0
  255. package/dist/scene-graph.js +803 -0
  256. package/dist/scene-graph.js.map +1 -0
  257. package/dist/snap.d.ts +16 -0
  258. package/dist/snap.d.ts.map +1 -0
  259. package/dist/snap.js +97 -0
  260. package/dist/snap.js.map +1 -0
  261. package/dist/style-runs.d.ts +20 -0
  262. package/dist/style-runs.d.ts.map +1 -0
  263. package/dist/style-runs.js +168 -0
  264. package/dist/style-runs.js.map +1 -0
  265. package/dist/svg-export/defs.d.ts +19 -0
  266. package/dist/svg-export/defs.d.ts.map +1 -0
  267. package/dist/svg-export/defs.js +191 -0
  268. package/dist/svg-export/defs.js.map +1 -0
  269. package/dist/svg-export/index.d.ts +8 -0
  270. package/dist/svg-export/index.d.ts.map +1 -0
  271. package/dist/svg-export/index.js +318 -0
  272. package/dist/svg-export/index.js.map +1 -0
  273. package/dist/svg-export/paths.d.ts +9 -0
  274. package/dist/svg-export/paths.d.ts.map +1 -0
  275. package/dist/svg-export/paths.js +189 -0
  276. package/dist/svg-export/paths.js.map +1 -0
  277. package/dist/svg-node.d.ts +8 -0
  278. package/dist/svg-node.d.ts.map +1 -0
  279. package/dist/svg-node.js +48 -0
  280. package/dist/svg-node.js.map +1 -0
  281. package/dist/text-editor.d.ts +57 -0
  282. package/dist/text-editor.d.ts.map +1 -0
  283. package/dist/text-editor.js +337 -0
  284. package/dist/text-editor.js.map +1 -0
  285. package/dist/tools/ai-adapter.d.ts +22 -0
  286. package/dist/tools/ai-adapter.d.ts.map +1 -0
  287. package/dist/tools/ai-adapter.js +121 -0
  288. package/dist/tools/ai-adapter.js.map +1 -0
  289. package/dist/tools/analyze.d.ts +22 -0
  290. package/dist/tools/analyze.d.ts.map +1 -0
  291. package/dist/tools/analyze.js +677 -0
  292. package/dist/tools/analyze.js.map +1 -0
  293. package/dist/tools/create.d.ts +8 -0
  294. package/dist/tools/create.d.ts.map +1 -0
  295. package/dist/tools/create.js +204 -0
  296. package/dist/tools/create.js.map +1 -0
  297. package/dist/tools/describe.d.ts +9 -0
  298. package/dist/tools/describe.d.ts.map +1 -0
  299. package/dist/tools/describe.js +295 -0
  300. package/dist/tools/describe.js.map +1 -0
  301. package/dist/tools/export-code.d.ts +2 -0
  302. package/dist/tools/export-code.d.ts.map +1 -0
  303. package/dist/tools/export-code.js +34 -0
  304. package/dist/tools/export-code.js.map +1 -0
  305. package/dist/tools/export-tailwind-config.d.ts +27 -0
  306. package/dist/tools/export-tailwind-config.d.ts.map +1 -0
  307. package/dist/tools/export-tailwind-config.js +215 -0
  308. package/dist/tools/export-tailwind-config.js.map +1 -0
  309. package/dist/tools/icons.d.ts +5 -0
  310. package/dist/tools/icons.d.ts.map +1 -0
  311. package/dist/tools/icons.js +192 -0
  312. package/dist/tools/icons.js.map +1 -0
  313. package/dist/tools/index.d.ts +7 -0
  314. package/dist/tools/index.d.ts.map +1 -0
  315. package/dist/tools/index.js +6 -0
  316. package/dist/tools/index.js.map +1 -0
  317. package/dist/tools/modify.d.ts +22 -0
  318. package/dist/tools/modify.d.ts.map +1 -0
  319. package/dist/tools/modify.js +653 -0
  320. package/dist/tools/modify.js.map +1 -0
  321. package/dist/tools/patterns.d.ts +2 -0
  322. package/dist/tools/patterns.d.ts.map +1 -0
  323. package/dist/tools/patterns.js +173 -0
  324. package/dist/tools/patterns.js.map +1 -0
  325. package/dist/tools/read.d.ts +17 -0
  326. package/dist/tools/read.d.ts.map +1 -0
  327. package/dist/tools/read.js +379 -0
  328. package/dist/tools/read.js.map +1 -0
  329. package/dist/tools/registry.d.ts +3 -0
  330. package/dist/tools/registry.d.ts.map +1 -0
  331. package/dist/tools/registry.js +124 -0
  332. package/dist/tools/registry.js.map +1 -0
  333. package/dist/tools/schema.d.ts +46 -0
  334. package/dist/tools/schema.d.ts.map +1 -0
  335. package/dist/tools/schema.js +17 -0
  336. package/dist/tools/schema.js.map +1 -0
  337. package/dist/tools/structure.d.ts +18 -0
  338. package/dist/tools/structure.d.ts.map +1 -0
  339. package/dist/tools/structure.js +345 -0
  340. package/dist/tools/structure.js.map +1 -0
  341. package/dist/tools/variables.d.ts +12 -0
  342. package/dist/tools/variables.d.ts.map +1 -0
  343. package/dist/tools/variables.js +190 -0
  344. package/dist/tools/variables.js.map +1 -0
  345. package/dist/tools/vector.d.ts +15 -0
  346. package/dist/tools/vector.d.ts.map +1 -0
  347. package/dist/tools/vector.js +312 -0
  348. package/dist/tools/vector.js.map +1 -0
  349. package/dist/types.d.ts +29 -0
  350. package/dist/types.d.ts.map +1 -0
  351. package/dist/types.js +2 -0
  352. package/dist/types.js.map +1 -0
  353. package/dist/undo.d.ts +33 -0
  354. package/dist/undo.d.ts.map +1 -0
  355. package/dist/undo.js +98 -0
  356. package/dist/undo.js.map +1 -0
  357. package/dist/vector.d.ts +14 -0
  358. package/dist/vector.d.ts.map +1 -0
  359. package/dist/vector.js +334 -0
  360. package/dist/vector.js.map +1 -0
  361. package/dist/xpath.d.ts +8 -0
  362. package/dist/xpath.d.ts.map +1 -0
  363. package/dist/xpath.js +199 -0
  364. package/dist/xpath.js.map +1 -0
  365. package/package.json +54 -0
  366. package/src/canvaskit.ts +66 -0
  367. package/src/clipboard.ts +444 -0
  368. package/src/color.ts +83 -0
  369. package/src/constants.ts +277 -0
  370. package/src/copy.ts +75 -0
  371. package/src/fig-export-worker.ts +28 -0
  372. package/src/fig-export.ts +321 -0
  373. package/src/figma-api.ts +1297 -0
  374. package/src/figma-rest-import.ts +443 -0
  375. package/src/fonts.ts +369 -0
  376. package/src/geometry.ts +73 -0
  377. package/src/global.d.ts +20 -0
  378. package/src/index.ts +247 -0
  379. package/src/kiwi/codec.ts +614 -0
  380. package/src/kiwi/fig-file.ts +248 -0
  381. package/src/kiwi/fig-import.ts +300 -0
  382. package/src/kiwi/fig-parse-worker.ts +213 -0
  383. package/src/kiwi/instance-overrides.ts +682 -0
  384. package/src/kiwi/kiwi-convert.ts +771 -0
  385. package/src/kiwi/kiwi-schema/bb.ts +244 -0
  386. package/src/kiwi/kiwi-schema/binary.ts +102 -0
  387. package/src/kiwi/kiwi-schema/index.ts +5 -0
  388. package/src/kiwi/kiwi-schema/js.ts +339 -0
  389. package/src/kiwi/kiwi-schema/parser.ts +287 -0
  390. package/src/kiwi/kiwi-schema/schema.ts +24 -0
  391. package/src/kiwi/kiwi-schema/util.ts +10 -0
  392. package/src/kiwi/protocol.ts +237 -0
  393. package/src/kiwi/schema.ts +2286 -0
  394. package/src/kiwi-serialize.ts +467 -0
  395. package/src/layout.ts +608 -0
  396. package/src/profiler/draw-call-counter.ts +43 -0
  397. package/src/profiler/frame-capture.ts +139 -0
  398. package/src/profiler/frame-stats.ts +122 -0
  399. package/src/profiler/gpu-timer.ts +93 -0
  400. package/src/profiler/hud-renderer.ts +242 -0
  401. package/src/profiler/index.ts +8 -0
  402. package/src/profiler/phase-timer.ts +62 -0
  403. package/src/profiler/render-profiler.ts +163 -0
  404. package/src/render/components.ts +69 -0
  405. package/src/render/emoji-icons.ts +60 -0
  406. package/src/render/export-code.ts +366 -0
  407. package/src/render/export-jsx.ts +633 -0
  408. package/src/render/index.ts +38 -0
  409. package/src/render/jsx-runtime.ts +36 -0
  410. package/src/render/mini-react.ts +30 -0
  411. package/src/render/render-jsx.ts +74 -0
  412. package/src/render/renderer.ts +508 -0
  413. package/src/render/tailwind.ts +114 -0
  414. package/src/render/tree.ts +137 -0
  415. package/src/render-image.ts +139 -0
  416. package/src/renderer/effects.ts +64 -0
  417. package/src/renderer/fills.ts +248 -0
  418. package/src/renderer/index.ts +1 -0
  419. package/src/renderer/label-cache.ts +114 -0
  420. package/src/renderer/labels.ts +168 -0
  421. package/src/renderer/lru-cache.ts +71 -0
  422. package/src/renderer/overlays.ts +1089 -0
  423. package/src/renderer/renderer.ts +1226 -0
  424. package/src/renderer/rulers.ts +230 -0
  425. package/src/renderer/scene.ts +554 -0
  426. package/src/renderer/shapes.ts +193 -0
  427. package/src/renderer/strokes.ts +221 -0
  428. package/src/rpc/commands.ts +667 -0
  429. package/src/rpc/index.ts +25 -0
  430. package/src/scene-graph.ts +1254 -0
  431. package/src/snap.ts +122 -0
  432. package/src/style-runs.ts +234 -0
  433. package/src/svg-export/defs.ts +255 -0
  434. package/src/svg-export/index.ts +427 -0
  435. package/src/svg-export/paths.ts +212 -0
  436. package/src/svg-node.ts +62 -0
  437. package/src/text-editor.ts +349 -0
  438. package/src/tools/ai-adapter.ts +144 -0
  439. package/src/tools/analyze.ts +786 -0
  440. package/src/tools/create.ts +206 -0
  441. package/src/tools/describe.ts +280 -0
  442. package/src/tools/export-code.ts +41 -0
  443. package/src/tools/export-tailwind-config.ts +266 -0
  444. package/src/tools/icons.ts +213 -0
  445. package/src/tools/index.ts +6 -0
  446. package/src/tools/modify.ts +651 -0
  447. package/src/tools/patterns.ts +189 -0
  448. package/src/tools/read.ts +401 -0
  449. package/src/tools/registry.ts +155 -0
  450. package/src/tools/schema.ts +65 -0
  451. package/src/tools/structure.ts +348 -0
  452. package/src/tools/variables.ts +193 -0
  453. package/src/tools/vector.ts +311 -0
  454. package/src/types.ts +32 -0
  455. package/src/undo.ts +126 -0
  456. package/src/vector.ts +413 -0
  457. package/src/xpath.ts +259 -0
@@ -0,0 +1,248 @@
1
+ import { Unzip, UnzipInflate, inflateSync } from 'fflate'
2
+ import { decompress as zstdDecompress } from 'fzstd'
3
+
4
+ import { importNodeChanges } from './fig-import'
5
+ import { decodeBinarySchema, compileSchema, ByteBuffer } from './kiwi-schema'
6
+ import { isZstdCompressed } from './protocol'
7
+
8
+ import type { SceneGraph } from '../scene-graph'
9
+ import type { FigmaMessage } from './codec'
10
+ import type { FigParseResult } from './fig-parse-worker'
11
+
12
+ interface FigKiwiPayload {
13
+ schemaDeflated: Uint8Array
14
+ dataRaw: Uint8Array
15
+ }
16
+
17
+ function parseFigKiwiContainer(data: Uint8Array): FigKiwiPayload | null {
18
+ const header = new TextDecoder().decode(data.slice(0, 8))
19
+ if (header !== 'fig-kiwi') return null
20
+
21
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength)
22
+ let offset = 12
23
+
24
+ const chunks: Uint8Array[] = []
25
+ while (offset < data.length) {
26
+ const len = view.getUint32(offset, true)
27
+ offset += 4
28
+ chunks.push(data.slice(offset, offset + len))
29
+ offset += len
30
+ }
31
+ if (chunks.length < 2) return null
32
+
33
+ const compressed = chunks[1]
34
+ let dataRaw: Uint8Array
35
+ if (isZstdCompressed(compressed)) {
36
+ dataRaw = zstdDecompress(compressed)
37
+ } else {
38
+ try {
39
+ dataRaw = inflateSync(compressed)
40
+ } catch {
41
+ dataRaw = compressed
42
+ }
43
+ }
44
+
45
+ return { schemaDeflated: chunks[0], dataRaw }
46
+ }
47
+
48
+ /** Concatenate Uint8Array chunks. */
49
+ function concatChunks(chunks: Uint8Array[]): Uint8Array {
50
+ if (chunks.length === 1) return chunks[0]
51
+ let total = 0
52
+ for (const c of chunks) total += c.length
53
+ const out = new Uint8Array(total)
54
+ let offset = 0
55
+ for (const c of chunks) {
56
+ out.set(c, offset)
57
+ offset += c.length
58
+ }
59
+ return out
60
+ }
61
+
62
+ function isCanvasEntry(name: string): boolean {
63
+ return name === 'canvas.fig' || name === 'canvas'
64
+ }
65
+
66
+ function isImageEntry(name: string): boolean {
67
+ return name.startsWith('images/') && name !== 'images/'
68
+ }
69
+
70
+ /**
71
+ * Streaming parse using fflate.Unzip — decompresses entries one at a time
72
+ * instead of all at once, reducing peak memory for large files.
73
+ */
74
+ function streamingParseFigFile(data: Uint8Array): Promise<SceneGraph> {
75
+ return new Promise<SceneGraph>((resolve, reject) => {
76
+ const fileChunks = new Map<string, Uint8Array[]>()
77
+ let pending = 0
78
+ let pushDone = false
79
+
80
+ const uz = new Unzip((file) => {
81
+ if (!isCanvasEntry(file.name) && !isImageEntry(file.name)) return
82
+ pending++
83
+ const chunks: Uint8Array[] = []
84
+ fileChunks.set(file.name, chunks)
85
+ file.ondata = (err, chunk, final) => {
86
+ if (err) { reject(err); return }
87
+ chunks.push(chunk)
88
+ if (final) { pending--; maybeFinish() }
89
+ }
90
+ file.start()
91
+ })
92
+ uz.register(UnzipInflate)
93
+
94
+ function maybeFinish() {
95
+ if (!pushDone || pending > 0) return
96
+ try { resolve(finalize()) } catch (err) { reject(err) }
97
+ }
98
+
99
+ function finalize(): SceneGraph {
100
+ let canvasData: Uint8Array | null = null
101
+ for (const [name, chunks] of fileChunks) {
102
+ if (isCanvasEntry(name)) { canvasData = concatChunks(chunks); break }
103
+ }
104
+ if (!canvasData) {
105
+ let maxSize = 0
106
+ for (const [name, chunks] of fileChunks) {
107
+ if (isImageEntry(name)) continue
108
+ const size = chunks.reduce((s, c) => s + c.length, 0)
109
+ if (size > maxSize) { maxSize = size; canvasData = concatChunks(chunks) }
110
+ }
111
+ }
112
+ if (!canvasData) {
113
+ throw new Error(`No canvas data found. Entries: ${[...fileChunks.keys()].join(', ')}`)
114
+ }
115
+
116
+ const payload = parseFigKiwiContainer(canvasData)
117
+ if (!payload) throw new Error('Invalid fig-kiwi container')
118
+
119
+ const schemaBytes = inflateSync(payload.schemaDeflated)
120
+ const schema = decodeBinarySchema(new ByteBuffer(schemaBytes))
121
+ const compiled = compileSchema(schema) as { decodeMessage(data: Uint8Array): unknown }
122
+ const message = compiled.decodeMessage(payload.dataRaw) as FigmaMessage
123
+
124
+ if (!message.nodeChanges?.length) throw new Error('No nodes found in .fig file')
125
+
126
+ const blobs: Uint8Array[] = (message.blobs ?? []).map((b) =>
127
+ b.bytes instanceof Uint8Array ? b.bytes : new Uint8Array(Object.values(b.bytes))
128
+ )
129
+
130
+ const images = new Map<string, Uint8Array>()
131
+ for (const [name, chunks] of fileChunks) {
132
+ if (isImageEntry(name)) {
133
+ images.set(name.replace('images/', ''), concatChunks(chunks))
134
+ }
135
+ }
136
+
137
+ return importNodeChanges(message.nodeChanges, blobs, images)
138
+ }
139
+
140
+ uz.push(data, true)
141
+ pushDone = true
142
+ maybeFinish()
143
+ })
144
+ }
145
+
146
+ function parseViaWorker(buffer: ArrayBuffer): Promise<SceneGraph> {
147
+ return new Promise((resolve, reject) => {
148
+ const worker = new Worker(new URL('./fig-parse-worker.ts', import.meta.url), { type: 'module' })
149
+
150
+ worker.onmessage = (e: MessageEvent<FigParseResult & { error?: string }>) => {
151
+ worker.terminate()
152
+ if (e.data.error) { reject(new Error(e.data.error)); return }
153
+ const { nodeChanges, blobs, images: imageEntries } = e.data
154
+ const images = new Map<string, Uint8Array>(imageEntries)
155
+ resolve(importNodeChanges(nodeChanges, blobs, images))
156
+ }
157
+
158
+ worker.onerror = (err) => {
159
+ worker.terminate()
160
+ reject(new Error(err.message))
161
+ }
162
+
163
+ worker.postMessage(buffer, [buffer])
164
+ })
165
+ }
166
+
167
+ /**
168
+ * Stream a File to the worker in chunks, avoiding loading the entire file
169
+ * into memory at once. Falls back to full-buffer for small files.
170
+ */
171
+ function streamFileToWorker(file: File): Promise<SceneGraph> {
172
+ const CHUNK_SIZE = 4 * 1024 * 1024 // 4MB chunks
173
+
174
+ return new Promise((resolve, reject) => {
175
+ const worker = new Worker(new URL('./fig-parse-worker.ts', import.meta.url), { type: 'module' })
176
+
177
+ worker.onmessage = (e: MessageEvent<FigParseResult & { error?: string }>) => {
178
+ worker.terminate()
179
+ if (e.data.error) { reject(new Error(e.data.error)); return }
180
+ const { nodeChanges, blobs, images: imageEntries } = e.data
181
+ const images = new Map<string, Uint8Array>(imageEntries)
182
+ resolve(importNodeChanges(nodeChanges, blobs, images))
183
+ }
184
+
185
+ worker.onerror = (err) => {
186
+ worker.terminate()
187
+ reject(new Error(err.message))
188
+ }
189
+
190
+ // Stream file in chunks
191
+ const reader = file.stream().getReader()
192
+ let buffer: Uint8Array[] = []
193
+ let bufferSize = 0
194
+
195
+ function flush(final: boolean) {
196
+ if (bufferSize === 0 && !final) return
197
+ const chunk = buffer.length === 1 ? buffer[0] : concatChunks(buffer)
198
+ const transfer = chunk.buffer as ArrayBuffer
199
+ worker.postMessage(
200
+ { type: 'stream-chunk', chunk, final },
201
+ [transfer]
202
+ )
203
+ buffer = []
204
+ bufferSize = 0
205
+ }
206
+
207
+ function pump(): void {
208
+ reader.read().then(({ done, value }) => {
209
+ if (done) {
210
+ flush(true)
211
+ return
212
+ }
213
+ buffer.push(value)
214
+ bufferSize += value.length
215
+ if (bufferSize >= CHUNK_SIZE) flush(false)
216
+ pump()
217
+ }).catch(reject)
218
+ }
219
+
220
+ pump()
221
+ })
222
+ }
223
+
224
+ /** Small file threshold for using streaming (50MB) */
225
+ const STREAM_THRESHOLD = 50 * 1024 * 1024
226
+
227
+ export async function parseFigFile(buffer: ArrayBuffer): Promise<SceneGraph> {
228
+ if (typeof Worker !== 'undefined' && typeof window !== 'undefined') {
229
+ return parseViaWorker(buffer)
230
+ }
231
+ // Non-worker fallback: use streaming parse to reduce peak memory
232
+ return streamingParseFigFile(new Uint8Array(buffer))
233
+ }
234
+
235
+ export async function readFigFile(file: File): Promise<SceneGraph> {
236
+ if (typeof Worker !== 'undefined' && typeof window !== 'undefined') {
237
+ // Large files: stream to worker in chunks to avoid full-buffer in main thread
238
+ if (file.size > STREAM_THRESHOLD) {
239
+ return streamFileToWorker(file)
240
+ }
241
+ // Small files: full buffer is fine
242
+ const buffer = await file.arrayBuffer()
243
+ return parseViaWorker(buffer)
244
+ }
245
+ // Non-worker fallback
246
+ const buffer = await file.arrayBuffer()
247
+ return streamingParseFigFile(new Uint8Array(buffer))
248
+ }
@@ -0,0 +1,300 @@
1
+ import type { VariableType, VariableValue } from '../scene-graph'
2
+ import { SceneGraph } from '../scene-graph'
3
+
4
+ import {
5
+ guidToString,
6
+ nodeChangeToProps,
7
+ sortChildren,
8
+ VARIABLE_BINDING_FIELDS_INVERSE
9
+ } from './kiwi-convert'
10
+ import { populateAndApplyOverrides } from './instance-overrides'
11
+ import type { InstanceNodeChange } from './instance-overrides'
12
+
13
+ import type { NodeChange, VariableDataValuesEntry } from './codec'
14
+
15
+ interface ChangeMaps {
16
+ changeMap: Map<string, NodeChange>
17
+ parentMap: Map<string, string>
18
+ childrenMap: Map<string, string[]>
19
+ }
20
+
21
+ function buildChangeMaps(nodeChanges: NodeChange[]): ChangeMaps {
22
+ const changeMap = new Map<string, NodeChange>()
23
+ const parentMap = new Map<string, string>()
24
+ const childrenMap = new Map<string, string[]>()
25
+
26
+ for (const nc of nodeChanges) {
27
+ if (!nc.guid) continue
28
+ if (nc.phase === 'REMOVED') continue
29
+ const id = guidToString(nc.guid)
30
+ changeMap.set(id, nc)
31
+
32
+ if (nc.parentIndex?.guid) {
33
+ const pid = guidToString(nc.parentIndex.guid)
34
+ parentMap.set(id, pid)
35
+ let siblings = childrenMap.get(pid)
36
+ if (!siblings) {
37
+ siblings = []
38
+ childrenMap.set(pid, siblings)
39
+ }
40
+ siblings.push(id)
41
+ }
42
+ }
43
+
44
+ for (const [parentId, children] of childrenMap) {
45
+ const parentNc = changeMap.get(parentId)
46
+ if (parentNc) sortChildren(children, parentNc, changeMap)
47
+ }
48
+
49
+ return { changeMap, parentMap, childrenMap }
50
+ }
51
+
52
+ function resolveVariableType(resolvedType: string | undefined): VariableType {
53
+ if (resolvedType === 'COLOR') return 'COLOR'
54
+ if (resolvedType === 'BOOLEAN') return 'BOOLEAN'
55
+ if (resolvedType === 'STRING') return 'STRING'
56
+ return 'FLOAT'
57
+ }
58
+
59
+ function resolveVariableValue(entry: VariableDataValuesEntry): VariableValue | undefined {
60
+ const vd = entry.variableData
61
+ if (!vd.value) return undefined
62
+
63
+ const dt = vd.dataType ?? vd.resolvedDataType
64
+ if (dt === 'COLOR' && vd.value.colorValue) {
65
+ const c = vd.value.colorValue
66
+ return { r: c.r, g: c.g, b: c.b, a: c.a }
67
+ }
68
+ if (dt === 'BOOLEAN') return vd.value.boolValue ?? false
69
+ if (dt === 'STRING') return vd.value.textValue ?? ''
70
+ if (dt === 'ALIAS' && vd.value.alias?.guid) {
71
+ return { aliasId: guidToString(vd.value.alias.guid) }
72
+ }
73
+ return vd.value.floatValue ?? 0
74
+ }
75
+
76
+ function resolveDefaultValue(type: VariableType): VariableValue {
77
+ if (type === 'BOOLEAN') return false
78
+ if (type === 'STRING') return ''
79
+ if (type === 'COLOR') return { r: 0, g: 0, b: 0, a: 1 }
80
+ return 0
81
+ }
82
+
83
+ function importCollections(
84
+ changeMap: Map<string, NodeChange>,
85
+ graph: SceneGraph
86
+ ): void {
87
+ for (const [id, nc] of changeMap) {
88
+ if (nc.type !== 'VARIABLE_SET') continue
89
+
90
+ const modes = (nc.variableSetModes ?? []).map((m) => {
91
+ const modeId = guidToString(m.id)
92
+ return { modeId, name: m.name }
93
+ })
94
+ if (modes.length === 0) modes.push({ modeId: 'default', name: 'Default' })
95
+
96
+ graph.addCollection({
97
+ id,
98
+ name: nc.name ?? 'Variables',
99
+ modes,
100
+ defaultModeId: modes[0].modeId,
101
+ variableIds: []
102
+ })
103
+ }
104
+ }
105
+
106
+ function importVariableEntries(
107
+ changeMap: Map<string, NodeChange>,
108
+ parentMap: Map<string, string>,
109
+ graph: SceneGraph
110
+ ): void {
111
+ for (const [id, nc] of changeMap) {
112
+ if (nc.type !== 'VARIABLE') continue
113
+
114
+ const collectionId = nc.variableSetID?.guid ? guidToString(nc.variableSetID.guid) : (parentMap.get(id) ?? '')
115
+
116
+ if (!graph.variableCollections.has(collectionId)) {
117
+ const parentNc = changeMap.get(collectionId)
118
+ graph.addCollection({
119
+ id: collectionId,
120
+ name: parentNc?.name ?? 'Variables',
121
+ modes: [{ modeId: 'default', name: 'Default' }],
122
+ defaultModeId: 'default',
123
+ variableIds: []
124
+ })
125
+ }
126
+
127
+ const type = resolveVariableType(nc.variableResolvedType)
128
+ const valuesByMode: Record<string, VariableValue> = {}
129
+
130
+ if (nc.variableDataValues?.entries) {
131
+ for (const entry of nc.variableDataValues.entries) {
132
+ const val = resolveVariableValue(entry)
133
+ if (val !== undefined) {
134
+ valuesByMode[guidToString(entry.modeID)] = val
135
+ }
136
+ }
137
+ }
138
+
139
+ if (Object.keys(valuesByMode).length === 0) {
140
+ const col = graph.variableCollections.get(collectionId)
141
+ const defaultMode = col?.defaultModeId ?? 'default'
142
+ valuesByMode[defaultMode] = resolveDefaultValue(type)
143
+ }
144
+
145
+ graph.addVariable({
146
+ id,
147
+ name: nc.name ?? 'Variable',
148
+ type,
149
+ collectionId,
150
+ valuesByMode,
151
+ description: '',
152
+ hiddenFromPublishing: false
153
+ })
154
+ }
155
+ }
156
+
157
+ function importPages(
158
+ graph: SceneGraph,
159
+ changeMap: Map<string, NodeChange>,
160
+ parentMap: Map<string, string>,
161
+ childrenMap: Map<string, string[]>,
162
+ created: Set<string>,
163
+ createSceneNode: (ncId: string, graphParentId: string) => void
164
+ ): void {
165
+ let docId: string | null = null
166
+ for (const [id, nc] of changeMap) {
167
+ if (nc.type === 'DOCUMENT' || id === '0:0') {
168
+ docId = id
169
+ break
170
+ }
171
+ }
172
+
173
+ if (docId) {
174
+ for (const canvasId of childrenMap.get(docId) ?? []) {
175
+ const canvasNc = changeMap.get(canvasId)
176
+ if (!canvasNc) continue
177
+ if (canvasNc.type === 'CANVAS') {
178
+ const page = graph.addPage(canvasNc.name ?? 'Page')
179
+ if (canvasNc.internalOnly) page.internalOnly = true
180
+ created.add(canvasId)
181
+ for (const childId of childrenMap.get(canvasId) ?? []) {
182
+ createSceneNode(childId, page.id)
183
+ }
184
+ } else {
185
+ createSceneNode(canvasId, graph.getPages()[0]?.id ?? graph.rootId)
186
+ }
187
+ }
188
+ } else {
189
+ const roots: string[] = []
190
+ for (const [id] of changeMap) {
191
+ const pid = parentMap.get(id)
192
+ if (!pid || !changeMap.has(pid)) roots.push(id)
193
+ }
194
+ const page = graph.getPages()[0] ?? graph.addPage('Page 1')
195
+ for (const rootId of roots) {
196
+ createSceneNode(rootId, page.id)
197
+ }
198
+ }
199
+ }
200
+
201
+ function importVariableBindings(
202
+ changeMap: Map<string, NodeChange>,
203
+ guidToNodeId: Map<string, string>,
204
+ graph: SceneGraph
205
+ ): void {
206
+ for (const [ncId, nc] of changeMap) {
207
+ if (!nc.variableConsumptionMap?.entries?.length) continue
208
+ const nodeId = guidToNodeId.get(ncId)
209
+ if (!nodeId) continue
210
+ for (const entry of nc.variableConsumptionMap.entries) {
211
+ const varGuid = entry.variableData?.value?.alias?.guid
212
+ if (!varGuid) continue
213
+ const field = VARIABLE_BINDING_FIELDS_INVERSE[entry.variableField ?? '']
214
+ if (field) graph.bindVariable(nodeId, field, guidToString(varGuid))
215
+ }
216
+ }
217
+ }
218
+
219
+ function remapComponentIds(
220
+ graph: SceneGraph,
221
+ guidToNodeId: Map<string, string>
222
+ ): void {
223
+ for (const node of graph.getAllNodes()) {
224
+ if (node.type !== 'INSTANCE' || !node.componentId) continue
225
+ const remapped = guidToNodeId.get(node.componentId)
226
+ if (remapped) node.componentId = remapped
227
+ }
228
+ }
229
+
230
+ export function importNodeChanges(
231
+ nodeChanges: NodeChange[],
232
+ blobs: Uint8Array[] = [],
233
+ images?: Map<string, Uint8Array>
234
+ ): SceneGraph {
235
+ const graph = new SceneGraph()
236
+
237
+ if (images) {
238
+ for (const [hash, data] of images) {
239
+ graph.images.set(hash, data)
240
+ }
241
+ }
242
+
243
+ for (const page of graph.getPages(true)) {
244
+ graph.deleteNode(page.id)
245
+ }
246
+
247
+ const { changeMap, parentMap, childrenMap } = buildChangeMaps(nodeChanges)
248
+
249
+ const created = new Set<string>()
250
+ const guidToNodeId = new Map<string, string>()
251
+ const getChildren = (ncId: string): string[] => childrenMap.get(ncId) ?? []
252
+
253
+ function createSceneNode(ncId: string, graphParentId: string) {
254
+ if (created.has(ncId)) return
255
+ created.add(ncId)
256
+
257
+ const nc = changeMap.get(ncId)
258
+ if (!nc) return
259
+
260
+ try {
261
+ const { nodeType, ...props } = nodeChangeToProps(nc, blobs)
262
+ if (nodeType === 'DOCUMENT' || nodeType === 'VARIABLE' || nc.type === 'VARIABLE_SET') return
263
+
264
+ const node = graph.createNode(nodeType, graphParentId, props)
265
+ guidToNodeId.set(ncId, node.id)
266
+
267
+ for (const childId of getChildren(ncId)) {
268
+ createSceneNode(childId, node.id)
269
+ }
270
+ } catch (e) {
271
+ // Skip nodes that fail to import rather than aborting the entire file
272
+ console.warn(`[fig-import] Skipped node ${ncId} (${nc.name ?? nc.type}):`, e)
273
+ }
274
+ }
275
+
276
+ importPages(graph, changeMap, parentMap, childrenMap, created, createSceneNode)
277
+
278
+ importCollections(changeMap, graph)
279
+ importVariableEntries(changeMap, parentMap, graph)
280
+ importVariableBindings(changeMap, guidToNodeId, graph)
281
+ remapComponentIds(graph, guidToNodeId)
282
+
283
+ try {
284
+ populateAndApplyOverrides(
285
+ graph,
286
+ changeMap as unknown as Map<string, InstanceNodeChange>,
287
+ guidToNodeId,
288
+ blobs
289
+ )
290
+ } catch (e) {
291
+ // Instance overrides are non-critical — import continues without them
292
+ console.warn('[fig-import] Instance override population failed:', e)
293
+ }
294
+
295
+ if (graph.getPages(true).length === 0) {
296
+ graph.addPage('Page 1')
297
+ }
298
+
299
+ return graph
300
+ }