a tool for shared writing and social publishing

shrink down url preview images before posting to bsky

+89 -69
+9 -3
app/[leaflet_id]/publish/publishBskyPost.ts
··· 1 1 "use server"; 2 2 3 3 import { Agent as BskyAgent } from "@atproto/api"; 4 + import sharp from "sharp"; 4 5 import { TID } from "@atproto/common"; 5 6 import { getIdentityData } from "actions/getIdentityData"; 6 7 import { AtpBaseClient, PubLeafletDocument } from "lexicons/api"; ··· 33 34 ); 34 35 35 36 let binary = await preview_image.blob(); 36 - let blob = await agent.com.atproto.repo.uploadBlob(binary, { 37 + let resized_preview_image = await sharp(await binary.arrayBuffer()) 38 + .resize({ 39 + width: 514, 40 + fit: "cover", 41 + }) 42 + .toBuffer(); 43 + 44 + let blob = await agent.com.atproto.repo.uploadBlob(resized_preview_image, { 37 45 headers: { "Content-Type": binary.type }, 38 46 }); 39 47 let bsky = new BskyAgent(credentialSession); ··· 66 74 record, 67 75 validate: false, //TODO publish the lexicon so we can validate! 68 76 }); 69 - console.log("UPDATING_TO_LINK_BSKY_POST"); 70 - console.log(result); 71 77 return true; 72 78 }
+79 -66
package-lock.json
··· 67 67 "remark-rehype": "^11.1.0", 68 68 "remark-stringify": "^11.0.0", 69 69 "replicache": "^14.2.2", 70 + "sharp": "^0.34.2", 70 71 "swr": "^2.3.3", 71 72 "thumbhash": "^0.1.1", 72 73 "twilio": "^5.3.7", ··· 1893 1894 "dev": true 1894 1895 }, 1895 1896 "node_modules/@img/sharp-darwin-arm64": { 1896 - "version": "0.34.1", 1897 - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.1.tgz", 1898 - "integrity": "sha512-pn44xgBtgpEbZsu+lWf2KNb6OAf70X68k+yk69Ic2Xz11zHR/w24/U49XT7AeRwJ0Px+mhALhU5LPci1Aymk7A==", 1897 + "version": "0.34.2", 1898 + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.2.tgz", 1899 + "integrity": "sha512-OfXHZPppddivUJnqyKoi5YVeHRkkNE2zUFT2gbpKxp/JZCFYEYubnMg+gOp6lWfasPrTS+KPosKqdI+ELYVDtg==", 1899 1900 "cpu": [ 1900 1901 "arm64" 1901 1902 ], ··· 1915 1916 } 1916 1917 }, 1917 1918 "node_modules/@img/sharp-darwin-x64": { 1918 - "version": "0.34.1", 1919 - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.1.tgz", 1920 - "integrity": "sha512-VfuYgG2r8BpYiOUN+BfYeFo69nP/MIwAtSJ7/Zpxc5QF3KS22z8Pvg3FkrSFJBPNQ7mmcUcYQFBmEQp7eu1F8Q==", 1919 + "version": "0.34.2", 1920 + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.2.tgz", 1921 + "integrity": "sha512-dYvWqmjU9VxqXmjEtjmvHnGqF8GrVjM2Epj9rJ6BUIXvk8slvNDJbhGFvIoXzkDhrJC2jUxNLz/GUjjvSzfw+g==", 1921 1922 "cpu": [ 1922 1923 "x64" 1923 1924 ], ··· 2081 2082 } 2082 2083 }, 2083 2084 "node_modules/@img/sharp-linux-arm": { 2084 - "version": "0.34.1", 2085 - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.1.tgz", 2086 - "integrity": "sha512-anKiszvACti2sGy9CirTlNyk7BjjZPiML1jt2ZkTdcvpLU1YH6CXwRAZCA2UmRXnhiIftXQ7+Oh62Ji25W72jA==", 2085 + "version": "0.34.2", 2086 + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.2.tgz", 2087 + "integrity": "sha512-0DZzkvuEOqQUP9mo2kjjKNok5AmnOr1jB2XYjkaoNRwpAYMDzRmAqUIa1nRi58S2WswqSfPOWLNOr0FDT3H5RQ==", 2087 2088 "cpu": [ 2088 2089 "arm" 2089 2090 ], ··· 2103 2104 } 2104 2105 }, 2105 2106 "node_modules/@img/sharp-linux-arm64": { 2106 - "version": "0.34.1", 2107 - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.1.tgz", 2108 - "integrity": "sha512-kX2c+vbvaXC6vly1RDf/IWNXxrlxLNpBVWkdpRq5Ka7OOKj6nr66etKy2IENf6FtOgklkg9ZdGpEu9kwdlcwOQ==", 2107 + "version": "0.34.2", 2108 + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.2.tgz", 2109 + "integrity": "sha512-D8n8wgWmPDakc83LORcfJepdOSN6MvWNzzz2ux0MnIbOqdieRZwVYY32zxVx+IFUT8er5KPcyU3XXsn+GzG/0Q==", 2109 2110 "cpu": [ 2110 2111 "arm64" 2111 2112 ], ··· 2125 2126 } 2126 2127 }, 2127 2128 "node_modules/@img/sharp-linux-s390x": { 2128 - "version": "0.34.1", 2129 - "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.1.tgz", 2130 - "integrity": "sha512-7s0KX2tI9mZI2buRipKIw2X1ufdTeaRgwmRabt5bi9chYfhur+/C1OXg3TKg/eag1W+6CCWLVmSauV1owmRPxA==", 2129 + "version": "0.34.2", 2130 + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.2.tgz", 2131 + "integrity": "sha512-EGZ1xwhBI7dNISwxjChqBGELCWMGDvmxZXKjQRuqMrakhO8QoMgqCrdjnAqJq/CScxfRn+Bb7suXBElKQpPDiw==", 2131 2132 "cpu": [ 2132 2133 "s390x" 2133 2134 ], ··· 2147 2148 } 2148 2149 }, 2149 2150 "node_modules/@img/sharp-linux-x64": { 2150 - "version": "0.34.1", 2151 - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.1.tgz", 2152 - "integrity": "sha512-wExv7SH9nmoBW3Wr2gvQopX1k8q2g5V5Iag8Zk6AVENsjwd+3adjwxtp3Dcu2QhOXr8W9NusBU6XcQUohBZ5MA==", 2151 + "version": "0.34.2", 2152 + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.2.tgz", 2153 + "integrity": "sha512-sD7J+h5nFLMMmOXYH4DD9UtSNBD05tWSSdWAcEyzqW8Cn5UxXvsHAxmxSesYUsTOBmUnjtxghKDl15EvfqLFbQ==", 2153 2154 "cpu": [ 2154 2155 "x64" 2155 2156 ], ··· 2169 2170 } 2170 2171 }, 2171 2172 "node_modules/@img/sharp-linuxmusl-arm64": { 2172 - "version": "0.34.1", 2173 - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.1.tgz", 2174 - "integrity": "sha512-DfvyxzHxw4WGdPiTF0SOHnm11Xv4aQexvqhRDAoD00MzHekAj9a/jADXeXYCDFH/DzYruwHbXU7uz+H+nWmSOQ==", 2173 + "version": "0.34.2", 2174 + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.2.tgz", 2175 + "integrity": "sha512-NEE2vQ6wcxYav1/A22OOxoSOGiKnNmDzCYFOZ949xFmrWZOVII1Bp3NqVVpvj+3UeHMFyN5eP/V5hzViQ5CZNA==", 2175 2176 "cpu": [ 2176 2177 "arm64" 2177 2178 ], ··· 2191 2192 } 2192 2193 }, 2193 2194 "node_modules/@img/sharp-linuxmusl-x64": { 2194 - "version": "0.34.1", 2195 - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.1.tgz", 2196 - "integrity": "sha512-pax/kTR407vNb9qaSIiWVnQplPcGU8LRIJpDT5o8PdAx5aAA7AS3X9PS8Isw1/WfqgQorPotjrZL3Pqh6C5EBg==", 2195 + "version": "0.34.2", 2196 + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.2.tgz", 2197 + "integrity": "sha512-DOYMrDm5E6/8bm/yQLCWyuDJwUnlevR8xtF8bs+gjZ7cyUNYXiSf/E8Kp0Ss5xasIaXSHzb888V1BE4i1hFhAA==", 2197 2198 "cpu": [ 2198 2199 "x64" 2199 2200 ], ··· 2213 2214 } 2214 2215 }, 2215 2216 "node_modules/@img/sharp-wasm32": { 2216 - "version": "0.34.1", 2217 - "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.1.tgz", 2218 - "integrity": "sha512-YDybQnYrLQfEpzGOQe7OKcyLUCML4YOXl428gOOzBgN6Gw0rv8dpsJ7PqTHxBnXnwXr8S1mYFSLSa727tpz0xg==", 2217 + "version": "0.34.2", 2218 + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.2.tgz", 2219 + "integrity": "sha512-/VI4mdlJ9zkaq53MbIG6rZY+QRN3MLbR6usYlgITEzi4Rpx5S6LFKsycOQjkOGmqTNmkIdLjEvooFKwww6OpdQ==", 2219 2220 "cpu": [ 2220 2221 "wasm32" 2221 2222 ], 2222 2223 "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", 2223 2224 "optional": true, 2224 2225 "dependencies": { 2225 - "@emnapi/runtime": "^1.4.0" 2226 + "@emnapi/runtime": "^1.4.3" 2226 2227 }, 2227 2228 "engines": { 2228 2229 "node": "^18.17.0 || ^20.3.0 || >=21.0.0" ··· 2231 2232 "url": "https://opencollective.com/libvips" 2232 2233 } 2233 2234 }, 2235 + "node_modules/@img/sharp-win32-arm64": { 2236 + "version": "0.34.2", 2237 + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.2.tgz", 2238 + "integrity": "sha512-cfP/r9FdS63VA5k0xiqaNaEoGxBg9k7uE+RQGzuK9fHt7jib4zAVVseR9LsE4gJcNWgT6APKMNnCcnyOtmSEUQ==", 2239 + "cpu": [ 2240 + "arm64" 2241 + ], 2242 + "license": "Apache-2.0 AND LGPL-3.0-or-later", 2243 + "optional": true, 2244 + "os": [ 2245 + "win32" 2246 + ], 2247 + "engines": { 2248 + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" 2249 + }, 2250 + "funding": { 2251 + "url": "https://opencollective.com/libvips" 2252 + } 2253 + }, 2234 2254 "node_modules/@img/sharp-win32-ia32": { 2235 - "version": "0.34.1", 2236 - "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.1.tgz", 2237 - "integrity": "sha512-WKf/NAZITnonBf3U1LfdjoMgNO5JYRSlhovhRhMxXVdvWYveM4kM3L8m35onYIdh75cOMCo1BexgVQcCDzyoWw==", 2255 + "version": "0.34.2", 2256 + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.2.tgz", 2257 + "integrity": "sha512-QLjGGvAbj0X/FXl8n1WbtQ6iVBpWU7JO94u/P2M4a8CFYsvQi4GW2mRy/JqkRx0qpBzaOdKJKw8uc930EX2AHw==", 2238 2258 "cpu": [ 2239 2259 "ia32" 2240 2260 ], ··· 2251 2271 } 2252 2272 }, 2253 2273 "node_modules/@img/sharp-win32-x64": { 2254 - "version": "0.34.1", 2255 - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.1.tgz", 2256 - "integrity": "sha512-hw1iIAHpNE8q3uMIRCgGOeDoz9KtFNarFLQclLxr/LK1VBkj8nby18RjFvr6aP7USRYAjTZW6yisnBWMX571Tw==", 2274 + "version": "0.34.2", 2275 + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.2.tgz", 2276 + "integrity": "sha512-aUdT6zEYtDKCaxkofmmJDJYGCf0+pJg3eU9/oBuqvEeoB9dKI6ZLc/1iLJCTuJQDO4ptntAlkUmHgGjyuobZbw==", 2257 2277 "cpu": [ 2258 2278 "x64" 2259 2279 ], ··· 7226 7246 "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", 7227 7247 "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", 7228 7248 "license": "MIT", 7229 - "optional": true, 7230 7249 "dependencies": { 7231 7250 "color-convert": "^2.0.1", 7232 7251 "color-string": "^1.9.0" ··· 7239 7258 "version": "2.0.1", 7240 7259 "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", 7241 7260 "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", 7242 - "devOptional": true, 7243 7261 "dependencies": { 7244 7262 "color-name": "~1.1.4" 7245 7263 }, ··· 7250 7268 "node_modules/color-name": { 7251 7269 "version": "1.1.4", 7252 7270 "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", 7253 - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", 7254 - "devOptional": true 7271 + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" 7255 7272 }, 7256 7273 "node_modules/color-string": { 7257 7274 "version": "1.9.1", 7258 7275 "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", 7259 7276 "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", 7260 7277 "license": "MIT", 7261 - "optional": true, 7262 7278 "dependencies": { 7263 7279 "color-name": "^1.0.0", 7264 7280 "simple-swizzle": "^0.2.2" ··· 7599 7615 } 7600 7616 }, 7601 7617 "node_modules/detect-libc": { 7602 - "version": "2.0.3", 7603 - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", 7604 - "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", 7618 + "version": "2.0.4", 7619 + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz", 7620 + "integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==", 7605 7621 "license": "Apache-2.0", 7606 - "optional": true, 7607 7622 "engines": { 7608 7623 "node": ">=8" 7609 7624 } ··· 10622 10637 "version": "0.3.2", 10623 10638 "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", 10624 10639 "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", 10625 - "license": "MIT", 10626 - "optional": true 10640 + "license": "MIT" 10627 10641 }, 10628 10642 "node_modules/is-async-function": { 10629 10643 "version": "2.1.1", ··· 14977 14991 } 14978 14992 }, 14979 14993 "node_modules/semver": { 14980 - "version": "7.7.1", 14981 - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", 14982 - "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", 14994 + "version": "7.7.2", 14995 + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", 14996 + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", 14983 14997 "license": "ISC", 14984 14998 "bin": { 14985 14999 "semver": "bin/semver.js" ··· 15123 15137 "license": "ISC" 15124 15138 }, 15125 15139 "node_modules/sharp": { 15126 - "version": "0.34.1", 15127 - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.1.tgz", 15128 - "integrity": "sha512-1j0w61+eVxu7DawFJtnfYcvSv6qPFvfTaqzTQ2BLknVhHTwGS8sc63ZBF4rzkWMBVKybo4S5OBtDdZahh2A1xg==", 15140 + "version": "0.34.2", 15141 + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.2.tgz", 15142 + "integrity": "sha512-lszvBmB9QURERtyKT2bNmsgxXK0ShJrL/fvqlonCo7e6xBF8nT8xU6pW+PMIbLsz0RxQk3rgH9kd8UmvOzlMJg==", 15129 15143 "hasInstallScript": true, 15130 15144 "license": "Apache-2.0", 15131 - "optional": true, 15132 15145 "dependencies": { 15133 15146 "color": "^4.2.3", 15134 - "detect-libc": "^2.0.3", 15135 - "semver": "^7.7.1" 15147 + "detect-libc": "^2.0.4", 15148 + "semver": "^7.7.2" 15136 15149 }, 15137 15150 "engines": { 15138 15151 "node": "^18.17.0 || ^20.3.0 || >=21.0.0" ··· 15141 15154 "url": "https://opencollective.com/libvips" 15142 15155 }, 15143 15156 "optionalDependencies": { 15144 - "@img/sharp-darwin-arm64": "0.34.1", 15145 - "@img/sharp-darwin-x64": "0.34.1", 15157 + "@img/sharp-darwin-arm64": "0.34.2", 15158 + "@img/sharp-darwin-x64": "0.34.2", 15146 15159 "@img/sharp-libvips-darwin-arm64": "1.1.0", 15147 15160 "@img/sharp-libvips-darwin-x64": "1.1.0", 15148 15161 "@img/sharp-libvips-linux-arm": "1.1.0", ··· 15152 15165 "@img/sharp-libvips-linux-x64": "1.1.0", 15153 15166 "@img/sharp-libvips-linuxmusl-arm64": "1.1.0", 15154 15167 "@img/sharp-libvips-linuxmusl-x64": "1.1.0", 15155 - "@img/sharp-linux-arm": "0.34.1", 15156 - "@img/sharp-linux-arm64": "0.34.1", 15157 - "@img/sharp-linux-s390x": "0.34.1", 15158 - "@img/sharp-linux-x64": "0.34.1", 15159 - "@img/sharp-linuxmusl-arm64": "0.34.1", 15160 - "@img/sharp-linuxmusl-x64": "0.34.1", 15161 - "@img/sharp-wasm32": "0.34.1", 15162 - "@img/sharp-win32-ia32": "0.34.1", 15163 - "@img/sharp-win32-x64": "0.34.1" 15168 + "@img/sharp-linux-arm": "0.34.2", 15169 + "@img/sharp-linux-arm64": "0.34.2", 15170 + "@img/sharp-linux-s390x": "0.34.2", 15171 + "@img/sharp-linux-x64": "0.34.2", 15172 + "@img/sharp-linuxmusl-arm64": "0.34.2", 15173 + "@img/sharp-linuxmusl-x64": "0.34.2", 15174 + "@img/sharp-wasm32": "0.34.2", 15175 + "@img/sharp-win32-arm64": "0.34.2", 15176 + "@img/sharp-win32-ia32": "0.34.2", 15177 + "@img/sharp-win32-x64": "0.34.2" 15164 15178 } 15165 15179 }, 15166 15180 "node_modules/shebang-command": { ··· 15273 15287 "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", 15274 15288 "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", 15275 15289 "license": "MIT", 15276 - "optional": true, 15277 15290 "dependencies": { 15278 15291 "is-arrayish": "^0.3.1" 15279 15292 }
+1
package.json
··· 77 77 "remark-rehype": "^11.1.0", 78 78 "remark-stringify": "^11.0.0", 79 79 "replicache": "^14.2.2", 80 + "sharp": "^0.34.2", 80 81 "swr": "^2.3.3", 81 82 "thumbhash": "^0.1.1", 82 83 "twilio": "^5.3.7",