@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,909 @@
1
+ import { SELECTION_COLOR, COMPONENT_COLOR, SNAP_COLOR, CANVAS_BG_COLOR, PEN_PATH_STROKE_WIDTH, PARENT_OUTLINE_ALPHA, PARENT_OUTLINE_DASH, DEFAULT_FONT_SIZE, LABEL_FONT_SIZE, LABEL_OFFSET_Y, SIZE_FONT_SIZE, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_GAP, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_BORDER_WIDTH, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_LABEL_ICON_GAP, RULER_BG_COLOR, RULER_TICK_COLOR, RULER_TEXT_COLOR, DEFAULT_FONT_FAMILY } from '../constants.js';
2
+ import { isFontLoaded, getCJKFallbackFamily } from '../fonts.js';
3
+ import { RenderProfiler } from '../profiler.js';
4
+ import { drawHoverHighlight as drawHoverHighlightFn, drawSelection as drawSelectionFn, drawNodeSelection as drawNodeSelectionFn, drawSelectionLabels as drawSelectionLabelsFn, drawParentFrameOutlines as drawParentFrameOutlinesFn, drawNodeOutline as drawNodeOutlineFn, drawGroupBounds as drawGroupBoundsFn, getRotatedCorners as getRotatedCornersFn, drawHandle as drawHandleFn, drawSnapGuides as drawSnapGuidesFn, drawMarquee as drawMarqueeFn, drawFlashes as drawFlashesFn, drawLayoutInsertIndicator as drawLayoutInsertIndicatorFn, drawTextEditOverlay as drawTextEditOverlayFn, drawPenOverlay as drawPenOverlayFn, drawRemoteCursors as drawRemoteCursorsFn, drawMeasurements as drawMeasurementsFn, drawPaddingOverlay as drawPaddingOverlayFn } from './overlays.js';
5
+ import { drawRulers as drawRulersFn } from './rulers.js';
6
+ import { drawSectionTitles as drawSectionTitlesFn, drawComponentLabels as drawComponentLabelsFn } from './labels.js';
7
+ import { LabelCache } from './label-cache.js';
8
+ import { LRUCache } from './lru-cache.js';
9
+ import { renderNode as renderNodeFn, renderSection as renderSectionFn, renderComponentSet as renderComponentSetFn, renderShape as renderShapeFn, renderShapeUncached as renderShapeUncachedFn, renderEffects as renderEffectsFn, renderText as renderTextFn } from './scene.js';
10
+ import { drawNodeFill as drawNodeFillFn, applyFill as applyFillFn, applyGradientFill as applyGradientFillFn, applyImageFill as applyImageFillFn, drawArc as drawArcFn } from './fills.js';
11
+ import { drawNodeStroke as drawNodeStrokeFn, drawStrokeWithAlign as drawStrokeWithAlignFn, drawRRectStrokeWithAlign as drawRRectStrokeWithAlignFn, drawIndividualSideStrokes as drawIndividualSideStrokesFn, strokeNodeShape as strokeNodeShapeFn } from './strokes.js';
12
+ import { makeNodeShapePath as makeNodeShapePathFn, makePolygonPath as makePolygonPathFn, makeRRect as makeRRectFn, makeRRectWithSpread as makeRRectWithSpreadFn, makeRRectWithOffset as makeRRectWithOffsetFn, clipNodeShape as clipNodeShapeFn, getVectorPaths as getVectorPathsFn, getFillGeometry as getFillGeometryFn, getStrokeGeometry as getStrokeGeometryFn } from './shapes.js';
13
+ import { getCachedDropShadow as getCachedDropShadowFn, getCachedBlur as getCachedBlurFn, getCachedDecalBlur as getCachedDecalBlurFn, getCachedMaskBlur as getCachedMaskBlurFn, applyClippedBlur as applyClippedBlurFn } from './effects.js';
14
+ export class SkiaRenderer {
15
+ ck;
16
+ surface;
17
+ fillPaint;
18
+ strokePaint;
19
+ selectionPaint;
20
+ parentOutlinePaint;
21
+ snapPaint;
22
+ auxFill;
23
+ auxStroke;
24
+ opacityPaint;
25
+ effectLayerPaint;
26
+ imageFilterCache = new Map();
27
+ maskFilterCache = new Map();
28
+ _tmpColor = new Float32Array(4);
29
+ _tmpRect = new Float32Array(4);
30
+ textFont = null;
31
+ labelFont = null;
32
+ sizeFont = null;
33
+ sectionTitleFont = null;
34
+ componentLabelFont = null;
35
+ fontMgr = null;
36
+ fontProvider = null;
37
+ fontsLoaded = false;
38
+ imageCache = new LRUCache(512, (img) => img.delete());
39
+ vectorPathCache = new LRUCache(512, (paths) => { for (const p of paths)
40
+ p.delete(); });
41
+ fillGeometryCache = new LRUCache(512, (paths) => { for (const p of paths)
42
+ p.delete(); });
43
+ strokeGeometryCache = new LRUCache(512, (paths) => { for (const p of paths)
44
+ p.delete(); });
45
+ scenePicture = null;
46
+ scenePictureVersion = -1;
47
+ scenePicturePageId = null;
48
+ nodePictureCache = new LRUCache(512, (pic) => pic.delete());
49
+ labelCache = new LabelCache();
50
+ profiler;
51
+ rulerBgPaint;
52
+ rulerTickPaint;
53
+ rulerTextPaint;
54
+ rulerHlPaint;
55
+ rulerBadgePaint;
56
+ rulerLabelPaint;
57
+ penPathPaint;
58
+ penHandlePaint;
59
+ penVertexFill;
60
+ penVertexStroke;
61
+ panX = 0;
62
+ panY = 0;
63
+ zoom = 1;
64
+ dpr = 1;
65
+ viewportWidth = 0;
66
+ viewportHeight = 0;
67
+ showRulers = true;
68
+ pageColor = CANVAS_BG_COLOR;
69
+ pageId = null;
70
+ worldViewport = { x: 0, y: 0, w: 0, h: 0 };
71
+ _nodeCount = 0;
72
+ _culledCount = 0;
73
+ _flashes = [];
74
+ _flashPaint = null;
75
+ DEFAULT_FONT_SIZE = DEFAULT_FONT_SIZE;
76
+ COMPONENT_SET_BORDER_WIDTH = COMPONENT_SET_BORDER_WIDTH;
77
+ COMPONENT_SET_DASH = COMPONENT_SET_DASH;
78
+ COMPONENT_SET_DASH_GAP = COMPONENT_SET_DASH_GAP;
79
+ /**
80
+ * Returns a shared Float32Array [r, g, b, a] for passing colors to CanvasKit.
81
+ * WARNING: The returned buffer is reused on every call. Callers must consume
82
+ * the value immediately (pass it to a CanvasKit API) before the next call to
83
+ * color4f(), as the underlying data will be overwritten.
84
+ */
85
+ color4f(r, g, b, a) {
86
+ const c = this._tmpColor;
87
+ c[0] = r;
88
+ c[1] = g;
89
+ c[2] = b;
90
+ c[3] = a;
91
+ return c;
92
+ }
93
+ /**
94
+ * Returns a shared Float32Array [left, top, right, bottom] for passing rects to CanvasKit.
95
+ * WARNING: The returned buffer is reused on every call. Callers must consume
96
+ * the value immediately (pass it to a CanvasKit API) before the next call to
97
+ * ltrb(), as the underlying data will be overwritten.
98
+ */
99
+ ltrb(l, t, r, b) {
100
+ const rc = this._tmpRect;
101
+ rc[0] = l;
102
+ rc[1] = t;
103
+ rc[2] = r;
104
+ rc[3] = b;
105
+ return rc;
106
+ }
107
+ selColor(alpha = 1) {
108
+ return this.ck.Color4f(SELECTION_COLOR.r, SELECTION_COLOR.g, SELECTION_COLOR.b, alpha);
109
+ }
110
+ compColor(alpha = 1) {
111
+ return this.ck.Color4f(COMPONENT_COLOR.r, COMPONENT_COLOR.g, COMPONENT_COLOR.b, alpha);
112
+ }
113
+ isComponentType(type) {
114
+ return type === 'COMPONENT' || type === 'COMPONENT_SET' || type === 'INSTANCE';
115
+ }
116
+ isRectangularType(type) {
117
+ return (type === 'FRAME' ||
118
+ type === 'RECTANGLE' ||
119
+ type === 'ROUNDED_RECTANGLE' ||
120
+ type === 'COMPONENT' ||
121
+ type === 'INSTANCE' ||
122
+ type === 'SECTION' ||
123
+ type === 'GROUP');
124
+ }
125
+ effectOverflow(node) {
126
+ let expand = 0;
127
+ for (const e of node.effects) {
128
+ if (!e.visible)
129
+ continue;
130
+ const blur = e.radius;
131
+ const spread = e.spread;
132
+ const ox = Math.abs(e.offset.x);
133
+ const oy = Math.abs(e.offset.y);
134
+ expand = Math.max(expand, blur + spread + ox, blur + spread + oy);
135
+ }
136
+ return expand;
137
+ }
138
+ constructor(ck, surface, gl) {
139
+ this.ck = ck;
140
+ this.surface = surface;
141
+ this.profiler = new RenderProfiler(ck, gl ?? null);
142
+ this.fillPaint = new ck.Paint();
143
+ this.fillPaint.setStyle(ck.PaintStyle.Fill);
144
+ this.fillPaint.setAntiAlias(true);
145
+ this.strokePaint = new ck.Paint();
146
+ this.strokePaint.setStyle(ck.PaintStyle.Stroke);
147
+ this.strokePaint.setAntiAlias(true);
148
+ this.selectionPaint = new ck.Paint();
149
+ this.selectionPaint.setStyle(ck.PaintStyle.Stroke);
150
+ this.selectionPaint.setStrokeWidth(1);
151
+ this.selectionPaint.setColor(this.selColor());
152
+ this.selectionPaint.setAntiAlias(true);
153
+ this.parentOutlinePaint = new ck.Paint();
154
+ this.parentOutlinePaint.setStyle(ck.PaintStyle.Stroke);
155
+ this.parentOutlinePaint.setStrokeWidth(1);
156
+ this.parentOutlinePaint.setColor(this.selColor(PARENT_OUTLINE_ALPHA));
157
+ this.parentOutlinePaint.setAntiAlias(true);
158
+ this.parentOutlinePaint.setPathEffect(ck.PathEffect.MakeDash([PARENT_OUTLINE_DASH, PARENT_OUTLINE_DASH], 0));
159
+ this.snapPaint = new ck.Paint();
160
+ this.snapPaint.setStyle(ck.PaintStyle.Stroke);
161
+ this.snapPaint.setStrokeWidth(1);
162
+ this.snapPaint.setColor(this.ck.Color4f(SNAP_COLOR.r, SNAP_COLOR.g, SNAP_COLOR.b, 1));
163
+ this.snapPaint.setAntiAlias(true);
164
+ this.auxFill = new ck.Paint();
165
+ this.auxFill.setStyle(ck.PaintStyle.Fill);
166
+ this.auxFill.setAntiAlias(true);
167
+ this.auxStroke = new ck.Paint();
168
+ this.auxStroke.setStyle(ck.PaintStyle.Stroke);
169
+ this.auxStroke.setAntiAlias(true);
170
+ this.opacityPaint = new ck.Paint();
171
+ this.effectLayerPaint = new ck.Paint();
172
+ this.textFont = new ck.Font(null, DEFAULT_FONT_SIZE);
173
+ const bg = RULER_BG_COLOR;
174
+ this.rulerBgPaint = new ck.Paint();
175
+ this.rulerBgPaint.setColor(ck.Color4f(bg.r, bg.g, bg.b, 1));
176
+ this.rulerTickPaint = new ck.Paint();
177
+ this.rulerTickPaint.setColor(ck.Color4f(RULER_TICK_COLOR.r, RULER_TICK_COLOR.g, RULER_TICK_COLOR.b, 1));
178
+ this.rulerTickPaint.setStrokeWidth(1);
179
+ this.rulerTickPaint.setAntiAlias(true);
180
+ const tc = RULER_TEXT_COLOR;
181
+ this.rulerTextPaint = new ck.Paint();
182
+ this.rulerTextPaint.setColor(ck.Color4f(tc.r, tc.g, tc.b, 1));
183
+ this.rulerTextPaint.setAntiAlias(true);
184
+ this.rulerHlPaint = new ck.Paint();
185
+ this.rulerHlPaint.setAntiAlias(true);
186
+ this.rulerBadgePaint = new ck.Paint();
187
+ this.rulerBadgePaint.setAntiAlias(true);
188
+ this.rulerLabelPaint = new ck.Paint();
189
+ this.rulerLabelPaint.setColor(ck.Color4f(1, 1, 1, 1));
190
+ this.rulerLabelPaint.setAntiAlias(true);
191
+ this.penPathPaint = new ck.Paint();
192
+ this.penPathPaint.setStyle(ck.PaintStyle.Stroke);
193
+ this.penPathPaint.setStrokeWidth(PEN_PATH_STROKE_WIDTH);
194
+ this.penPathPaint.setColor(this.selColor());
195
+ this.penPathPaint.setAntiAlias(true);
196
+ this.penHandlePaint = new ck.Paint();
197
+ this.penHandlePaint.setStyle(ck.PaintStyle.Stroke);
198
+ this.penHandlePaint.setStrokeWidth(1);
199
+ this.penHandlePaint.setColor(this.selColor(PARENT_OUTLINE_ALPHA));
200
+ this.penHandlePaint.setAntiAlias(true);
201
+ this.penVertexFill = new ck.Paint();
202
+ this.penVertexFill.setStyle(ck.PaintStyle.Fill);
203
+ this.penVertexFill.setColor(ck.WHITE);
204
+ this.penVertexFill.setAntiAlias(true);
205
+ this.penVertexStroke = new ck.Paint();
206
+ this.penVertexStroke.setStyle(ck.PaintStyle.Stroke);
207
+ this.penVertexStroke.setStrokeWidth(PEN_PATH_STROKE_WIDTH);
208
+ this.penVertexStroke.setColor(this.selColor());
209
+ this.penVertexStroke.setAntiAlias(true);
210
+ }
211
+ getFontProvider() {
212
+ return this.fontProvider;
213
+ }
214
+ async loadFonts() {
215
+ this.fontProvider = this.ck.TypefaceFontProvider.Make();
216
+ const { initFontService, loadFont, ensureCJKFallback } = await import('../fonts');
217
+ initFontService(this.ck, this.fontProvider);
218
+ const fontData = await loadFont(DEFAULT_FONT_FAMILY, 'Regular');
219
+ if (fontData) {
220
+ const typeface = this.ck.Typeface.MakeFreeTypeFaceFromData(fontData);
221
+ if (typeface) {
222
+ this.textFont?.delete();
223
+ this.labelFont?.delete();
224
+ this.sizeFont?.delete();
225
+ this.sectionTitleFont?.delete();
226
+ this.componentLabelFont?.delete();
227
+ this.textFont = new this.ck.Font(typeface, DEFAULT_FONT_SIZE);
228
+ this.labelFont = new this.ck.Font(typeface, LABEL_FONT_SIZE);
229
+ this.sizeFont = new this.ck.Font(typeface, SIZE_FONT_SIZE);
230
+ this.sectionTitleFont = new this.ck.Font(typeface, SECTION_TITLE_FONT_SIZE);
231
+ this.componentLabelFont = new this.ck.Font(typeface, COMPONENT_LABEL_FONT_SIZE);
232
+ this.profiler.setTypeface(typeface);
233
+ }
234
+ this.fontMgr = this.ck.FontMgr.FromData(fontData) ?? null;
235
+ }
236
+ this.fontsLoaded = true;
237
+ this.invalidateAllPictures();
238
+ void ensureCJKFallback().then((family) => {
239
+ if (family)
240
+ this.invalidateAllPictures();
241
+ });
242
+ }
243
+ replaceSurface(surface) {
244
+ this.surface.delete();
245
+ this.surface = surface;
246
+ this.invalidateScenePicture();
247
+ }
248
+ invalidateScenePicture() {
249
+ this.scenePicture?.delete();
250
+ this.scenePicture = null;
251
+ this.scenePictureVersion = -1;
252
+ }
253
+ invalidateAllPictures() {
254
+ this.invalidateScenePicture();
255
+ this.nodePictureCache.clear();
256
+ }
257
+ invalidateNodePicture(nodeId) {
258
+ this.nodePictureCache.delete(nodeId);
259
+ }
260
+ flashNode(nodeId) {
261
+ this._flashes.push({ nodeId, startTime: performance.now() });
262
+ }
263
+ get hasActiveFlashes() {
264
+ return this._flashes.length > 0;
265
+ }
266
+ hitTestSectionTitle(graph, canvasX, canvasY) {
267
+ if (!this.sectionTitleFont)
268
+ return null;
269
+ const pageNode = graph.getNode(this.pageId ?? graph.rootId);
270
+ if (!pageNode)
271
+ return null;
272
+ const font = this.sectionTitleFont;
273
+ let result = null;
274
+ const check = (parentId, ox, oy, insideSection) => {
275
+ const parent = graph.getNode(parentId);
276
+ if (!parent)
277
+ return;
278
+ for (let i = parent.childIds.length - 1; i >= 0; i--) {
279
+ if (result)
280
+ return;
281
+ const childId = parent.childIds[i];
282
+ const child = graph.getNode(childId);
283
+ if (!child || !child.visible)
284
+ continue;
285
+ const ax = ox + child.x;
286
+ const ay = oy + child.y;
287
+ if (child.type === 'SECTION') {
288
+ const glyphIds = font.getGlyphIDs(child.name);
289
+ const widths = font.getGlyphWidths(glyphIds);
290
+ let textW = 0;
291
+ for (const w of widths)
292
+ textW += w;
293
+ const pillW = Math.min(textW + SECTION_TITLE_PADDING_X * 2, child.width * this.zoom) / this.zoom;
294
+ const pillH = SECTION_TITLE_HEIGHT / this.zoom;
295
+ const gap = SECTION_TITLE_GAP / this.zoom;
296
+ let pillX = ax;
297
+ let pillY;
298
+ if (insideSection) {
299
+ pillY = ay + gap;
300
+ }
301
+ else {
302
+ pillY = ay - pillH - gap;
303
+ }
304
+ if (canvasX >= pillX &&
305
+ canvasX <= pillX + pillW &&
306
+ canvasY >= pillY &&
307
+ canvasY <= pillY + pillH) {
308
+ result = child;
309
+ return;
310
+ }
311
+ check(childId, ax, ay, true);
312
+ }
313
+ else if (child.childIds.length > 0) {
314
+ check(childId, ax, ay, insideSection);
315
+ }
316
+ }
317
+ };
318
+ check(pageNode.id, 0, 0, false);
319
+ return result;
320
+ }
321
+ hitTestComponentLabel(graph, canvasX, canvasY) {
322
+ if (!this.componentLabelFont)
323
+ return null;
324
+ const pageNode = graph.getNode(this.pageId ?? graph.rootId);
325
+ if (!pageNode)
326
+ return null;
327
+ const font = this.componentLabelFont;
328
+ const LABEL_TYPES = new Set(['COMPONENT', 'COMPONENT_SET']);
329
+ let result = null;
330
+ const check = (parentId, ox, oy) => {
331
+ const parent = graph.getNode(parentId);
332
+ if (!parent)
333
+ return;
334
+ for (let i = parent.childIds.length - 1; i >= 0; i--) {
335
+ if (result)
336
+ return;
337
+ const childId = parent.childIds[i];
338
+ const child = graph.getNode(childId);
339
+ if (!child || !child.visible)
340
+ continue;
341
+ const ax = ox + child.x;
342
+ const ay = oy + child.y;
343
+ if (LABEL_TYPES.has(child.type)) {
344
+ const glyphIds = font.getGlyphIDs(child.name);
345
+ const widths = font.getGlyphWidths(glyphIds);
346
+ let textW = 0;
347
+ for (const w of widths)
348
+ textW += w;
349
+ const labelW = (COMPONENT_LABEL_ICON_SIZE + COMPONENT_LABEL_ICON_GAP + textW) / this.zoom;
350
+ const labelH = COMPONENT_LABEL_FONT_SIZE / this.zoom;
351
+ const gap = COMPONENT_LABEL_GAP / this.zoom;
352
+ const isInsideSet = parent.type === 'COMPONENT_SET';
353
+ const labelX = ax;
354
+ let labelY;
355
+ if (isInsideSet) {
356
+ labelY = ay + gap;
357
+ }
358
+ else {
359
+ labelY = ay - labelH - gap;
360
+ }
361
+ if (canvasX >= labelX &&
362
+ canvasX <= labelX + labelW &&
363
+ canvasY >= labelY &&
364
+ canvasY <= labelY + labelH) {
365
+ result = child;
366
+ return;
367
+ }
368
+ }
369
+ if (child.childIds.length > 0) {
370
+ check(childId, ax, ay);
371
+ }
372
+ }
373
+ };
374
+ check(pageNode.id, 0, 0);
375
+ return result;
376
+ }
377
+ hitTestFrameTitle(graph, canvasX, canvasY, selectedIds) {
378
+ if (!this.labelFont || selectedIds.size !== 1)
379
+ return null;
380
+ const id = [...selectedIds][0];
381
+ const node = graph.getNode(id);
382
+ if (node?.type !== 'FRAME')
383
+ return null;
384
+ const parent = node.parentId ? graph.getNode(node.parentId) : null;
385
+ const isTopLevel = !parent || parent.type === 'CANVAS' || parent.type === 'SECTION';
386
+ if (!isTopLevel)
387
+ return null;
388
+ const abs = graph.getAbsolutePosition(id);
389
+ const font = this.labelFont;
390
+ const glyphIds = font.getGlyphIDs(node.name);
391
+ const widths = font.getGlyphWidths(glyphIds);
392
+ let textW = 0;
393
+ for (const w of widths)
394
+ textW += w;
395
+ const labelW = textW / this.zoom;
396
+ const labelH = LABEL_FONT_SIZE / this.zoom;
397
+ const gap = LABEL_OFFSET_Y / this.zoom;
398
+ const labelX = abs.x;
399
+ const labelY = abs.y - gap - labelH;
400
+ if (canvasX >= labelX &&
401
+ canvasX <= labelX + labelW &&
402
+ canvasY >= labelY &&
403
+ canvasY <= labelY + labelH) {
404
+ return node;
405
+ }
406
+ return null;
407
+ }
408
+ renderSceneToCanvas(canvas, graph, pageId) {
409
+ const prevViewport = this.worldViewport;
410
+ this.worldViewport = { x: -1e9, y: -1e9, w: 2e9, h: 2e9 };
411
+ const pageNode = graph.getNode(pageId);
412
+ if (pageNode) {
413
+ for (const childId of pageNode.childIds) {
414
+ this.renderNode(canvas, graph, childId, {});
415
+ }
416
+ }
417
+ this.worldViewport = prevViewport;
418
+ }
419
+ render(graph, selectedIds, overlays = {}, sceneVersion = -1) {
420
+ const p = this.profiler;
421
+ p.beginFrame();
422
+ graph.clearAbsPosCache();
423
+ const canvas = this.surface.getCanvas();
424
+ canvas.clear(this.ck.Color4f(this.pageColor.r, this.pageColor.g, this.pageColor.b, 1));
425
+ this.worldViewport = {
426
+ x: -this.panX / this.zoom,
427
+ y: -this.panY / this.zoom,
428
+ w: this.viewportWidth / this.zoom,
429
+ h: this.viewportHeight / this.zoom
430
+ };
431
+ const hasVolatileOverlays = overlays.dropTargetId != null ||
432
+ overlays.rotationPreview != null ||
433
+ overlays.editingTextId != null;
434
+ const canUsePicture = !hasVolatileOverlays &&
435
+ this.scenePicture &&
436
+ sceneVersion === this.scenePictureVersion &&
437
+ this.pageId === this.scenePicturePageId;
438
+ p.setCacheHit(!!canUsePicture);
439
+ canvas.save();
440
+ canvas.scale(this.dpr, this.dpr);
441
+ canvas.translate(this.panX, this.panY);
442
+ canvas.scale(this.zoom, this.zoom);
443
+ p.beginPhase('render:scene');
444
+ if (canUsePicture) {
445
+ p.beginPhase('render:drawPicture');
446
+ if (this.scenePicture)
447
+ canvas.drawPicture(this.scenePicture);
448
+ p.endPhase('render:drawPicture');
449
+ }
450
+ else if (hasVolatileOverlays) {
451
+ this._nodeCount = 0;
452
+ this._culledCount = 0;
453
+ p.beginPhase('render:volatile');
454
+ const pageNode = graph.getNode(this.pageId ?? graph.rootId);
455
+ if (pageNode) {
456
+ for (const childId of pageNode.childIds) {
457
+ this.renderNode(canvas, graph, childId, overlays, 0, 0);
458
+ }
459
+ }
460
+ p.endPhase('render:volatile');
461
+ }
462
+ else {
463
+ this._nodeCount = 0;
464
+ this._culledCount = 0;
465
+ p.beginPhase('render:recordPicture');
466
+ this.recordScenePicture(canvas, graph, sceneVersion);
467
+ p.endPhase('render:recordPicture');
468
+ }
469
+ p.endPhase('render:scene');
470
+ canvas.restore();
471
+ canvas.save();
472
+ canvas.scale(this.dpr, this.dpr);
473
+ this.labelCache.update(graph, this.pageId, sceneVersion);
474
+ p.beginPhase('render:sectionTitles');
475
+ this.drawSectionTitles(canvas, graph);
476
+ p.endPhase('render:sectionTitles');
477
+ p.beginPhase('render:componentLabels');
478
+ this.drawComponentLabels(canvas, graph);
479
+ p.endPhase('render:componentLabels');
480
+ canvas.restore();
481
+ canvas.save();
482
+ canvas.scale(this.dpr, this.dpr);
483
+ this.drawHoverHighlight(canvas, graph, overlays.hoveredNodeId);
484
+ p.beginPhase('render:selection');
485
+ this.drawSelection(canvas, graph, selectedIds, overlays);
486
+ p.endPhase('render:selection');
487
+ this.drawFlashes(canvas, graph);
488
+ this.drawSnapGuides(canvas, overlays.snapGuides);
489
+ if (overlays.measurementMode) {
490
+ this.drawMeasurements(canvas, graph, selectedIds, overlays.hoveredNodeId);
491
+ this.drawPaddingOverlay(canvas, graph, selectedIds);
492
+ }
493
+ this.drawMarquee(canvas, overlays.marquee);
494
+ this.drawLayoutInsertIndicator(canvas, overlays.layoutInsertIndicator);
495
+ this.drawPenOverlay(canvas, overlays.penState);
496
+ this.drawRemoteCursors(canvas, graph, overlays.remoteCursors);
497
+ p.beginPhase('render:rulers');
498
+ if (this.showRulers)
499
+ this.drawRulers(canvas, graph, selectedIds);
500
+ p.endPhase('render:rulers');
501
+ p.drawHUD(canvas, this.showRulers);
502
+ canvas.restore();
503
+ p.beginPhase('render:flush');
504
+ this.surface.flush();
505
+ p.endPhase('render:flush');
506
+ p.setNodeCounts(this._nodeCount, this._culledCount);
507
+ p.endFrame();
508
+ }
509
+ recordScenePicture(canvas, graph, sceneVersion) {
510
+ this.scenePicture?.delete();
511
+ const prevViewport = this.worldViewport;
512
+ this.worldViewport = { x: -1e6, y: -1e6, w: 2e6, h: 2e6 };
513
+ const recorder = new this.ck.PictureRecorder();
514
+ const bounds = this.ck.LTRBRect(-1e6, -1e6, 1e6, 1e6);
515
+ const recCanvas = recorder.beginRecording(bounds);
516
+ const pageNode = graph.getNode(this.pageId ?? graph.rootId);
517
+ if (pageNode) {
518
+ for (const childId of pageNode.childIds) {
519
+ this.renderNode(recCanvas, graph, childId, {}, 0, 0);
520
+ }
521
+ }
522
+ this.scenePicture = recorder.finishRecordingAsPicture();
523
+ recorder.delete();
524
+ this.worldViewport = prevViewport;
525
+ this.scenePictureVersion = sceneVersion;
526
+ this.scenePicturePageId = this.pageId;
527
+ canvas.drawPicture(this.scenePicture);
528
+ }
529
+ invalidateVectorPath(nodeId) {
530
+ this.vectorPathCache.delete(nodeId);
531
+ this.fillGeometryCache.delete(nodeId);
532
+ this.strokeGeometryCache.delete(nodeId);
533
+ }
534
+ measureTextNode(node, maxWidth) {
535
+ if (!this.fontsLoaded || !this.fontProvider || !this.isNodeFontLoaded(node))
536
+ return null;
537
+ if (node.type !== 'TEXT' || !node.text)
538
+ return null;
539
+ const paragraph = this.buildParagraph(node);
540
+ const layoutWidth = maxWidth !== undefined
541
+ ? maxWidth
542
+ : (node.textAutoResize === 'WIDTH_AND_HEIGHT'
543
+ ? 1e6
544
+ : node.width || 1e6);
545
+ paragraph.layout(layoutWidth);
546
+ const width = paragraph.getLongestLine();
547
+ const height = paragraph.getHeight();
548
+ paragraph.delete();
549
+ return { width: Math.ceil(width), height: Math.ceil(height) };
550
+ }
551
+ isNodeFontLoaded(node) {
552
+ const families = new Set();
553
+ families.add(node.fontFamily || DEFAULT_FONT_FAMILY);
554
+ for (const run of node.styleRuns) {
555
+ if (run.style.fontFamily)
556
+ families.add(run.style.fontFamily);
557
+ }
558
+ return [...families].every((f) => isFontLoaded(f));
559
+ }
560
+ buildTextPicture(node) {
561
+ if (!this.fontsLoaded || !this.fontProvider || !this.isNodeFontLoaded(node))
562
+ return null;
563
+ if (node.type !== 'TEXT' || !node.text)
564
+ return null;
565
+ const ck = this.ck;
566
+ const recorder = new ck.PictureRecorder();
567
+ const bounds = ck.LTRBRect(0, 0, node.width || 1e6, node.height || 1e6);
568
+ const recCanvas = recorder.beginRecording(bounds);
569
+ const paragraph = this.buildParagraph(node, undefined, { halfLeading: true });
570
+ recCanvas.drawParagraph(paragraph, 0, 0);
571
+ paragraph.delete();
572
+ const picture = recorder.finishRecordingAsPicture();
573
+ recorder.delete();
574
+ const bytes = picture.serialize();
575
+ picture.delete();
576
+ return bytes ?? null;
577
+ }
578
+ buildParagraph(node, color, { halfLeading = false } = {}) {
579
+ const ck = this.ck;
580
+ const baseColor = color ?? ck.BLACK;
581
+ const baseFontSize = node.fontSize || DEFAULT_FONT_SIZE;
582
+ const cjkFallback = getCJKFallbackFamily();
583
+ const truncateOpts = this.buildTruncateOpts(node, baseFontSize);
584
+ const fontFamilies = (primary) => cjkFallback ? [primary, cjkFallback] : [primary];
585
+ const paraStyle = new ck.ParagraphStyle({
586
+ textAlign: this.getTextAlign(node.textAlignHorizontal),
587
+ ...truncateOpts,
588
+ textStyle: {
589
+ color: baseColor,
590
+ fontFamilies: fontFamilies(node.fontFamily || DEFAULT_FONT_FAMILY),
591
+ fontSize: baseFontSize,
592
+ fontStyle: {
593
+ weight: { value: node.fontWeight || 400 },
594
+ slant: node.italic ? ck.FontSlant.Italic : ck.FontSlant.Upright
595
+ },
596
+ letterSpacing: node.letterSpacing || 0,
597
+ decoration: this.textDecorationValue(node.textDecoration),
598
+ heightMultiplier: node.lineHeight ? node.lineHeight / baseFontSize : undefined,
599
+ halfLeading
600
+ }
601
+ });
602
+ if (!this.fontProvider)
603
+ throw new Error('Font provider not initialized');
604
+ const builder = ck.ParagraphBuilder.MakeFromFontProvider(paraStyle, this.fontProvider);
605
+ if (node.styleRuns.length === 0) {
606
+ builder.addText(node.text);
607
+ }
608
+ else {
609
+ this.addStyledRuns(builder, node, baseColor, baseFontSize, fontFamilies, halfLeading);
610
+ }
611
+ const paragraph = builder.build();
612
+ paragraph.layout(node.width || 1e6);
613
+ builder.delete();
614
+ return paragraph;
615
+ }
616
+ buildTruncateOpts(node, baseFontSize) {
617
+ if (node.textTruncation !== 'ENDING')
618
+ return {};
619
+ const opts = { ellipsis: '…' };
620
+ if (node.maxLines != null && node.maxLines > 0) {
621
+ opts.maxLines = node.maxLines;
622
+ }
623
+ else if (node.height > 0) {
624
+ const lineH = node.lineHeight || baseFontSize * 1.2;
625
+ opts.maxLines = Math.max(1, Math.floor(node.height / lineH));
626
+ }
627
+ return opts;
628
+ }
629
+ addStyledRuns(builder, node, baseColor, baseFontSize, fontFamilies, halfLeading) {
630
+ const ck = this.ck;
631
+ const text = node.text;
632
+ let pos = 0;
633
+ for (const run of node.styleRuns) {
634
+ if (pos < run.start) {
635
+ builder.addText(text.slice(pos, run.start));
636
+ }
637
+ const s = run.style;
638
+ const runLineHeight = s.lineHeight !== undefined ? s.lineHeight : node.lineHeight;
639
+ const runFontSize = s.fontSize ?? baseFontSize;
640
+ builder.pushStyle(new ck.TextStyle({
641
+ color: baseColor,
642
+ fontFamilies: fontFamilies(s.fontFamily ?? (node.fontFamily || DEFAULT_FONT_FAMILY)),
643
+ fontSize: runFontSize,
644
+ fontStyle: {
645
+ weight: { value: (s.fontWeight ?? node.fontWeight) || 400 },
646
+ slant: (s.italic ?? node.italic) ? ck.FontSlant.Italic : ck.FontSlant.Upright
647
+ },
648
+ letterSpacing: s.letterSpacing ?? (node.letterSpacing || 0),
649
+ decoration: this.textDecorationValue(s.textDecoration ?? node.textDecoration),
650
+ heightMultiplier: runLineHeight ? runLineHeight / runFontSize : undefined,
651
+ halfLeading
652
+ }));
653
+ builder.addText(text.slice(run.start, run.start + run.length));
654
+ builder.pop();
655
+ pos = run.start + run.length;
656
+ }
657
+ if (pos < text.length) {
658
+ builder.addText(text.slice(pos));
659
+ }
660
+ }
661
+ textDecorationValue(decoration) {
662
+ switch (decoration) {
663
+ case 'UNDERLINE':
664
+ return this.ck.UnderlineDecoration;
665
+ case 'STRIKETHROUGH':
666
+ return this.ck.LineThroughDecoration;
667
+ default:
668
+ return this.ck.NoDecoration;
669
+ }
670
+ }
671
+ getTextAlign(align) {
672
+ switch (align) {
673
+ case 'CENTER':
674
+ return this.ck.TextAlign.Center;
675
+ case 'RIGHT':
676
+ return this.ck.TextAlign.Right;
677
+ case 'JUSTIFIED':
678
+ return this.ck.TextAlign.Justify;
679
+ default:
680
+ return this.ck.TextAlign.Left;
681
+ }
682
+ }
683
+ resolveFillColor(fill, fillIndex, node, graph) {
684
+ const varId = node.boundVariables[`fills/${fillIndex}/color`];
685
+ if (varId) {
686
+ const resolved = graph.resolveColorVariable(varId);
687
+ if (resolved)
688
+ return resolved;
689
+ }
690
+ return fill.color;
691
+ }
692
+ resolveStrokeColor(stroke, strokeIndex, node, graph) {
693
+ const varId = node.boundVariables[`strokes/${strokeIndex}/color`];
694
+ if (varId) {
695
+ const resolved = graph.resolveColorVariable(varId);
696
+ if (resolved)
697
+ return resolved;
698
+ }
699
+ return stroke.color;
700
+ }
701
+ screenToCanvas(sx, sy) {
702
+ return {
703
+ x: (sx - this.panX) / this.zoom,
704
+ y: (sy - this.panY) / this.zoom
705
+ };
706
+ }
707
+ destroyed = false;
708
+ destroy() {
709
+ if (this.destroyed)
710
+ return;
711
+ this.destroyed = true;
712
+ this.imageCache.clear();
713
+ this.vectorPathCache.clear();
714
+ this.fillGeometryCache.clear();
715
+ this.strokeGeometryCache.clear();
716
+ this.fillPaint.delete();
717
+ this.strokePaint.delete();
718
+ this.selectionPaint.delete();
719
+ this.snapPaint.delete();
720
+ this.auxFill.delete();
721
+ this.auxStroke.delete();
722
+ this.opacityPaint.delete();
723
+ this.textFont?.delete();
724
+ this.labelFont?.delete();
725
+ this.sizeFont?.delete();
726
+ this.fontMgr?.delete();
727
+ this.fontProvider?.delete();
728
+ this.rulerBgPaint.delete();
729
+ this.rulerTickPaint.delete();
730
+ this.rulerTextPaint.delete();
731
+ this.rulerHlPaint.delete();
732
+ this.rulerBadgePaint.delete();
733
+ this.rulerLabelPaint.delete();
734
+ this.penPathPaint.delete();
735
+ this.penHandlePaint.delete();
736
+ this.penVertexFill.delete();
737
+ this.penVertexStroke.delete();
738
+ this.effectLayerPaint.delete();
739
+ for (const filter of this.imageFilterCache.values())
740
+ filter.delete();
741
+ this.imageFilterCache.clear();
742
+ for (const filter of this.maskFilterCache.values())
743
+ filter.delete();
744
+ this.maskFilterCache.clear();
745
+ this.nodePictureCache.clear();
746
+ this.scenePicture?.delete();
747
+ this._flashPaint?.delete();
748
+ this.profiler.destroy();
749
+ this.surface.delete();
750
+ }
751
+ // --- Delegation methods ---
752
+ drawHoverHighlight(canvas, graph, hoveredNodeId) {
753
+ drawHoverHighlightFn(this, canvas, graph, hoveredNodeId);
754
+ }
755
+ drawSelection(canvas, graph, selectedIds, overlays) {
756
+ drawSelectionFn(this, canvas, graph, selectedIds, overlays);
757
+ }
758
+ drawNodeSelection(canvas, node, rotation, graph) {
759
+ drawNodeSelectionFn(this, canvas, node, rotation, graph);
760
+ }
761
+ drawSelectionLabels(canvas, graph, selectedIds) {
762
+ drawSelectionLabelsFn(this, canvas, graph, selectedIds);
763
+ }
764
+ drawParentFrameOutlines(canvas, graph, selectedIds) {
765
+ drawParentFrameOutlinesFn(this, canvas, graph, selectedIds);
766
+ }
767
+ drawNodeOutline(canvas, node, rotation, graph) {
768
+ drawNodeOutlineFn(this, canvas, node, rotation, graph);
769
+ }
770
+ drawGroupBounds(canvas, nodes, graph) {
771
+ drawGroupBoundsFn(this, canvas, nodes, graph);
772
+ }
773
+ getRotatedCorners(n, abs) {
774
+ return getRotatedCornersFn(this, n, abs);
775
+ }
776
+ drawHandle(canvas, x, y) {
777
+ drawHandleFn(this, canvas, x, y);
778
+ }
779
+ drawSnapGuides(canvas, guides) {
780
+ drawSnapGuidesFn(this, canvas, guides);
781
+ }
782
+ drawMeasurements(canvas, graph, selectedIds, hoveredNodeId) {
783
+ drawMeasurementsFn(this, canvas, graph, selectedIds, hoveredNodeId);
784
+ }
785
+ drawPaddingOverlay(canvas, graph, selectedIds) {
786
+ drawPaddingOverlayFn(this, canvas, graph, selectedIds);
787
+ }
788
+ drawMarquee(canvas, marquee) {
789
+ drawMarqueeFn(this, canvas, marquee);
790
+ }
791
+ drawFlashes(canvas, graph) {
792
+ drawFlashesFn(this, canvas, graph);
793
+ }
794
+ drawLayoutInsertIndicator(canvas, indicator) {
795
+ drawLayoutInsertIndicatorFn(this, canvas, indicator);
796
+ }
797
+ drawTextEditOverlay(canvas, node, editor) {
798
+ drawTextEditOverlayFn(this, canvas, node, editor);
799
+ }
800
+ drawPenOverlay(canvas, penState) {
801
+ drawPenOverlayFn(this, canvas, penState);
802
+ }
803
+ drawRemoteCursors(canvas, graph, cursors) {
804
+ drawRemoteCursorsFn(this, canvas, graph, cursors);
805
+ }
806
+ drawRulers(canvas, graph, selectedIds) {
807
+ drawRulersFn(this, canvas, graph, selectedIds);
808
+ }
809
+ drawSectionTitles(canvas, graph) {
810
+ drawSectionTitlesFn(this, canvas, graph);
811
+ }
812
+ drawComponentLabels(canvas, graph) {
813
+ drawComponentLabelsFn(this, canvas, graph);
814
+ }
815
+ renderNode(canvas, graph, nodeId, overlays, parentAbsX = 0, parentAbsY = 0) {
816
+ renderNodeFn(this, canvas, graph, nodeId, overlays, parentAbsX, parentAbsY);
817
+ }
818
+ renderSection(canvas, node, graph) {
819
+ renderSectionFn(this, canvas, node, graph);
820
+ }
821
+ renderComponentSet(canvas, node, graph) {
822
+ renderComponentSetFn(this, canvas, node, graph);
823
+ }
824
+ renderShape(canvas, node, graph) {
825
+ renderShapeFn(this, canvas, node, graph);
826
+ }
827
+ renderShapeUncached(canvas, node, graph) {
828
+ renderShapeUncachedFn(this, canvas, node, graph);
829
+ }
830
+ renderEffects(canvas, node, rect, hasRadius, pass) {
831
+ renderEffectsFn(this, canvas, node, rect, hasRadius, pass);
832
+ }
833
+ renderText(canvas, node) {
834
+ renderTextFn(this, canvas, node);
835
+ }
836
+ drawNodeFill(canvas, node, rect, hasRadius) {
837
+ drawNodeFillFn(this, canvas, node, rect, hasRadius);
838
+ }
839
+ applyFill(fill, node, graph, fillIndex = 0) {
840
+ return applyFillFn(this, fill, node, graph, fillIndex);
841
+ }
842
+ applyGradientFill(fill, node) {
843
+ applyGradientFillFn(this, fill, node);
844
+ }
845
+ applyImageFill(fill, node, graph) {
846
+ return applyImageFillFn(this, fill, node, graph);
847
+ }
848
+ drawArc(canvas, node, paint) {
849
+ drawArcFn(this, canvas, node, paint);
850
+ }
851
+ drawNodeStroke(canvas, node, rect, hasRadius) {
852
+ drawNodeStrokeFn(this, canvas, node, rect, hasRadius);
853
+ }
854
+ drawStrokeWithAlign(canvas, node, rect, hasRadius, align) {
855
+ drawStrokeWithAlignFn(this, canvas, node, rect, hasRadius, align);
856
+ }
857
+ drawRRectStrokeWithAlign(canvas, rrect, node, stroke) {
858
+ drawRRectStrokeWithAlignFn(this, canvas, rrect, node, stroke);
859
+ }
860
+ drawIndividualSideStrokes(canvas, node, align) {
861
+ drawIndividualSideStrokesFn(this, canvas, node, align);
862
+ }
863
+ strokeNodeShape(canvas, node, paint) {
864
+ strokeNodeShapeFn(this, canvas, node, paint);
865
+ }
866
+ makeNodeShapePath(node, rect, hasRadius) {
867
+ return makeNodeShapePathFn(this, node, rect, hasRadius);
868
+ }
869
+ makePolygonPath(node) {
870
+ return makePolygonPathFn(this, node);
871
+ }
872
+ makeRRect(node) {
873
+ return makeRRectFn(this, node);
874
+ }
875
+ makeRRectWithSpread(node, spread) {
876
+ return makeRRectWithSpreadFn(this, node, spread);
877
+ }
878
+ makeRRectWithOffset(node, ox, oy, spread) {
879
+ return makeRRectWithOffsetFn(this, node, ox, oy, spread);
880
+ }
881
+ clipNodeShape(canvas, node, rect, hasRadius) {
882
+ clipNodeShapeFn(this, canvas, node, rect, hasRadius);
883
+ }
884
+ getVectorPaths(node) {
885
+ return getVectorPathsFn(this, node);
886
+ }
887
+ getFillGeometry(node) {
888
+ return getFillGeometryFn(this, node);
889
+ }
890
+ getStrokeGeometry(node) {
891
+ return getStrokeGeometryFn(this, node);
892
+ }
893
+ getCachedDropShadow(dx, dy, sigma, color) {
894
+ return getCachedDropShadowFn(this, dx, dy, sigma, color);
895
+ }
896
+ getCachedBlur(sigma) {
897
+ return getCachedBlurFn(this, sigma);
898
+ }
899
+ getCachedDecalBlur(sigma) {
900
+ return getCachedDecalBlurFn(this, sigma);
901
+ }
902
+ getCachedMaskBlur(sigma) {
903
+ return getCachedMaskBlurFn(this, sigma);
904
+ }
905
+ applyClippedBlur(canvas, node, rect, hasRadius, sigma) {
906
+ applyClippedBlurFn(this, canvas, node, rect, hasRadius, sigma);
907
+ }
908
+ }
909
+ //# sourceMappingURL=renderer.js.map