From 811f55ec31fc6f29561329d1b2d729697427cc1f Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 29 Apr 2024 12:23:54 +0200 Subject: [PATCH] refactor: remove old state plugin --- apps/poc-state-read-plugin/.babelrc | 3 - apps/poc-state-read-plugin/.eslintrc.json | 22 --- apps/poc-state-read-plugin/.swcrc | 8 - apps/poc-state-read-plugin/index.html | 16 -- apps/poc-state-read-plugin/project.json | 8 - apps/poc-state-read-plugin/public/favicon.ico | Bin 15086 -> 0 bytes .../public/manifest.json | 9 -- .../src/app/app.element.css | 87 ----------- .../src/app/app.element.ts | 141 ------------------ .../poc-state-read-plugin/src/assets/.gitkeep | 0 apps/poc-state-read-plugin/src/main.ts | 1 - apps/poc-state-read-plugin/src/plugin.ts | 106 ------------- apps/poc-state-read-plugin/src/styles.css | 1 - apps/poc-state-read-plugin/tsconfig.app.json | 9 -- apps/poc-state-read-plugin/tsconfig.json | 30 ---- apps/poc-state-read-plugin/tsconfig.spec.json | 26 ---- apps/poc-state-read-plugin/vite.config.ts | 59 -------- package.json | 1 - 18 files changed, 527 deletions(-) delete mode 100644 apps/poc-state-read-plugin/.babelrc delete mode 100644 apps/poc-state-read-plugin/.eslintrc.json delete mode 100644 apps/poc-state-read-plugin/.swcrc delete mode 100644 apps/poc-state-read-plugin/index.html delete mode 100644 apps/poc-state-read-plugin/project.json delete mode 100644 apps/poc-state-read-plugin/public/favicon.ico delete mode 100644 apps/poc-state-read-plugin/public/manifest.json delete mode 100644 apps/poc-state-read-plugin/src/app/app.element.css delete mode 100644 apps/poc-state-read-plugin/src/app/app.element.ts delete mode 100644 apps/poc-state-read-plugin/src/assets/.gitkeep delete mode 100644 apps/poc-state-read-plugin/src/main.ts delete mode 100644 apps/poc-state-read-plugin/src/plugin.ts delete mode 100644 apps/poc-state-read-plugin/src/styles.css delete mode 100644 apps/poc-state-read-plugin/tsconfig.app.json delete mode 100644 apps/poc-state-read-plugin/tsconfig.json delete mode 100644 apps/poc-state-read-plugin/tsconfig.spec.json delete mode 100644 apps/poc-state-read-plugin/vite.config.ts diff --git a/apps/poc-state-read-plugin/.babelrc b/apps/poc-state-read-plugin/.babelrc deleted file mode 100644 index f2f3806..0000000 --- a/apps/poc-state-read-plugin/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["@nx/js/babel"] -} diff --git a/apps/poc-state-read-plugin/.eslintrc.json b/apps/poc-state-read-plugin/.eslintrc.json deleted file mode 100644 index fdea108..0000000 --- a/apps/poc-state-read-plugin/.eslintrc.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*", "vite.config.ts"], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "./apps/poc-state-read-plugin/tsconfig.app.json" - }, - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/apps/poc-state-read-plugin/.swcrc b/apps/poc-state-read-plugin/.swcrc deleted file mode 100644 index a2d5b04..0000000 --- a/apps/poc-state-read-plugin/.swcrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "jsc": { - "parser": { - "syntax": "typescript" - }, - "target": "es2016" - } -} diff --git a/apps/poc-state-read-plugin/index.html b/apps/poc-state-read-plugin/index.html deleted file mode 100644 index d01f0f3..0000000 --- a/apps/poc-state-read-plugin/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - State Read Plugin - - - - - - - - - - - diff --git a/apps/poc-state-read-plugin/project.json b/apps/poc-state-read-plugin/project.json deleted file mode 100644 index 522220c..0000000 --- a/apps/poc-state-read-plugin/project.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "poc-state-read-plugin", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "projectType": "application", - "sourceRoot": "apps/poc-state-read-plugin/src", - "tags": ["type:plugin"], - "targets": {} -} diff --git a/apps/poc-state-read-plugin/public/favicon.ico b/apps/poc-state-read-plugin/public/favicon.ico deleted file mode 100644 index 317ebcb2336e0833a22dddf0ab287849f26fda57..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15086 zcmeI332;U^%p|z7g|#(P)qFEA@4f!_@qOK2 z_lJl}!lhL!VT_U|uN7%8B2iKH??xhDa;*`g{yjTFWHvXn;2s{4R7kH|pKGdy(7z!K zgftM+Ku7~24TLlh(!g)gz|foI94G^t2^IO$uvX$3(OR0<_5L2sB)lMAMy|+`xodJ{ z_Uh_1m)~h?a;2W{dmhM;u!YGo=)OdmId_B<%^V^{ovI@y`7^g1_V9G}*f# zNzAtvou}I!W1#{M^@ROc(BZ! z+F!!_aR&Px3_reO(EW+TwlW~tv*2zr?iP7(d~a~yA|@*a89IUke+c472NXM0wiX{- zl`UrZC^1XYyf%1u)-Y)jj9;MZ!SLfd2Hl?o|80Su%Z?To_=^g_Jt0oa#CT*tjx>BI z16wec&AOWNK<#i0Qd=1O$fymLRoUR*%;h@*@v7}wApDl^w*h}!sYq%kw+DKDY)@&A z@9$ULEB3qkR#85`lb8#WZw=@})#kQig9oqy^I$dj&k4jU&^2(M3q{n1AKeGUKPFbr z1^<)aH;VsG@J|B&l>UtU#Ejv3GIqERzYgL@UOAWtW<{p#zy`WyJgpCy8$c_e%wYJL zyGHRRx38)HyjU3y{-4z6)pzb>&Q1pR)B&u01F-|&Gx4EZWK$nkUkOI|(D4UHOXg_- zw{OBf!oWQUn)Pe(=f=nt=zkmdjpO^o8ZZ9o_|4tW1ni+Un9iCW47*-ut$KQOww!;u z`0q)$s6IZO!~9$e_P9X!hqLxu`fpcL|2f^I5d4*a@Dq28;@2271v_N+5HqYZ>x;&O z05*7JT)mUe&%S0@UD)@&8SmQrMtsDfZT;fkdA!r(S=}Oz>iP)w=W508=Rc#nNn7ym z1;42c|8($ALY8#a({%1#IXbWn9-Y|0eDY$_L&j{63?{?AH{);EzcqfydD$@-B`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{7zOMUF z^?%F%)c1Y)Q?Iy?I>knw*8gYW#ok|2gdS=YYZLiD=CW|Nj;n^x!=S#iJ#`~Ld79+xXpVmUK^B(xO_vO!btA9y7w3L3-0j-y4 z?M-V{%z;JI`bk7yFDcP}OcCd*{Q9S5$iGA7*E1@tfkyjAi!;wP^O71cZ^Ep)qrQ)N z#wqw0_HS;T7x3y|`P==i3hEwK%|>fZ)c&@kgKO1~5<5xBSk?iZV?KI6&i72H6S9A* z=U(*e)EqEs?Oc04)V-~K5AUmh|62H4*`UAtItO$O(q5?6jj+K^oD!04r=6#dsxp?~}{`?&sXn#q2 zGuY~7>O2=!u@@Kfu7q=W*4egu@qPMRM>(eyYyaIE<|j%d=iWNdGsx%c!902v#ngNg z@#U-O_4xN$s_9?(`{>{>7~-6FgWpBpqXb`Ydc3OFL#&I}Irse9F_8R@4zSS*Y*o*B zXL?6*Aw!AfkNCgcr#*yj&p3ZDe2y>v$>FUdKIy_2N~}6AbHc7gA3`6$g@1o|dE>vz z4pl(j9;kyMsjaw}lO?(?Xg%4k!5%^t#@5n=WVc&JRa+XT$~#@rldvN3S1rEpU$;XgxVny7mki3 z-Hh|jUCHrUXuLr!)`w>wgO0N%KTB-1di>cj(x3Bav`7v z3G7EIbU$z>`Nad7Rk_&OT-W{;qg)-GXV-aJT#(ozdmnA~Rq3GQ_3mby(>q6Ocb-RgTUhTN)))x>m&eD;$J5Bg zo&DhY36Yg=J=$Z>t}RJ>o|@hAcwWzN#r(WJ52^g$lh^!63@hh+dR$&_dEGu&^CR*< z!oFqSqO@>xZ*nC2oiOd0eS*F^IL~W-rsrO`J`ej{=ou_q^_(<$&-3f^J z&L^MSYWIe{&pYq&9eGaArA~*kA 0) { - this.#nameInput.value = this.#selection[0].name; - } else { - this.#nameInput.value = ""; - } - } - - connectedCallback() { - this.innerHTML = ` -
-

