Skip to content

Commit e5a0875

Browse files
committed
No more placeholder on plugin
1 parent aee3e57 commit e5a0875

File tree

12 files changed

+1534
-1226
lines changed

12 files changed

+1534
-1226
lines changed

apps/debug/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111
},
1212
"dependencies": {
1313
"backend": "workspace:*",
14-
"next": "^15.2.4",
14+
"next": "^15.3.4",
1515
"plugin-ui": "workspace:*",
16-
"react": "^19.0.0",
17-
"react-dom": "^19.0.0"
16+
"react": "^19.1.0",
17+
"react-dom": "^19.1.0"
1818
},
1919
"devDependencies": {
20-
"@tailwindcss/postcss": "^4.0.17",
21-
"@types/node": "^22.13.14",
22-
"@types/react": "^19.0.12",
23-
"@types/react-dom": "^19.0.4",
20+
"@tailwindcss/postcss": "^4.1.10",
21+
"@types/node": "^22.15.32",
22+
"@types/react": "^19.1.8",
23+
"@types/react-dom": "^19.1.6",
2424
"eslint-config-custom": "workspace:*",
25-
"postcss": "^8.5.3",
25+
"postcss": "^8.5.6",
2626
"tailwindcss": "4.0.14",
2727
"tsconfig": "workspace:*",
2828
"types": "workspace:*",
29-
"typescript": "^5.8.2"
29+
"typescript": "^5.8.3"
3030
}
3131
}

apps/plugin/package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@
1010
"dev": "pnpm build:watch"
1111
},
1212
"dependencies": {
13-
"@figma/plugin-typings": "^1.109.0",
13+
"@figma/plugin-typings": "^1.114.0",
1414
"backend": "workspace:*",
1515
"clsx": "^2.1.1",
1616
"copy-to-clipboard": "^3.3.3",
1717
"lucide-react": "^0.483.0",
18-
"motion": "^12.6.2",
18+
"motion": "^12.18.1",
1919
"nanoid": "^5.1.5",
2020
"plugin-ui": "workspace:*",
21-
"react": "^19.0.0",
22-
"react-dom": "^19.0.0",
23-
"tailwind-merge": "^3.0.2"
21+
"react": "^19.1.0",
22+
"react-dom": "^19.1.0",
23+
"tailwind-merge": "^3.3.1"
2424
},
2525
"devDependencies": {
26-
"@tailwindcss/postcss": "^4.0.17",
27-
"@types/node": "^22.13.14",
28-
"@types/react": "^19.0.12",
29-
"@types/react-dom": "^19.0.4",
30-
"@typescript-eslint/eslint-plugin": "^8.28.0",
31-
"@typescript-eslint/parser": "^8.28.0",
32-
"@vitejs/plugin-react": "^4.3.4",
33-
"@vitejs/plugin-react-swc": "^3.8.1",
26+
"@tailwindcss/postcss": "^4.1.10",
27+
"@types/node": "^22.15.32",
28+
"@types/react": "^19.1.8",
29+
"@types/react-dom": "^19.1.6",
30+
"@typescript-eslint/eslint-plugin": "^8.34.1",
31+
"@typescript-eslint/parser": "^8.34.1",
32+
"@vitejs/plugin-react": "^4.5.2",
33+
"@vitejs/plugin-react-swc": "^3.10.2",
3434
"concurrently": "^9.1.2",
35-
"esbuild": "^0.25.1",
35+
"esbuild": "^0.25.5",
3636
"eslint-config-custom": "workspace:*",
3737
"eslint-plugin-react-hooks": "^5.2.0",
38-
"eslint-plugin-react-refresh": "^0.4.19",
39-
"postcss": "^8.5.3",
38+
"eslint-plugin-react-refresh": "^0.4.20",
39+
"postcss": "^8.5.6",
4040
"tailwindcss": "4.0.14",
4141
"tsconfig": "workspace:*",
4242
"types": "workspace:*",
43-
"typescript": "^5.8.2",
44-
"vite": "^5.4.15",
43+
"typescript": "^5.8.3",
44+
"vite": "^5.4.19",
4545
"vite-plugin-singlefile": "^2.2.0"
4646
}
4747
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"permissions": [],
1010
"documentAccess": "dynamic-page",
1111
"networkAccess": {
12-
"allowedDomains": ["https://placehold.co"]
12+
"allowedDomains": ["none"]
1313
},
1414
"codegenLanguages": [
1515
{ "label": "HTML", "value": "html" },

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"format": "prettier --write \"**/*.{ts,tsx,css,md}\""
1111
},
1212
"devDependencies": {
13-
"eslint": "^9.23.0",
13+
"eslint": "^9.29.0",
1414
"eslint-config-custom": "workspace:*",
1515
"prettier": "^3.5.3",
16-
"turbo": "^2.4.4",
17-
"typescript": "^5.8.2"
16+
"turbo": "^2.5.4",
17+
"typescript": "^5.8.3"
1818
}
1919
}

packages/backend/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
"lint": "eslint \"src/**/*.ts*\""
1414
},
1515
"dependencies": {
16-
"@figma/plugin-typings": "^1.109.0",
16+
"@figma/plugin-typings": "^1.114.0",
1717
"js-base64": "^3.7.7",
1818
"nanoid": "^5.1.5",
1919
"react": "19.0.0",
2020
"react-dom": "19.0.0",
2121
"types": "workspace:*"
2222
},
2323
"devDependencies": {
24-
"@types/react": "^19.0.12",
25-
"@types/react-dom": "^19.0.4",
26-
"eslint": "^9.23.0",
24+
"@types/react": "^19.1.8",
25+
"@types/react-dom": "^19.1.6",
26+
"eslint": "^9.29.0",
2727
"eslint-config-custom": "workspace:*",
2828
"tsconfig": "workspace:*",
29-
"tsup": "^8.4.0",
30-
"typescript": "^5.8.2"
29+
"tsup": "^8.5.0",
30+
"typescript": "^5.8.3"
3131
}
3232
}

