From 394bbee7092a53da1f68514f82ad79622962342d Mon Sep 17 00:00:00 2001 From: softmarshmallow Date: Fri, 7 Jul 2023 21:29:32 +0900 Subject: [PATCH 1/3] init --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5dbdf86b..7e155916 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ title: Grida Assistant for Figma ![Grida assistant](./branding/assistant-cover-v2021.8.0.png) - # Grdia Assistant plugin (figma to flutter & react) > Any design to high quality code, with live preview. @@ -25,6 +24,10 @@ title: Grida Assistant for Figma - ✅ Live preview via [console](https://console.grida.co) - compiles output source remotely makes design to living application within seconds - ✅ Context detection - Grida assistant understands the design, than converts it into a hight quality code. we don't generate rect and text code for a button. We generate button code for a button. +## Devmode + +WIP + ## Usage > Install figma plugin via below link. Note that the published plugin is always behind few new features behind this repository. For trying out the latest and mindblowing features, please build from your local environment directly. From f1b4060dcccc7dc059df31a03a46ef2e383bd127 Mon Sep 17 00:00:00 2001 From: softmarshmallow Date: Sun, 9 Jul 2023 20:05:33 +0900 Subject: [PATCH 2/3] Moved submodule to new location --- .gitmodules | 6 +++--- package.json | 6 +++--- packages/design-to-code | 1 - yarn.lock | 8 ++++---- 4 files changed, 10 insertions(+), 11 deletions(-) delete mode 160000 packages/design-to-code diff --git a/.gitmodules b/.gitmodules index 20e46780..2c4e8a24 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,6 @@ [submodule "packages/reflect-ui-generator"] path = packages/reflect-ui-generator url = https://github.com/reflect-ui/reflect-ui-generator -[submodule "packages/design-to-code"] - path = packages/design-to-code - url = https://github.com/gridaco/designto-code +[submodule "lib/code"] + path = lib/code + url = https://github.com/gridaco/code diff --git a/package.json b/package.json index 99cc6a47..af21288b 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "packages/*", "packages/base-sdk/*", "packages/base-sdk/_firstparty/*", - "packages/design-to-code/packages/*", - "packages/design-to-code/editor-packages/*" + "lib/code/packages/*", + "lib/code/editor-packages/*" ] }, "repository": "https://github.com/gridaco/assistant", @@ -51,7 +51,7 @@ "react-dom": "^18.2.0", "@types/react": "18.0.24", "@types/react-dom": "^18.0.8", - "@figma/plugin-typings": "^1.58.0", + "@figma/plugin-typings": "^1.70.0", "ts-loader": "8.4.0", "typescript": "4.9.5", "coli": "0.0.32", diff --git a/packages/design-to-code b/packages/design-to-code deleted file mode 160000 index ca4ea08c..00000000 --- a/packages/design-to-code +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ca4ea08ceef51b85b15780b61b9aef15a96acace diff --git a/yarn.lock b/yarn.lock index 8eeb3b2f..c3b141be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1783,10 +1783,10 @@ resolved "https://registry.yarnpkg.com/@emotion/weak-memoize/-/weak-memoize-0.3.0.tgz#ea89004119dc42db2e1dba0f97d553f7372f6fcb" integrity sha512-AHPmaAx+RYfZz0eYu6Gviiagpmiyw98ySSlQvCUhVGDRtDFe4DBS0x1bSjdF3gqUDYOczB+yYvBTtEylYSdRhg== -"@figma/plugin-typings@^1.58.0": - version "1.61.0" - resolved "https://registry.yarnpkg.com/@figma/plugin-typings/-/plugin-typings-1.61.0.tgz#34abfea24013bbc9897b182713a8f7fc23c5261f" - integrity sha512-qgnu96PY+eIMnqF2OorwLdSTdLT+HpZXAarOMjNkqEqBylVfSvc0f/qZpbKCTNDBM0blb3kayQoR8BwjM+0xmA== +"@figma/plugin-typings@^1.70.0": + version "1.70.0" + resolved "https://registry.yarnpkg.com/@figma/plugin-typings/-/plugin-typings-1.70.0.tgz#0e11bc4c5d90c4e37b0bbb99fabe60fa46906169" + integrity sha512-dN/ehVt40WDSjuf6+vICw1Btq8yKNvKSo5xl1qk8jfRaOdaN88QOYgODEVUGp9gSzlyUEhUKng0YMKg/doBpEg== "@firebase/analytics-types@0.4.0": version "0.4.0" From a3aac578312b4d9e040efad2d39ab2a182953fb6 Mon Sep 17 00:00:00 2001 From: softmarshmallow Date: Sun, 9 Jul 2023 20:06:20 +0900 Subject: [PATCH 3/3] alt manifest with codegen and inspect support --- figma-core/index.ts | 45 +++++++++++++++++++++++++++--- figma-core/package.json | 2 +- figma/manifest.json | 9 +++--- packages/plugin-app/plugin-app.tsx | 2 +- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/figma-core/index.ts b/figma-core/index.ts index ee77b173..92bb8389 100644 --- a/figma-core/index.ts +++ b/figma-core/index.ts @@ -42,15 +42,52 @@ figma.on("currentpagechange", () => { console.log("currentpagechange"); }); +// codegen +figma.codegen.on("generate", async (event) => { + return [ + { + title: "Hello", + code: "code should appear here", + language: "TYPESCRIPT", + }, + ]; +}); + +figma.codegen.on("preferenceschange", async (event) => { + return; +}); + /// ============================================================ // MAIN INITIALIZATION import { showUI } from "./code-thread/show-ui"; import { provideFigma } from "@design-sdk/figma"; -function main() { - MainImageRepository.instance = new ImageRepositories(); - provideFigma(figma); - showUI(); +async function main() { + // provide figma editor type + await figma.clientStorage.setAsync("figma.editorType", figma.editorType); + + switch (figma.editorType) { + case "figma": { + MainImageRepository.instance = new ImageRepositories(); + provideFigma(figma); + showUI(); + break; + } + case "figjam": { + break; + } + case "dev": { + MainImageRepository.instance = new ImageRepositories(); + provideFigma(figma); + figma.notify("dev mode"); + showUI(); + break; + } + default: { + throw "unsupported editor type" + figma.editorType; + } + } + // disabled on staging ---- // create primary visual store // import { createPrimaryVisualStorePageIfNonExists } from "./physical-visual-store/page-manager/craete-page-if-non-exist"; diff --git a/figma-core/package.json b/figma-core/package.json index c95ab489..19e3512f 100644 --- a/figma-core/package.json +++ b/figma-core/package.json @@ -9,7 +9,7 @@ "@plugin-sdk/service": "*" }, "devDependencies": { - "@figma/plugin-typings": "^1.58.0", + "@figma/plugin-typings": "^1.70.0", "typescript": "^4.0.5" } } diff --git a/figma/manifest.json b/figma/manifest.json index 13a04e7e..a63ee279 100644 --- a/figma/manifest.json +++ b/figma/manifest.json @@ -4,9 +4,10 @@ "api": "1.0.0", "main": "dist/code.js", "ui": "dist/ui.html", - "editorType": [ - "figma" - ], + "editorType": ["figma", "dev"], + "capabilities": ["codegen", "inspect"], + "codegenLanguages": [{ "label": "React", "value": "react" }], + "codegenPreferences": [], "relaunchButtons": [ { "command": "open", @@ -14,4 +15,4 @@ "multipleSelection": true } ] -} \ No newline at end of file +} diff --git a/packages/plugin-app/plugin-app.tsx b/packages/plugin-app/plugin-app.tsx index a76cadbc..e88217a9 100644 --- a/packages/plugin-app/plugin-app.tsx +++ b/packages/plugin-app/plugin-app.tsx @@ -21,7 +21,7 @@ export function PluginApp(props: { const [booting, setBooting] = useState(true); useEffect(() => { console.log("start initializing plugin app..."); - + PluginSdk.getItem("figma.ediorType").then((a) => PluginSdk.notify(a, 10)); PluginSdk.initializeWindow(parent); window.addEventListener("message", (ev: MessageEvent) => { const message: TransportPluginEvent = ev.data.pluginMessage;