Test area!

- -

Current project name: Unknown

- -
- - - -
- -
- - - - - - -
- -

- -

-
- `; - - this.#nameSubmit = document.getElementById('name-submit'); - this.#nameInput = document.getElementById('name-input'); - - this.#createRectBtn = document.getElementById('create-rect'); - this.#moveXBtn = document.getElementById('move-x'); - this.#moveYBtn = document.getElementById('move-y'); - this.#resizeWBtn = document.getElementById('resize-w'); - this.#resizeHBtn = document.getElementById('resize-h'); - this.#loremIpsumBtn = document.getElementById('lorem-ipsum'); - console.log(this.#loremIpsumBtn); - - window.addEventListener('message', (event) => { - if (event.data.type === 'file') { - this.#fileId = event.data.content.id; - this.#revn = event.data.content.revn; - } else if (event.data.type === 'page') { - this.refreshPage(event.data.content.page.id, event.data.content.page.name); - } else if (event.data.type === 'selection') { - this.refreshSelection(event.data.content.selection); - } else if (event.data.type === 'init') { - this.#fileId = event.data.content.fileId; - this.#revn = event.data.content.revn; - this.refreshPage(event.data.content.pageId, event.data.content.name); - this.refreshSelection(event.data.content.selection); - this.setAttribute('data-theme', event.data.content.theme); - } else if (event.data.type === 'theme') { - this.setAttribute('data-theme', event.data.content); - } - }); - - const closeAction = this.querySelector('.act-close-plugin'); - closeAction?.addEventListener('click', () => { - parent.postMessage({ content: 'close' }, '*'); - }); - - parent.postMessage({ content: 'ready' }, '*'); - - this.#nameSubmit?.addEventListener('click', (e) => { - const id = this.#selection[0].id; - const name = this.#nameInput.value; - parent.postMessage({ content: 'change-name', data: { id, name } }, '*'); - }); - - this.#createRectBtn?.addEventListener('click', (e) => { - parent.postMessage({ content: 'create-rect' }, '*'); - }); - - this.#moveXBtn?.addEventListener('click', (e) => { - const id = this.#selection[0].id; - parent.postMessage({ content: 'move-x', data: { id } }, '*'); - }); - - this.#moveYBtn?.addEventListener('click', (e) => { - const id = this.#selection[0].id; - parent.postMessage({ content: 'move-y', data: { id } }, '*'); - }); - - this.#resizeWBtn?.addEventListener('click', (e) => { - const id = this.#selection[0].id; - parent.postMessage({ content: 'resize-w', data: { id } }, '*'); - }); - - this.#resizeHBtn?.addEventListener('click', (e) => { - const id = this.#selection[0].id; - parent.postMessage({ content: 'resize-h', data: { id } }, '*'); - }); - - this.#loremIpsumBtn?.addEventListener('click', (e) => { - console.log(">>"); - parent.postMessage({ content: 'lorem-ipsum' }, '*'); - }); - - } -} -customElements.define('app-root', AppElement); diff --git a/apps/poc-state-read-plugin/src/assets/.gitkeep b/apps/poc-state-read-plugin/src/assets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/apps/poc-state-read-plugin/src/main.ts b/apps/poc-state-read-plugin/src/main.ts deleted file mode 100644 index fdb879d..0000000 --- a/apps/poc-state-read-plugin/src/main.ts +++ /dev/null @@ -1 +0,0 @@ -import './app/app.element'; diff --git a/apps/poc-state-read-plugin/src/plugin.ts b/apps/poc-state-read-plugin/src/plugin.ts deleted file mode 100644 index 185c522..0000000 --- a/apps/poc-state-read-plugin/src/plugin.ts +++ /dev/null @@ -1,106 +0,0 @@ -penpot.ui.open('Plugin name', 'http://localhost:4202', { - width: 500, - height: 600, -}); - -penpot.ui.onMessage<{ content: string; data: unknown }>((message) => { - if (message.content === 'close') { - penpot.closePlugin(); - } else if (message.content === 'ready') { - const page = penpot.getPage(); - const file = penpot.getFile(); - - if (!page || !file) { - return; - } - - penpot.ui.sendMessage({ - type: 'init', - content: { - name: page.name, - pageId: page.id, - fileId: file.id, - revn: file.revn, - theme: penpot.getTheme(), - selection: penpot.getSelectedShapes(), - }, - }); - } else if (message.content === 'change-name') { - const shape = penpot - .getPage() - ?.getShapeById('' + (message.data as { id: string }).id); - if (shape) { - shape.name = (message.data as { name: string }).name; - } - } else if (message.content === 'create-rect') { - const shape = penpot.createRectangle(); - penpot.log(shape); - } else if (message.content === 'move-x') { - const shape = penpot - .getPage() - ?.getShapeById('' + (message.data as { id: string }).id); - if (shape) { - shape.x += 100; - } - } else if (message.content === 'move-y') { - const shape = penpot - .getPage() - ?.getShapeById('' + (message.data as { id: string }).id); - if (shape) { - shape.y += 100; - } - } else if (message.content === 'resize-w') { - const shape = penpot - .getPage() - ?.getShapeById('' + (message.data as { id: string }).id); - if (shape) { - shape.resize(shape.width * 2, shape.height); - } - } else if (message.content === 'resize-h') { - const shape = penpot - .getPage() - ?.getShapeById('' + (message.data as { id: string }).id); - if (shape) { - shape.resize(shape.width, shape.height * 2); - } - } else if (message.content === 'lorem-ipsum') { - const selection = penpot.selection; - - for (const shape of selection) { - if (penpot.utils.types.isText(shape)) { - shape.characters = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam id mauris ut felis finibus congue. Ut odio ipsum, condimentum id tellus sit amet, dapibus sagittis ligula. Pellentesque hendrerit, nulla sit amet aliquet scelerisque, orci nunc commodo tellus, quis hendrerit nisl massa non tellus. - -Phasellus fringilla tortor elit, ac dictum tellus posuere sodales. Ut eget imperdiet ante. Nunc eros magna, tincidunt non finibus in, tempor elementum nunc. Sed commodo magna in arcu aliquam efficitur.`; - } - } - } -}); - -penpot.on('pagechange', () => { - const page = penpot.getPage(); - const shapes = page?.findShapes(); - - penpot.ui.sendMessage({ - type: 'page', - content: { page, shapes }, - }); -}); - -penpot.on('filechange', () => { - const file = penpot.getFile(); - penpot.ui.sendMessage({ - type: 'file', - content: { - id: file.id, - }, - }); -}); - -penpot.on('selectionchange', () => { - const selection = penpot.getSelectedShapes(); - penpot.ui.sendMessage({ type: 'selection', content: { selection } }); -}); - -penpot.on('themechange', (theme) => { - penpot.ui.sendMessage({ type: 'theme', content: theme }); -}); diff --git a/apps/poc-state-read-plugin/src/styles.css b/apps/poc-state-read-plugin/src/styles.css deleted file mode 100644 index 90d4ee0..0000000 --- a/apps/poc-state-read-plugin/src/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ diff --git a/apps/poc-state-read-plugin/tsconfig.app.json b/apps/poc-state-read-plugin/tsconfig.app.json deleted file mode 100644 index 559b7d6..0000000 --- a/apps/poc-state-read-plugin/tsconfig.app.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "types": ["node"] - }, - "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"], - "include": ["src/**/*.ts", "../../libs/plugin-types/index.d.ts"] -} diff --git a/apps/poc-state-read-plugin/tsconfig.json b/apps/poc-state-read-plugin/tsconfig.json deleted file mode 100644 index cee4bba..0000000 --- a/apps/poc-state-read-plugin/tsconfig.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "files": [], - "compilerOptions": { - "target": "ESNext", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ESNext", "DOM"], - "moduleResolution": "Node", - "strict": true, - "resolveJsonModule": true, - "isolatedModules": true, - "esModuleInterop": true, - "noEmit": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "skipLibCheck": true, - "types": ["vite/client"] - }, - "include": ["src"], - "references": [ - { - "path": "./tsconfig.app.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/apps/poc-state-read-plugin/tsconfig.spec.json b/apps/poc-state-read-plugin/tsconfig.spec.json deleted file mode 100644 index 3c002c2..0000000 --- a/apps/poc-state-read-plugin/tsconfig.spec.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "types": [ - "vitest/globals", - "vitest/importMeta", - "vite/client", - "node", - "vitest" - ] - }, - "include": [ - "vite.config.ts", - "vitest.config.ts", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx", - "src/**/*.d.ts" - ] -} diff --git a/apps/poc-state-read-plugin/vite.config.ts b/apps/poc-state-read-plugin/vite.config.ts deleted file mode 100644 index 5cad5be..0000000 --- a/apps/poc-state-read-plugin/vite.config.ts +++ /dev/null @@ -1,59 +0,0 @@ -/// -import { defineConfig } from 'vite'; - -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; - -export default defineConfig({ - root: __dirname, - cacheDir: '../../node_modules/.vite/apps/example-plugin', - - server: { - port: 4200, - host: 'localhost', - }, - - preview: { - port: 4202, - host: 'localhost', - }, - - plugins: [nxViteTsPaths()], - - // Uncomment this if you are using workers. - // worker: { - // plugins: [ nxViteTsPaths() ], - // }, - - build: { - outDir: '../../dist/apps/poc-state-read-plugin', - reportCompressedSize: true, - commonjsOptions: { - transformMixedEsModules: true, - }, - rollupOptions: { - input: { - plugin: 'src/plugin.ts', - index: './index.html', - }, - output: { - entryFileNames: '[name].js', - }, - }, - sourcemap: true, - }, - - test: { - globals: true, - cache: { - dir: '../../node_modules/.vitest', - }, - environment: 'jsdom', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - - reporters: ['default'], - coverage: { - reportsDirectory: '../../coverage/apps/poc-state-read-plugin', - provider: 'v8', - }, - }, -}); diff --git a/package.json b/package.json index af348aa..b0c301e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "scripts": { "start": "npx nx run plugins-runtime:build --watch --mode development & npx nx run plugins-runtime:preview", "start:example": "npx nx run example-plugin:build --watch & npx nx run example-plugin:preview", - "start:read-plugin": "npx nx run poc-state-read-plugin:build --watch & npx nx run poc-state-read-plugin:preview", "start:pc-plugin": "npx nx run-many --targets=buildPlugin,serve --projects=poc-state-plugin --watch", "start:contrast-plugin": "npx nx run contrast-plugin:build --watch & npx nx run contrast-plugin:preview", "start:rpc-api": "npx nx serve rpc-api",