packages/backend/src/common/images.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,56 @@ import { exportAsyncProxy } from "./exportAsyncProxy";
55

66
export const PLACEHOLDER_IMAGE_DOMAIN = "https://placehold.co";
77

8-
export const getPlaceholderImage = (w: number, h = -1) => {
8+
const createCanvasImageUrl = (width: number, height: number): string => {
9+
// Check if we're in a browser environment
10+
if (typeof document === 'undefined' || typeof window === 'undefined') {
11+
// Fallback for non-browser environments
12+
return `${PLACEHOLDER_IMAGE_DOMAIN}/${width}x${height}`;
13+
}
14+
15+
const canvas = document.createElement('canvas');
16+
canvas.width = width;
17+
canvas.height = height;
18+
19+
const ctx = canvas.getContext('2d');
20+
if (!ctx) {
21+
// Fallback if canvas context is not available
22+
return `${PLACEHOLDER_IMAGE_DOMAIN}/${width}x${height}`;
23+
}
24+
25+
const fontSize = Math.max(12, Math.floor(width * 0.15));
26+
ctx.font = `bold ${fontSize}px Inter, Arial, Helvetica, sans-serif`;
27+
ctx.fillStyle = '#888888';
28+
29+
const text = `${width} x ${height}`;
30+
const textWidth = ctx.measureText(text).width;
31+
const x = (width - textWidth) / 2;
32+
const y = (height + fontSize) / 2;
33+
34+
ctx.fillText(text, x, y);
35+
36+
const image = canvas.toDataURL();
37+
const base64 = image.substring(22);
38+
const byteCharacters = atob(base64);
39+
const byteNumbers = new Array(byteCharacters.length);
40+
for (let i = 0; i < byteCharacters.length; i++) {
41+
byteNumbers[i] = byteCharacters.charCodeAt(i);
42+
}
43+
const byteArray = new Uint8Array(byteNumbers);
44+
const file = new Blob([byteArray], {
45+
type: 'image/png;base64',
46+
});
47+
return URL.createObjectURL(file);
48+
};
49+
50+
export const getPlaceholderImage = (w: number, h = -1, useCanvas = false) => {
951
const _w = w.toFixed(0);
1052
const _h = (h < 0 ? w : h).toFixed(0);
53+
54+
if (useCanvas) {
55+
return createCanvasImageUrl(parseInt(_w), parseInt(_h));
56+
}
57+
1158
return `${PLACEHOLDER_IMAGE_DOMAIN}/${_w}x${_h}`;
1259
};
1360

packages/backend/src/html/htmlMain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ const htmlContainer = async (
617617
) {
618618
imgUrl = (await exportNodeAsBase64PNG(altNode, hasChildren)) ?? "";
619619
} else {
620-
imgUrl = getPlaceholderImage(node.width, node.height);
620+
imgUrl = getPlaceholderImage(node.width, node.height, isPreviewGlobal);
621621
}
622622

623623
if (hasChildren) {

packages/backend/src/tailwind/tailwindMain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const tailwindWrapSVG = (
9797
.addData("svg-wrapper")
9898
.position();
9999

100-
return `\n<div${builder.build()}>\n${node.svg}</div>`;
100+
return `\n<div${builder.build()}>\n${indentString(node.svg ?? "")}</div>`;
101101
};
102102

103103
const tailwindGroup = async (

packages/eslint-config-custom/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"main": "index.js",
55
"license": "MIT",
66
"dependencies": {
7-
"eslint-config-next": "^15.2.4",
8-
"eslint-config-prettier": "^10.1.1",
9-
"eslint-config-turbo": "^2.4.4",
7+
"eslint-config-next": "^15.3.4",
8+
"eslint-config-prettier": "^10.1.5",
9+
"eslint-config-turbo": "^2.5.4",
1010
"eslint-plugin-react": "7.37.4"
1111
},
1212
"publishConfig": {

packages/plugin-ui/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010
"lint": "eslint \"src/**/*.ts*\""
1111
},
1212
"dependencies": {
13-
"@types/react": "^19.0.12",
14-
"@types/react-dom": "^19.0.4",
13+
"@types/react": "^19.1.8",
14+
"@types/react-dom": "^19.1.6",
1515
"@types/react-syntax-highlighter": "15.5.13",
1616
"clsx": "^2.1.1",
1717
"copy-to-clipboard": "^3.3.3",
1818
"lucide-react": "^0.483.0",
19-
"react": "^19.0.0",
19+
"react": "^19.1.0",
2020
"react-syntax-highlighter": "^15.6.1",
21-
"tailwind-merge": "^3.0.2",
22-
"tailwindcss": "^4.0.17"
21+
"tailwind-merge": "^3.3.1",
22+
"tailwindcss": "^4.1.10"
2323
},
2424
"devDependencies": {
25-
"eslint": "^9.23.0",
25+
"eslint": "^9.29.0",
2626
"eslint-config-custom": "workspace:*",
2727
"tsconfig": "workspace:*",
2828
"types": "workspace:*",
29-
"typescript": "^5.8.2"
29+
"typescript": "^5.8.3"
3030
}
3131
}

0 commit comments

Comments
 (0)