0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 05:33:02 -05:00

Implement components (#106)

* Implement components

* fix

* revert

* wip

* wip

* wip

* 🎉 Finish create component operation

* minor fixes

* not needed, refactor

* refactor not needed

* refactor not needed

* remove deps

* add changelog

* fixes

* fixes

* fixes

* fix lint

* refactor ui-src

* further refactor

* refactor

* refactor

* more refactor

* refactor

* refactor

* penpot lib update

---------

Co-authored-by: Alex Sánchez <sion333@gmail.com>
Co-authored-by: Andrés Moya <andres.moya@kaleidos.net>
This commit is contained in:
Jordi Sala Morales 2024-05-29 12:52:21 +02:00 committed by GitHub
parent 5d7263bdbf
commit 32aafbcf9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 6158 additions and 6241 deletions

View file

@ -0,0 +1,5 @@
---
"penpot-exporter": minor
---
Implement root component translation

433
package-lock.json generated
View file

@ -989,9 +989,9 @@
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.1.tgz",
"integrity": "sha512-O7yppwipkXvnEPjzkSXJRk2g4bS8sUx9p9oXHq9MU/U7lxUzZVsnFZMDTmeeX9bfQxrFcvOacl/ENgOh0WP9pA==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.2.tgz",
"integrity": "sha512-/c7hocx0pm14bHQlqUVKmxwdT/e5/KkyoY1W8F9lk/8CkE037STDDz8PXUP/LE6faj2HqchvDs9GcShxFhI78Q==",
"cpu": [
"ppc64"
],
@ -1005,9 +1005,9 @@
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.1.tgz",
"integrity": "sha512-hh3jKWikdnTtHCglDAeVO3Oyh8MaH8xZUaWMiCCvJ9/c3NtPqZq+CACOlGTxhddypXhl+8B45SeceYBfB/e8Ow==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.2.tgz",
"integrity": "sha512-G1ve3b4FeyJeyCjB4MX1CiWyTaIJwT9wAYE+8+IRA53YoN/reC/Bf2GDRXAzDTnh69Fpl+1uIKg76DiB3U6vwQ==",
"cpu": [
"arm"
],
@ -1021,9 +1021,9 @@
}
},
"node_modules/@esbuild/android-arm64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.1.tgz",
"integrity": "sha512-jXhccq6es+onw7x8MxoFnm820mz7sGa9J14kLADclmiEUH4fyj+FjR6t0M93RgtlI/awHWhtF0Wgfhqgf9gDZA==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.2.tgz",
"integrity": "sha512-SGZKngoTWVUriO5bDjI4WDGsNx2VKZoXcds+ita/kVYB+8IkSCKDRDaK+5yu0b5S0eq6B3S7fpiEvpsa2ammlQ==",
"cpu": [
"arm64"
],
@ -1037,9 +1037,9 @@
}
},
"node_modules/@esbuild/android-x64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.1.tgz",
"integrity": "sha512-NPObtlBh4jQHE01gJeucqEhdoD/4ya2owSIS8lZYS58aR0x7oZo9lB2lVFxgTANSa5MGCBeoQtr+yA9oKCGPvA==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.2.tgz",
"integrity": "sha512-1wzzNoj2QtNkAYwIcWJ66UTRA80+RTQ/kuPMtEuP0X6dp5Ar23Dn566q3aV61h4EYrrgGlOgl/HdcqN/2S/2vg==",
"cpu": [
"x64"
],
@ -1053,9 +1053,9 @@
}
},
"node_modules/@esbuild/darwin-arm64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.1.tgz",
"integrity": "sha512-BLT7TDzqsVlQRmJfO/FirzKlzmDpBWwmCUlyggfzUwg1cAxVxeA4O6b1XkMInlxISdfPAOunV9zXjvh5x99Heg==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.2.tgz",
"integrity": "sha512-ZyMkPWc5eTROcLOA10lEqdDSTc6ds6nuh3DeHgKip/XJrYjZDfnkCVSty8svWdy+SC1f77ULtVeIqymTzaB6/Q==",
"cpu": [
"arm64"
],
@ -1069,9 +1069,9 @@
}
},
"node_modules/@esbuild/darwin-x64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.1.tgz",
"integrity": "sha512-D3h3wBQmeS/vp93O4B+SWsXB8HvRDwMyhTNhBd8yMbh5wN/2pPWRW5o/hM3EKgk9bdKd9594lMGoTCTiglQGRQ==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.2.tgz",
"integrity": "sha512-K4ZdVq1zP9v51h/cKVna7im7G0zGTKKB6bP2yJiSmHjjOykbd8DdhrSi8V978sF69rkwrn8zCyL2t6I3ei6j9A==",
"cpu": [
"x64"
],
@ -1085,9 +1085,9 @@
}
},
"node_modules/@esbuild/freebsd-arm64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.1.tgz",
"integrity": "sha512-/uVdqqpNKXIxT6TyS/oSK4XE4xWOqp6fh4B5tgAwozkyWdylcX+W4YF2v6SKsL4wCQ5h1bnaSNjWPXG/2hp8AQ==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.2.tgz",
"integrity": "sha512-4kbOGdpA61CXqadD+Gb/Pw3YXamQGiz9mal/h93rFVSjr5cgMnmJd/gbfPRm+3BMifvnaOfS1gNWaIDxkE2A3A==",
"cpu": [
"arm64"
],
@ -1101,9 +1101,9 @@
}
},
"node_modules/@esbuild/freebsd-x64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.1.tgz",
"integrity": "sha512-paAkKN1n1jJitw+dAoR27TdCzxRl1FOEITx3h201R6NoXUojpMzgMLdkXVgCvaCSCqwYkeGLoe9UVNRDKSvQgw==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.2.tgz",
"integrity": "sha512-ShS+R09nuHzDBfPeMUliKZX27Wrmr8UFp93aFf/S8p+++x5BZ+D344CLKXxmY6qzgTL3mILSImPCNJOzD6+RRg==",
"cpu": [
"x64"
],
@ -1117,9 +1117,9 @@
}
},
"node_modules/@esbuild/linux-arm": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.1.tgz",
"integrity": "sha512-tRHnxWJnvNnDpNVnsyDhr1DIQZUfCXlHSCDohbXFqmg9W4kKR7g8LmA3kzcwbuxbRMKeit8ladnCabU5f2traA==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.2.tgz",
"integrity": "sha512-nnGXjOAv+7cM3LYRx4tJsYdgy8dGDGkAzF06oIDGppWbUkUKN9SmgQA8H0KukpU0Pjrj9XmgbWqMVSX/U7eeTA==",
"cpu": [
"arm"
],
@ -1133,9 +1133,9 @@
}
},
"node_modules/@esbuild/linux-arm64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.1.tgz",
"integrity": "sha512-G65d08YoH00TL7Xg4LaL3gLV21bpoAhQ+r31NUu013YB7KK0fyXIt05VbsJtpqh/6wWxoLJZOvQHYnodRrnbUQ==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.2.tgz",
"integrity": "sha512-Hdu8BL+AmO+eCDvvT6kz/fPQhvuHL8YK4ExKZfANWsNe1kFGOHw7VJvS/FKSLFqheXmB3rTF3xFQIgUWPYsGnA==",
"cpu": [
"arm64"
],
@ -1149,9 +1149,9 @@
}
},
"node_modules/@esbuild/linux-ia32": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.1.tgz",
"integrity": "sha512-tt/54LqNNAqCz++QhxoqB9+XqdsaZOtFD/srEhHYwBd3ZUOepmR1Eeot8bS+Q7BiEvy9vvKbtpHf+r6q8hF5UA==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.2.tgz",
"integrity": "sha512-m73BOCW2V9lcj7RtEMi+gBfHC6n3+VHpwQXP5offtQMPLDkpVolYn1YGXxOZ9hp4h3UPRKuezL7WkBsw+3EB3Q==",
"cpu": [
"ia32"
],
@ -1165,9 +1165,9 @@
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.1.tgz",
"integrity": "sha512-MhNalK6r0nZD0q8VzUBPwheHzXPr9wronqmZrewLfP7ui9Fv1tdPmg6e7A8lmg0ziQCziSDHxh3cyRt4YMhGnQ==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.2.tgz",
"integrity": "sha512-84eYHwwWHq3myIY/6ikALMcnwkf6Qo7NIq++xH0x+cJuUNpdwh8mlpUtRY+JiGUc60yu7ElWBbVHGWTABTclGw==",
"cpu": [
"loong64"
],
@ -1181,9 +1181,9 @@
}
},
"node_modules/@esbuild/linux-mips64el": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.1.tgz",
"integrity": "sha512-YCKVY7Zen5rwZV+nZczOhFmHaeIxR4Zn3jcmNH53LbgF6IKRwmrMywqDrg4SiSNApEefkAbPSIzN39FC8VsxPg==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.2.tgz",
"integrity": "sha512-9siSZngT0/ZKG+AH+/agwKF29LdCxw4ODi/PiE0F52B2rtLozlDP92umf8G2GPoVV611LN4pZ+nSTckebOscUA==",
"cpu": [
"mips64el"
],
@ -1197,9 +1197,9 @@
}
},
"node_modules/@esbuild/linux-ppc64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.1.tgz",
"integrity": "sha512-bw7bcQ+270IOzDV4mcsKAnDtAFqKO0jVv3IgRSd8iM0ac3L8amvCrujRVt1ajBTJcpDaFhIX+lCNRKteoDSLig==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.2.tgz",
"integrity": "sha512-y0T4aV2CA+ic04ULya1A/8M2RDpDSK2ckgTj6jzHKFJvCq0jQg8afQQIn4EM0G8u2neyOiNHgSF9YKPfuqKOVw==",
"cpu": [
"ppc64"
],
@ -1213,9 +1213,9 @@
}
},
"node_modules/@esbuild/linux-riscv64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.1.tgz",
"integrity": "sha512-ARmDRNkcOGOm1AqUBSwRVDfDeD9hGYRfkudP2QdoonBz1ucWVnfBPfy7H4JPI14eYtZruRSczJxyu7SRYDVOcg==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.2.tgz",
"integrity": "sha512-x5ssCdXmZC86L2Li1qQPF/VaC4VP20u/Zm8jlAu9IiVOVi79YsSz6cpPDYZl1rfKSHYCJW9XBfFCo66S5gVPSA==",
"cpu": [
"riscv64"
],
@ -1229,9 +1229,9 @@
}
},
"node_modules/@esbuild/linux-s390x": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.1.tgz",
"integrity": "sha512-o73TcUNMuoTZlhwFdsgr8SfQtmMV58sbgq6gQq9G1xUiYnHMTmJbwq65RzMx89l0iya69lR4bxBgtWiiOyDQZA==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.2.tgz",
"integrity": "sha512-NP7fTpGSFWdXyvp8iAFU04uFh9ARoplFVM/m+8lTRpaYG+2ytHPZWyscSsMM6cvObSIK2KoPHXiZD4l99WaxbQ==",
"cpu": [
"s390x"
],
@ -1245,9 +1245,9 @@
}
},
"node_modules/@esbuild/linux-x64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.1.tgz",
"integrity": "sha512-da4/1mBJwwgJkbj4fMH7SOXq2zapgTo0LKXX1VUZ0Dxr+e8N0WbS80nSZ5+zf3lvpf8qxrkZdqkOqFfm57gXwA==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.2.tgz",
"integrity": "sha512-giZ/uOxWDKda44ZuyfKbykeXznfuVNkTgXOUOPJIjbayJV6FRpQ4zxUy9JMBPLaK9IJcdWtaoeQrYBMh3Rr4vQ==",
"cpu": [
"x64"
],
@ -1261,9 +1261,9 @@
}
},
"node_modules/@esbuild/netbsd-x64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.1.tgz",
"integrity": "sha512-CPWs0HTFe5woTJN5eKPvgraUoRHrCtzlYIAv9wBC+FAyagBSaf+UdZrjwYyTGnwPGkThV4OCI7XibZOnPvONVw==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.2.tgz",
"integrity": "sha512-IeFMfGFSQfIj1d4XU+6lkbFzMR+mFELUUVYrZ+jvWzG4NGvs6o53ReEHLHpYkjRbdEjJy2W3lTekTxrFHW7YJg==",
"cpu": [
"x64"
],
@ -1277,9 +1277,9 @@
}
},
"node_modules/@esbuild/openbsd-x64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.1.tgz",
"integrity": "sha512-xxhTm5QtzNLc24R0hEkcH+zCx/o49AsdFZ0Cy5zSd/5tOj4X2g3/2AJB625NoadUuc4A8B3TenLJoYdWYOYCew==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.2.tgz",
"integrity": "sha512-48QhWD6WxcebNNaE4FCwgvQVUnAycuTd+BdvA/oZu+/MmbpU8pY2dMEYlYzj5uNHWIG5jvdDmFXu0naQeOWUoA==",
"cpu": [
"x64"
],
@ -1293,9 +1293,9 @@
}
},
"node_modules/@esbuild/sunos-x64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.1.tgz",
"integrity": "sha512-CWibXszpWys1pYmbr9UiKAkX6x+Sxw8HWtw1dRESK1dLW5fFJ6rMDVw0o8MbadusvVQx1a8xuOxnHXT941Hp1A==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.2.tgz",
"integrity": "sha512-90r3nTBLgdIgD4FCVV9+cR6Hq2Dzs319icVsln+NTmTVwffWcCqXGml8rAoocHuJ85kZK36DCteii96ba/PX8g==",
"cpu": [
"x64"
],
@ -1309,9 +1309,9 @@
}
},
"node_modules/@esbuild/win32-arm64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.1.tgz",
"integrity": "sha512-jb5B4k+xkytGbGUS4T+Z89cQJ9DJ4lozGRSV+hhfmCPpfJ3880O31Q1srPCimm+V6UCbnigqD10EgDNgjvjerQ==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.2.tgz",
"integrity": "sha512-sNndlsBT8OeE/MZDSGpRDJlWuhjuUz/dn80nH0EP4ZzDUYvMDVa7G87DVpweBrn4xdJYyXS/y4CQNrf7R2ODXg==",
"cpu": [
"arm64"
],
@ -1325,9 +1325,9 @@
}
},
"node_modules/@esbuild/win32-ia32": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.1.tgz",
"integrity": "sha512-PgyFvjJhXqHn1uxPhyN1wZ6dIomKjiLUQh1LjFvjiV1JmnkZ/oMPrfeEAZg5R/1ftz4LZWZr02kefNIQ5SKREQ==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.2.tgz",
"integrity": "sha512-Ti2QChGNFzWhUNNVuU4w21YkYTErsNh3h+CzvlEhzgRbwsJ7TrWQqRzW3bllLKKvTppuF3DJ3XP1GEg11AfrEQ==",
"cpu": [
"ia32"
],
@ -1341,9 +1341,9 @@
}
},
"node_modules/@esbuild/win32-x64": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.1.tgz",
"integrity": "sha512-W9NttRZQR5ehAiqHGDnvfDaGmQOm6Fi4vSlce8mjM75x//XKuVAByohlEX6N17yZnVXxQFuh4fDRunP8ca6bfA==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.2.tgz",
"integrity": "sha512-VEfTCZicoZnZ6sGkjFPGRFFJuL2fZn2bLhsekZl1CJslflp2cJS/VoKs1jMk+3pDfsGW6CfQVUckP707HwbXeQ==",
"cpu": [
"x64"
],
@ -2434,17 +2434,6 @@
"integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==",
"dev": true
},
"node_modules/@swc/helpers": {
"version": "0.5.11",
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.11.tgz",
"integrity": "sha512-YNlnKRWF2sVojTpIyzwou9XoTNbzbzONwRhOoniEioF1AtaitTvVZblaQRrAzChWQ1bLYyYSWzM18y4WwgzJ+A==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@swc/types": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.6.tgz",
@ -3917,20 +3906,6 @@
"node": ">=8"
}
},
"node_modules/detect-libc": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==",
"dev": true,
"optional": true,
"peer": true,
"bin": {
"detect-libc": "bin/detect-libc.js"
},
"engines": {
"node": ">=0.10"
}
},
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@ -4188,9 +4163,9 @@
}
},
"node_modules/esbuild": {
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.1.tgz",
"integrity": "sha512-GPqx+FX7mdqulCeQ4TsGZQ3djBJkx5k7zBGtqt9ycVlWNg8llJ4RO9n2vciu8BN2zAEs6lPbPl0asZsAh7oWzg==",
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.2.tgz",
"integrity": "sha512-LmHPAa5h4tSxz+g/D8IHY6wCjtIiFx8I7/Q0Aq+NmvtoYvyMnJU0KQJcqB6QH30X9x/W4CemgUtPgQDZFca5SA==",
"dev": true,
"hasInstallScript": true,
"bin": {
@ -4200,29 +4175,29 @@
"node": ">=12"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.21.1",
"@esbuild/android-arm": "0.21.1",
"@esbuild/android-arm64": "0.21.1",
"@esbuild/android-x64": "0.21.1",
"@esbuild/darwin-arm64": "0.21.1",
"@esbuild/darwin-x64": "0.21.1",
"@esbuild/freebsd-arm64": "0.21.1",
"@esbuild/freebsd-x64": "0.21.1",
"@esbuild/linux-arm": "0.21.1",
"@esbuild/linux-arm64": "0.21.1",
"@esbuild/linux-ia32": "0.21.1",
"@esbuild/linux-loong64": "0.21.1",
"@esbuild/linux-mips64el": "0.21.1",
"@esbuild/linux-ppc64": "0.21.1",
"@esbuild/linux-riscv64": "0.21.1",
"@esbuild/linux-s390x": "0.21.1",
"@esbuild/linux-x64": "0.21.1",
"@esbuild/netbsd-x64": "0.21.1",
"@esbuild/openbsd-x64": "0.21.1",
"@esbuild/sunos-x64": "0.21.1",
"@esbuild/win32-arm64": "0.21.1",
"@esbuild/win32-ia32": "0.21.1",
"@esbuild/win32-x64": "0.21.1"
"@esbuild/aix-ppc64": "0.21.2",
"@esbuild/android-arm": "0.21.2",
"@esbuild/android-arm64": "0.21.2",
"@esbuild/android-x64": "0.21.2",
"@esbuild/darwin-arm64": "0.21.2",
"@esbuild/darwin-x64": "0.21.2",
"@esbuild/freebsd-arm64": "0.21.2",
"@esbuild/freebsd-x64": "0.21.2",
"@esbuild/linux-arm": "0.21.2",
"@esbuild/linux-arm64": "0.21.2",
"@esbuild/linux-ia32": "0.21.2",
"@esbuild/linux-loong64": "0.21.2",
"@esbuild/linux-mips64el": "0.21.2",
"@esbuild/linux-ppc64": "0.21.2",
"@esbuild/linux-riscv64": "0.21.2",
"@esbuild/linux-s390x": "0.21.2",
"@esbuild/linux-x64": "0.21.2",
"@esbuild/netbsd-x64": "0.21.2",
"@esbuild/openbsd-x64": "0.21.2",
"@esbuild/sunos-x64": "0.21.2",
"@esbuild/win32-arm64": "0.21.2",
"@esbuild/win32-ia32": "0.21.2",
"@esbuild/win32-x64": "0.21.2"
}
},
"node_modules/escalade": {
@ -5992,224 +5967,6 @@
"node": ">= 0.8.0"
}
},
"node_modules/lightningcss": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.24.1.tgz",
"integrity": "sha512-kUpHOLiH5GB0ERSv4pxqlL0RYKnOXtgGtVe7shDGfhS0AZ4D1ouKFYAcLcZhql8aMspDNzaUCumGHZ78tb2fTg==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"detect-libc": "^1.0.3"
},
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"optionalDependencies": {
"lightningcss-darwin-arm64": "1.24.1",
"lightningcss-darwin-x64": "1.24.1",
"lightningcss-freebsd-x64": "1.24.1",
"lightningcss-linux-arm-gnueabihf": "1.24.1",
"lightningcss-linux-arm64-gnu": "1.24.1",
"lightningcss-linux-arm64-musl": "1.24.1",
"lightningcss-linux-x64-gnu": "1.24.1",
"lightningcss-linux-x64-musl": "1.24.1",
"lightningcss-win32-x64-msvc": "1.24.1"
}
},
"node_modules/lightningcss-darwin-arm64": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.24.1.tgz",
"integrity": "sha512-1jQ12jBy+AE/73uGQWGSafK5GoWgmSiIQOGhSEXiFJSZxzV+OXIx+a9h2EYHxdJfX864M+2TAxWPWb0Vv+8y4w==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"peer": true,
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-darwin-x64": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.24.1.tgz",
"integrity": "sha512-R4R1d7VVdq2mG4igMU+Di8GPf0b64ZLnYVkubYnGG0Qxq1KaXQtAzcLI43EkpnoWvB/kUg8JKCWH4S13NfiLcQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"peer": true,
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-freebsd-x64": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.24.1.tgz",
"integrity": "sha512-z6NberUUw5ALES6Ixn2shmjRRrM1cmEn1ZQPiM5IrZ6xHHL5a1lPin9pRv+w6eWfcrEo+qGG6R9XfJrpuY3e4g==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
],
"peer": true,
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-arm-gnueabihf": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.24.1.tgz",
"integrity": "sha512-NLQLnBQW/0sSg74qLNI8F8QKQXkNg4/ukSTa+XhtkO7v3BnK19TS1MfCbDHt+TTdSgNEBv0tubRuapcKho2EWw==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-arm64-gnu": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.24.1.tgz",
"integrity": "sha512-AQxWU8c9E9JAjAi4Qw9CvX2tDIPjgzCTrZCSXKELfs4mCwzxRkHh2RCxX8sFK19RyJoJAjA/Kw8+LMNRHS5qEg==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-arm64-musl": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.24.1.tgz",
"integrity": "sha512-JCgH/SrNrhqsguUA0uJUM1PvN5+dVuzPIlXcoWDHSv2OU/BWlj2dUYr3XNzEw748SmNZPfl2NjQrAdzaPOn1lA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-x64-gnu": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.24.1.tgz",
"integrity": "sha512-TYdEsC63bHV0h47aNRGN3RiK7aIeco3/keN4NkoSQ5T8xk09KHuBdySltWAvKLgT8JvR+ayzq8ZHnL1wKWY0rw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-linux-x64-musl": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.24.1.tgz",
"integrity": "sha512-HLfzVik3RToot6pQ2Rgc3JhfZkGi01hFetHt40HrUMoeKitLoqUUT5owM6yTZPTytTUW9ukLBJ1pc3XNMSvlLw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"peer": true,
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lightningcss-win32-x64-msvc": {
"version": "1.24.1",
"resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.24.1.tgz",
"integrity": "sha512-joEupPjYJ7PjZtDsS5lzALtlAudAbgIBMGJPNeFe5HfdmJXFd13ECmEM+5rXNxYVMRHua2w8132R6ab5Z6K9Ow==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"peer": true,
"engines": {
"node": ">= 12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/lines-and-columns": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",

View file

@ -1,4 +1,5 @@
export * from './transformBooleanNode';
export * from './transformComponentNode';
export * from './transformDocumentNode';
export * from './transformEllipseNode';
export * from './transformFrameNode';

View file

@ -0,0 +1,34 @@
import {
transformBlend,
transformCornerRadius,
transformDimensionAndPosition,
transformEffects,
transformFills,
transformProportion,
transformSceneNode,
transformStrokes
} from '@plugin/transformers/partials';
import { transformChildren } from '@plugin/transformers/partials';
import { ComponentShape } from '@ui/lib/types/shapes/componentShape';
export const transformComponentNode = async (
node: ComponentNode,
baseX: number,
baseY: number
): Promise<ComponentShape> => {
return {
type: 'component',
name: node.name,
path: '',
...(await transformFills(node)),
...transformEffects(node),
...(await transformStrokes(node)),
...transformSceneNode(node),
...transformBlend(node),
...transformProportion(node),
...transformCornerRadius(node),
...(await transformChildren(node, baseX + node.x, baseY + node.y)),
...transformDimensionAndPosition(node, baseX, baseY)
};
};

View file

@ -2,6 +2,7 @@ import { PenpotNode } from '@ui/lib/types/penpotNode';
import {
transformBooleanNode,
transformComponentNode,
transformEllipseNode,
transformFrameNode,
transformGroupNode,
@ -36,6 +37,8 @@ export const transformSceneNode = async (
return await transformPathNode(node, baseX, baseY);
case 'BOOLEAN_OPERATION':
return await transformBooleanNode(node, baseX, baseY);
case 'COMPONENT':
return await transformComponentNode(node, baseX, baseY);
}
console.error(`Unsupported node type: ${node.type}`);

View file

@ -3,8 +3,8 @@ import { useEffect, useState } from 'react';
import { FormProvider, useForm } from 'react-hook-form';
import { Stack } from '@ui/components/Stack';
import { createPenpotFile } from '@ui/converters';
import { PenpotDocument } from '@ui/lib/types/penpotDocument';
import { parse } from '@ui/parser';
import { MissingFontsSection } from './MissingFontsSection';
@ -22,7 +22,7 @@ export const PenpotExporter = () => {
const onMessage = (event: MessageEvent<{ pluginMessage: { type: string; data: unknown } }>) => {
if (event.data.pluginMessage?.type == 'PENPOT_DOCUMENT') {
const document = event.data.pluginMessage.data as PenpotDocument;
const file = createPenpotFile(document);
const file = parse(document);
file.export();

View file

@ -1,22 +0,0 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { FrameShape } from '@ui/lib/types/shapes/frameShape';
import { translateFillGradients, translateUiBlendMode } from '@ui/translators';
import { createPenpotItem } from '.';
export const createPenpotArtboard = (
file: PenpotFile,
{ type, fills, blendMode, children = [], ...rest }: FrameShape
) => {
file.addArtboard({
fills: translateFillGradients(fills),
blendMode: translateUiBlendMode(blendMode),
...rest
});
for (const child of children) {
createPenpotItem(file, child);
}
file.closeArtboard();
};

View file

@ -1,22 +0,0 @@
import { createPenpotItem } from '@ui/converters/createPenpotItem';
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { BoolShape } from '@ui/lib/types/shapes/boolShape';
import { translateFillGradients, translateUiBlendMode, translateUiBoolType } from '@ui/translators';
export const createPenpotBool = (
file: PenpotFile,
{ type, fills, boolType, blendMode, children = [], ...rest }: BoolShape
) => {
file.addBool({
fills: translateFillGradients(fills),
blendMode: translateUiBlendMode(blendMode),
boolType: translateUiBoolType(boolType),
...rest
});
for (const child of children) {
createPenpotItem(file, child);
}
file.closeBool();
};

View file

@ -1,14 +0,0 @@
import { createFile } from '@ui/lib/penpot';
import { PenpotDocument } from '@ui/lib/types/penpotDocument';
import { createPenpotPage } from '.';
export const createPenpotFile = (node: PenpotDocument) => {
const file = createFile(node.name);
for (const page of node.children ?? []) {
createPenpotPage(file, page);
}
return file;
};

View file

@ -1,31 +0,0 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { PenpotNode } from '@ui/lib/types/penpotNode';
import {
createPenpotArtboard,
createPenpotBool,
createPenpotCircle,
createPenpotGroup,
createPenpotPath,
createPenpotRectangle,
createPenpotText
} from '.';
export const createPenpotItem = (file: PenpotFile, node: PenpotNode) => {
switch (node.type) {
case 'rect':
return createPenpotRectangle(file, node);
case 'circle':
return createPenpotCircle(file, node);
case 'frame':
return createPenpotArtboard(file, node);
case 'group':
return createPenpotGroup(file, node);
case 'path':
return createPenpotPath(file, node);
case 'text':
return createPenpotText(file, node);
case 'bool':
return createPenpotBool(file, node);
}
};

View file

@ -1,14 +0,0 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { PenpotPage } from '@ui/lib/types/penpotPage';
import { createPenpotItem } from '.';
export const createPenpotPage = (file: PenpotFile, node: PenpotPage) => {
file.addPage(node.name, node.options);
for (const child of node.children ?? []) {
createPenpotItem(file, child);
}
file.closePage();
};

View file

@ -1,19 +0,0 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { PathShape } from '@ui/lib/types/shapes/pathShape';
import {
translateFillGradients,
translatePathContent,
translateUiBlendMode
} from '@ui/translators';
export const createPenpotPath = (
file: PenpotFile,
{ type, fills, blendMode, content, ...rest }: PathShape
) => {
file.createPath({
fills: translateFillGradients(fills),
blendMode: translateUiBlendMode(blendMode),
content: translatePathContent(content),
...rest
});
};

View file

@ -1,10 +0,0 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { TextShape } from '@ui/lib/types/shapes/textShape';
import { translateUiBlendMode } from '@ui/translators';
export const createPenpotText = (file: PenpotFile, { type, blendMode, ...rest }: TextShape) => {
file.createText({
blendMode: translateUiBlendMode(blendMode),
...rest
});
};

View file

@ -1,10 +0,0 @@
export * from './createPenpotArtboard';
export * from './createPenpotBool';
export * from './createPenpotCircle';
export * from './createPenpotFile';
export * from './createPenpotGroup';
export * from './createPenpotItem';
export * from './createPenpotPage';
export * from './createPenpotPath';
export * from './createPenpotRectangle';
export * from './createPenpotText';

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,7 @@
import { PenpotPageOptions } from '@ui/lib/types/penpotPage';
import { BoolShape } from '@ui/lib/types/shapes/boolShape';
import { CircleShape } from '@ui/lib/types/shapes/circleShape';
import { ComponentShape } from '@ui/lib/types/shapes/componentShape';
import { FrameShape } from '@ui/lib/types/shapes/frameShape';
import { GroupShape } from '@ui/lib/types/shapes/groupShape';
import { PathShape } from '@ui/lib/types/shapes/pathShape';
@ -26,12 +27,15 @@ export interface PenpotFile {
// deleteLibraryColor(color: any): void;
// addLibraryTypography(typography: any): void;
// deleteLibraryTypography(typography: any): void;
// startComponent(component: any): void;
// finishComponent(): void;
startComponent(component: ComponentShape): Uuid;
finishComponent(): void;
// createComponentInstance(instance: any): void;
// lookupShape(shapeId: string): void;
// lookupShape(shapeId: string): PenpotNode;
// updateObject(id: string, object: any): void;
// deleteObject(id: string): void;
getId(): Uuid;
getCurrentPageId(): Uuid;
newId(): Uuid;
// asMap(): unknown;
export(): void;
}

View file

@ -1,5 +1,6 @@
import { BoolShape } from '@ui/lib/types/shapes/boolShape';
import { CircleShape } from '@ui/lib/types/shapes/circleShape';
import { ComponentShape } from '@ui/lib/types/shapes/componentShape';
import { FrameShape } from '@ui/lib/types/shapes/frameShape';
import { GroupShape } from '@ui/lib/types/shapes/groupShape';
import { PathShape } from '@ui/lib/types/shapes/pathShape';
@ -13,4 +14,5 @@ export type PenpotNode =
| RectShape
| CircleShape
| TextShape
| BoolShape;
| BoolShape
| ComponentShape;

View file

@ -1,13 +1,11 @@
import { Children } from '@ui/lib/types/utils/children';
import { SavedGrids } from '@ui/lib/types/utils/grid';
import { Uuid } from '@ui/lib/types/utils/uuid';
import { PenpotNode } from './penpotNode';
export type PenpotPage = {
name: string;
children?: PenpotNode[];
options?: PenpotPageOptions;
};
} & Children;
export type PenpotPageOptions = {
background?: string; // hex color

View file

@ -0,0 +1,21 @@
import {
ShapeAttributes,
ShapeBaseAttributes,
ShapeGeomAttributes
} from '@ui/lib/types/shapes/shape';
import { Children } from '@ui/lib/types/utils/children';
import { Uuid } from '@ui/lib/types/utils/uuid';
export type ComponentShape = ShapeBaseAttributes &
ShapeAttributes &
ShapeGeomAttributes &
ComponentAttributes &
Children;
export type ComponentAttributes = {
type?: 'component';
name: string;
path: '';
mainInstanceId?: Uuid;
mainInstancePage?: Uuid;
};

View file

@ -14,7 +14,17 @@ import { Uuid } from '@ui/lib/types/utils/uuid';
export type ShapeBaseAttributes = {
id?: Uuid;
name?: string;
type?: 'frame' | 'group' | 'bool' | 'rect' | 'path' | 'text' | 'circle' | 'svg-raw' | 'image';
type?:
| 'frame'
| 'group'
| 'bool'
| 'rect'
| 'path'
| 'text'
| 'circle'
| 'svg-raw'
| 'image'
| 'component';
selrect?: Selrect;
points?: Point[];
transform?: Matrix;

View file

@ -0,0 +1,20 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { FrameShape } from '@ui/lib/types/shapes/frameShape';
import { symbolBlendMode, symbolFillGradients } from '@ui/parser/creators/symbols';
import { createItems } from '.';
export const createArtboard = (
file: PenpotFile,
{ type, fills, blendMode, children = [], ...rest }: FrameShape
) => {
file.addArtboard({
fills: symbolFillGradients(fills),
blendMode: symbolBlendMode(blendMode),
...rest
});
createItems(file, children);
file.closeArtboard();
};

View file

@ -0,0 +1,21 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { BoolShape } from '@ui/lib/types/shapes/boolShape';
import { symbolBlendMode, symbolBoolType, symbolFillGradients } from '@ui/parser/creators/symbols';
import { createItems } from '.';
export const createBool = (
file: PenpotFile,
{ type, fills, boolType, blendMode, children = [], ...rest }: BoolShape
) => {
file.addBool({
fills: symbolFillGradients(fills),
blendMode: symbolBlendMode(blendMode),
boolType: symbolBoolType(boolType),
...rest
});
createItems(file, children);
file.closeBool();
};

View file

@ -1,15 +1,14 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { CircleShape } from '@ui/lib/types/shapes/circleShape';
import { symbolBlendMode, symbolFillGradients } from '@ui/parser/creators/symbols';
import { translateFillGradients, translateUiBlendMode } from '../translators';
export const createPenpotCircle = (
export const createCircle = (
file: PenpotFile,
{ type, fills, blendMode, ...rest }: CircleShape
) => {
file.createCircle({
fills: translateFillGradients(fills),
blendMode: translateUiBlendMode(blendMode),
fills: symbolFillGradients(fills),
blendMode: symbolBlendMode(blendMode),
...rest
});
};

View file

@ -0,0 +1,38 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { ComponentShape } from '@ui/lib/types/shapes/componentShape';
import { components } from '@ui/parser/libraries';
import { createArtboard } from '.';
export const createComponent = (
file: PenpotFile,
{ type, path, children = [], ...rest }: ComponentShape
) => {
const frameId = file.newId();
const componentId = file.newId();
const commonStructure = {
...rest,
children,
componentFile: file.getId(),
componentId: componentId,
componentRoot: true,
mainInstance: true
};
createArtboard(file, {
...commonStructure,
id: frameId,
mainInstance: true,
type: 'frame'
});
components.add({
...commonStructure,
id: componentId,
mainInstanceId: frameId,
mainInstancePage: file.getCurrentPageId(),
path,
type
});
};

View file

@ -0,0 +1,15 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { ComponentShape } from '@ui/lib/types/shapes/componentShape';
import { components } from '@ui/parser/libraries';
import { createItems } from '.';
export const createComponentLibrary = (file: PenpotFile) => {
components.get().forEach(({ children = [], ...rest }: ComponentShape) => {
file.startComponent(rest);
createItems(file, children);
file.finishComponent();
});
};

View file

@ -1,21 +1,19 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { GroupShape } from '@ui/lib/types/shapes/groupShape';
import { translateUiBlendMode } from '@ui/translators';
import { symbolBlendMode } from '@ui/parser/creators/symbols';
import { createPenpotItem } from '.';
import { createItems } from '.';
export const createPenpotGroup = (
export const createGroup = (
file: PenpotFile,
{ type, blendMode, children = [], ...rest }: GroupShape
) => {
file.addGroup({
blendMode: translateUiBlendMode(blendMode),
blendMode: symbolBlendMode(blendMode),
...rest
});
for (const child of children) {
createPenpotItem(file, child);
}
createItems(file, children);
file.closeGroup();
};

View file

@ -0,0 +1,40 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { PenpotNode } from '@ui/lib/types/penpotNode';
import {
createArtboard,
createBool,
createCircle,
createComponent,
createGroup,
createPath,
createRectangle,
createText
} from '.';
export const createItems = (file: PenpotFile, nodes: PenpotNode[]) => {
for (const node of nodes) {
createItem(file, node);
}
};
const createItem = (file: PenpotFile, node: PenpotNode) => {
switch (node.type) {
case 'rect':
return createRectangle(file, node);
case 'circle':
return createCircle(file, node);
case 'frame':
return createArtboard(file, node);
case 'group':
return createGroup(file, node);
case 'path':
return createPath(file, node);
case 'text':
return createText(file, node);
case 'bool':
return createBool(file, node);
case 'component':
return createComponent(file, node);
}
};

View file

@ -0,0 +1,12 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { PenpotPage } from '@ui/lib/types/penpotPage';
import { createItems } from '.';
export const createPage = (file: PenpotFile, { name, options, children = [] }: PenpotPage) => {
file.addPage(name, options);
createItems(file, children);
file.closePage();
};

View file

@ -0,0 +1,19 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { PathShape } from '@ui/lib/types/shapes/pathShape';
import {
symbolBlendMode,
symbolFillGradients,
symbolPathContent
} from '@ui/parser/creators/symbols';
export const createPath = (
file: PenpotFile,
{ type, fills, blendMode, content, ...rest }: PathShape
) => {
file.createPath({
fills: symbolFillGradients(fills),
blendMode: symbolBlendMode(blendMode),
content: symbolPathContent(content),
...rest
});
};

View file

@ -1,14 +1,14 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { RectShape } from '@ui/lib/types/shapes/rectShape';
import { translateFillGradients, translateUiBlendMode } from '@ui/translators';
import { symbolBlendMode, symbolFillGradients } from '@ui/parser/creators/symbols';
export const createPenpotRectangle = (
export const createRectangle = (
file: PenpotFile,
{ type, fills, blendMode, ...rest }: RectShape
) => {
file.createRect({
fills: translateFillGradients(fills),
blendMode: translateUiBlendMode(blendMode),
fills: symbolFillGradients(fills),
blendMode: symbolBlendMode(blendMode),
...rest
});
};

View file

@ -0,0 +1,10 @@
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { TextShape } from '@ui/lib/types/shapes/textShape';
import { symbolBlendMode } from '@ui/parser/creators/symbols';
export const createText = (file: PenpotFile, { type, blendMode, ...rest }: TextShape) => {
file.createText({
blendMode: symbolBlendMode(blendMode),
...rest
});
};

View file

@ -0,0 +1,11 @@
export * from './createComponentLibrary';
export * from './createArtboard';
export * from './createBool';
export * from './createCircle';
export * from './createComponent';
export * from './createGroup';
export * from './createItems';
export * from './createPage';
export * from './createPath';
export * from './createRectangle';
export * from './createText';

View file

@ -0,0 +1,4 @@
export * from './symbolBlendMode';
export * from './symbolBoolType';
export * from './symbolFillGradients';
export * from './symbolPathContent';

View file

@ -18,7 +18,7 @@ import {
BlendMode
} from '@ui/lib/types/utils/blendModes';
export const translateUiBlendMode = (blendMode?: BlendMode): BlendMode | undefined => {
export const symbolBlendMode = (blendMode?: BlendMode): BlendMode | undefined => {
if (!blendMode) return;
switch (blendMode) {

View file

@ -6,7 +6,7 @@ import {
BoolOperations
} from '@ui/lib/types/shapes/boolShape';
export const translateUiBoolType = (booleanOperation: BoolOperations): BoolOperations => {
export const symbolBoolType = (booleanOperation: BoolOperations): BoolOperations => {
switch (booleanOperation) {
case 'union':
return BOOL_UNION;

View file

@ -1,19 +1,19 @@
import { Fill } from '@ui/lib/types/utils/fill';
import { Gradient, LINEAR_TYPE, RADIAL_TYPE } from '@ui/lib/types/utils/gradient';
export const translateFillGradients = (fills?: Fill[]): Fill[] | undefined => {
export const symbolFillGradients = (fills?: Fill[]): Fill[] | undefined => {
if (!fills) return;
return fills.map(fill => {
if (fill.fillColorGradient) {
fill.fillColorGradient = translateFillGradient(fill.fillColorGradient);
fill.fillColorGradient = symbolFillGradient(fill.fillColorGradient);
}
return fill;
});
};
const translateFillGradient = ({ type, ...rest }: Gradient): Gradient | undefined => {
const symbolFillGradient = ({ type, ...rest }: Gradient): Gradient | undefined => {
switch (type) {
case 'linear':
return {

View file

@ -8,10 +8,10 @@ import {
VECTOR_MOVE_TO
} from '@ui/lib/types/shapes/pathShape';
export const translatePathContent = (content: PathContent): PathContent =>
export const symbolPathContent = (content: PathContent): PathContent =>
content
.map(({ command: stringCommand, ...rest }) => {
const command = translatePathCommand(stringCommand);
const command = symbolPathCommand(stringCommand);
if (!command) return;
@ -22,7 +22,7 @@ export const translatePathContent = (content: PathContent): PathContent =>
})
.filter((command): command is Segment => !!command);
const translatePathCommand = (command: Command): Command | undefined => {
const symbolPathCommand = (command: Command): Command | undefined => {
switch (command) {
case 'line-to':
return VECTOR_LINE_TO;

1
ui-src/parser/index.ts Normal file
View file

@ -0,0 +1 @@
export * from './parse';

View file

@ -0,0 +1,19 @@
import { ComponentShape } from '@ui/lib/types/shapes/componentShape';
class Components {
private components: ComponentShape[] = [];
public add(component: ComponentShape) {
this.components.push(component);
}
public get() {
return this.components;
}
public clear() {
this.components = [];
}
}
export const components = new Components();

View file

@ -0,0 +1 @@
export * from './Components';

18
ui-src/parser/parse.ts Normal file
View file

@ -0,0 +1,18 @@
import { createFile } from '@ui/lib/penpot';
import { PenpotDocument } from '@ui/lib/types/penpotDocument';
import { createComponentLibrary, createPage } from '@ui/parser/creators';
import { components } from '@ui/parser/libraries';
export const parse = ({ name, children = [] }: PenpotDocument) => {
components.clear();
const file = createFile(name);
for (const page of children) {
createPage(file, page);
}
createComponentLibrary(file);
return file;
};

View file

@ -1,4 +0,0 @@
export * from './translateFillGradients';
export * from './translatePathContent';
export * from './translateUiBlendMode';
export * from './translateUiBoolType';