@payloadcms/figma 1.0.0-beta.3 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dist/adapters/asset-collection.d.ts +15 -0
  2. package/dist/adapters/asset-collection.js +51 -45
  3. package/dist/adapters/build-lambda-zip.d.ts +8 -9
  4. package/dist/adapters/build-lambda-zip.js +36 -44
  5. package/dist/adapters/index.d.ts +4 -0
  6. package/dist/adapters/index.js +4 -0
  7. package/dist/adapters/lambdaLimits.d.ts +6 -0
  8. package/dist/adapters/lambdaLimits.js +5 -0
  9. package/dist/adapters/nextjs-assets.d.ts +7 -0
  10. package/dist/adapters/nextjs-assets.js +44 -0
  11. package/dist/adapters/nextjs.d.ts +8 -0
  12. package/dist/adapters/nextjs.js +19 -37
  13. package/dist/adapters/nitro.js +18 -43
  14. package/dist/adapters/omit-optional-sharp.d.ts +22 -0
  15. package/dist/adapters/omit-optional-sharp.js +158 -0
  16. package/dist/adapters/secret-files.js +8 -1
  17. package/dist/adapters/types.d.ts +8 -0
  18. package/dist/adapters/v2/core/build.d.ts +69 -0
  19. package/dist/adapters/v2/core/build.js +183 -0
  20. package/dist/adapters/v2/core/content-type.d.ts +3 -0
  21. package/dist/adapters/v2/core/content-type.js +41 -0
  22. package/dist/adapters/v2/core/getRelativePathError.d.ts +5 -0
  23. package/dist/adapters/v2/core/getRelativePathError.js +21 -0
  24. package/dist/adapters/v2/core/index.d.ts +15 -0
  25. package/dist/adapters/v2/core/index.js +13 -0
  26. package/dist/adapters/v2/core/limits.d.ts +28 -0
  27. package/dist/adapters/v2/core/limits.js +26 -0
  28. package/dist/adapters/v2/core/manifest-version.d.ts +10 -0
  29. package/dist/adapters/v2/core/manifest-version.js +14 -0
  30. package/dist/adapters/v2/core/server-zip.d.ts +58 -0
  31. package/dist/adapters/v2/core/server-zip.js +123 -0
  32. package/dist/adapters/v2/core/services.d.ts +46 -0
  33. package/dist/adapters/v2/core/services.js +202 -0
  34. package/dist/adapters/v2/core/static-path.d.ts +13 -0
  35. package/dist/adapters/v2/core/static-path.js +32 -0
  36. package/dist/adapters/v2/core/static-site.d.ts +26 -0
  37. package/dist/adapters/v2/core/static-site.js +95 -0
  38. package/dist/adapters/v2/core/types.d.ts +128 -0
  39. package/dist/adapters/v2/core/types.js +7 -0
  40. package/dist/adapters/v2/core/upload.d.ts +67 -0
  41. package/dist/adapters/v2/core/upload.js +198 -0
  42. package/dist/adapters/v2/core/validateDeployment/createIssue.d.ts +3 -0
  43. package/dist/adapters/v2/core/validateDeployment/createIssue.js +7 -0
  44. package/dist/adapters/v2/core/validateDeployment/escapePointer.d.ts +2 -0
  45. package/dist/adapters/v2/core/validateDeployment/escapePointer.js +3 -0
  46. package/dist/adapters/v2/core/validateDeployment/singletonHeaders.d.ts +2 -0
  47. package/dist/adapters/v2/core/validateDeployment/singletonHeaders.js +10 -0
  48. package/dist/adapters/v2/core/validateDeployment/types.d.ts +16 -0
  49. package/dist/adapters/v2/core/validateDeployment/types.js +8 -0
  50. package/dist/adapters/v2/core/validateDeployment/validateArtifacts.d.ts +3 -0
  51. package/dist/adapters/v2/core/validateDeployment/validateArtifacts.js +30 -0
  52. package/dist/adapters/v2/core/validateDeployment/validateCachePolicy.d.ts +8 -0
  53. package/dist/adapters/v2/core/validateDeployment/validateCachePolicy.js +26 -0
  54. package/dist/adapters/v2/core/validateDeployment/validateCounts/validateCount.d.ts +7 -0
  55. package/dist/adapters/v2/core/validateDeployment/validateCounts/validateCount.js +11 -0
  56. package/dist/adapters/v2/core/validateDeployment/validateCounts.d.ts +3 -0
  57. package/dist/adapters/v2/core/validateDeployment/validateCounts.js +41 -0
  58. package/dist/adapters/v2/core/validateDeployment/validateFallback.d.ts +3 -0
  59. package/dist/adapters/v2/core/validateDeployment/validateFallback.js +21 -0
  60. package/dist/adapters/v2/core/validateDeployment/validateHeaderName.d.ts +6 -0
  61. package/dist/adapters/v2/core/validateDeployment/validateHeaderName.js +13 -0
  62. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp/isReservedRuleHeader.d.ts +2 -0
  63. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp/isReservedRuleHeader.js +13 -0
  64. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp.d.ts +11 -0
  65. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules/validateHeaderOp.js +38 -0
  66. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules.d.ts +3 -0
  67. package/dist/adapters/v2/core/validateDeployment/validateHeaderRules.js +17 -0
  68. package/dist/adapters/v2/core/validateDeployment/validateHeaderValue.d.ts +6 -0
  69. package/dist/adapters/v2/core/validateDeployment/validateHeaderValue.js +24 -0
  70. package/dist/adapters/v2/core/validateDeployment/validateId.d.ts +7 -0
  71. package/dist/adapters/v2/core/validateDeployment/validateId.js +12 -0
  72. package/dist/adapters/v2/core/validateDeployment/validateMatch.d.ts +15 -0
  73. package/dist/adapters/v2/core/validateDeployment/validateMatch.js +74 -0
  74. package/dist/adapters/v2/core/validateDeployment/validatePublicPath.d.ts +7 -0
  75. package/dist/adapters/v2/core/validateDeployment/validatePublicPath.js +21 -0
  76. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList/findRepeatedSingletons.d.ts +3 -0
  77. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList/findRepeatedSingletons.js +16 -0
  78. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList.d.ts +11 -0
  79. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateHeaderList.js +48 -0
  80. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseBody.d.ts +10 -0
  81. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseBody.js +16 -0
  82. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseStatus.d.ts +8 -0
  83. package/dist/adapters/v2/core/validateDeployment/validateResponses/validateResponseStatus.js +25 -0
  84. package/dist/adapters/v2/core/validateDeployment/validateResponses.d.ts +7 -0
  85. package/dist/adapters/v2/core/validateDeployment/validateResponses.js +59 -0
  86. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateCaptures.d.ts +10 -0
  87. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateCaptures.js +12 -0
  88. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRedirectAction.d.ts +14 -0
  89. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRedirectAction.js +59 -0
  90. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRewriteAction.d.ts +11 -0
  91. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateRewriteAction.js +20 -0
  92. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateServerAction.d.ts +11 -0
  93. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateServerAction.js +26 -0
  94. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateStaticAction.d.ts +13 -0
  95. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction/validateStaticAction.js +25 -0
  96. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction.d.ts +12 -0
  97. package/dist/adapters/v2/core/validateDeployment/validateRoutes/validateRouteAction.js +35 -0
  98. package/dist/adapters/v2/core/validateDeployment/validateRoutes.d.ts +6 -0
  99. package/dist/adapters/v2/core/validateDeployment/validateRoutes.js +55 -0
  100. package/dist/adapters/v2/core/validateDeployment/validateServers/listReferencedServerIds.d.ts +3 -0
  101. package/dist/adapters/v2/core/validateDeployment/validateServers/listReferencedServerIds.js +12 -0
  102. package/dist/adapters/v2/core/validateDeployment/validateServers.d.ts +7 -0
  103. package/dist/adapters/v2/core/validateDeployment/validateServers.js +59 -0
  104. package/dist/adapters/v2/core/validateDeployment/validateStaticMap.d.ts +3 -0
  105. package/dist/adapters/v2/core/validateDeployment/validateStaticMap.js +22 -0
  106. package/dist/adapters/v2/core/validateDeployment.d.ts +7 -0
  107. package/dist/adapters/v2/core/validateDeployment.js +42 -0
  108. package/dist/adapters/v2/core/write.d.ts +21 -0
  109. package/dist/adapters/v2/core/write.js +30 -0
  110. package/dist/adapters/v2/nextjs/coverage.d.ts +45 -0
  111. package/dist/adapters/v2/nextjs/coverage.js +113 -0
  112. package/dist/adapters/v2/nextjs/read-build-output.d.ts +116 -0
  113. package/dist/adapters/v2/nextjs/read-build-output.js +368 -0
  114. package/dist/adapters/v2/nextjs/translate.d.ts +20 -0
  115. package/dist/adapters/v2/nextjs/translate.js +400 -0
  116. package/dist/adapters/vite.d.ts +7 -0
  117. package/dist/adapters/vite.js +47 -0
  118. package/dist/adapters/writeZip.d.ts +20 -0
  119. package/dist/adapters/writeZip.js +28 -0
  120. package/dist/api/control-plane.d.ts +28 -6
  121. package/dist/api/control-plane.js +67 -64
  122. package/dist/auth/cli-build-context.d.ts +3 -0
  123. package/dist/auth/cli-build-context.js +2 -0
  124. package/dist/auth/oauth-flow.d.ts +3 -3
  125. package/dist/auth/oauth-flow.js +13 -3
  126. package/dist/cli.js +15 -0
  127. package/dist/commands/build-manifest.d.ts +49 -0
  128. package/dist/commands/build-manifest.js +111 -0
  129. package/dist/commands/deploy.js +195 -26
  130. package/dist/db-content-api/generated/content-api-types.d.ts +18 -14
  131. package/dist/db-content-api/index.js +4 -1
  132. package/dist/db-content-api/utilities/where.js +2 -6
  133. package/dist/endpoints/client-config.d.ts +3 -0
  134. package/dist/endpoints/client-config.js +87 -0
  135. package/dist/image-transforms/constants.d.ts +8 -0
  136. package/dist/image-transforms/constants.js +26 -0
  137. package/dist/image-transforms/createImageTransformer.d.ts +6 -0
  138. package/dist/image-transforms/createImageTransformer.js +100 -0
  139. package/dist/image-transforms/deliverImageResponse.d.ts +11 -0
  140. package/dist/image-transforms/deliverImageResponse.js +43 -0
  141. package/dist/image-transforms/imageRevision.d.ts +14 -0
  142. package/dist/image-transforms/imageRevision.js +115 -0
  143. package/dist/image-transforms/normalizeMediaType.d.ts +2 -0
  144. package/dist/image-transforms/normalizeMediaType.js +3 -0
  145. package/dist/image-transforms/parseImageOverrides.d.ts +4 -0
  146. package/dist/image-transforms/parseImageOverrides.js +20 -0
  147. package/dist/image-transforms/preserveImageRedirectHeaders.d.ts +2 -0
  148. package/dist/image-transforms/preserveImageRedirectHeaders.js +30 -0
  149. package/dist/image-transforms/preventConflictingImageTransformers.d.ts +9 -0
  150. package/dist/image-transforms/preventConflictingImageTransformers.js +67 -0
  151. package/dist/image-transforms/serveImageRequest.d.ts +6 -0
  152. package/dist/image-transforms/serveImageRequest.js +97 -0
  153. package/dist/image-transforms/storedImage.d.ts +49 -0
  154. package/dist/image-transforms/storedImage.js +84 -0
  155. package/dist/image-transforms/types.d.ts +9 -0
  156. package/dist/image-transforms/types.js +1 -0
  157. package/dist/image-transforms/variantMetadata.d.ts +13 -0
  158. package/dist/image-transforms/variantMetadata.js +164 -0
  159. package/dist/imageSizeOptions.d.ts +8 -8
  160. package/dist/imageSizeOptions.js +0 -2
  161. package/dist/index.d.ts +1 -0
  162. package/dist/oauth/hooks/refresh.js +9 -4
  163. package/dist/oauth/strategy/index.js +34 -14
  164. package/dist/oauth/utilities/createTokenCookie.d.ts +11 -0
  165. package/dist/oauth/utilities/createTokenCookie.js +21 -0
  166. package/dist/oauth/utilities/refreshTokens.d.ts +7 -5
  167. package/dist/oauth/utilities/refreshTokens.js +7 -23
  168. package/dist/plugin/build-config.d.ts +3 -4
  169. package/dist/plugin/build-config.js +39 -18
  170. package/dist/plugin/mcp-oauth.d.ts +18 -7
  171. package/dist/plugin/mcp-oauth.js +123 -10
  172. package/dist/skills/deploy-to-figma/SKILL.md +8 -8
  173. package/dist/skills/deploy-to-figma/references/cli-reference.md +1 -1
  174. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +2 -1
  175. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +2 -1
  176. package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +2 -1
  177. package/dist/storage-content-api/buildMediaResponseHeaders.js +11 -5
  178. package/dist/storage-content-api/isRunningInLambda.d.ts +2 -0
  179. package/dist/storage-content-api/isRunningInLambda.js +3 -0
  180. package/dist/storage-content-api/staticHandler.js +13 -51
  181. package/dist/storage-content-api/streamMediaResponse.d.ts +17 -0
  182. package/dist/storage-content-api/streamMediaResponse.js +96 -0
  183. package/dist/utils/lambda-config.js +1 -1
  184. package/dist/utils/messages.js +8 -0
  185. package/dist/utils/next-image-loader-config.js +43 -6
  186. package/dist/utils/next-image-loader-file.js +8 -0
  187. package/package.json +12 -4
@@ -1,10 +1,21 @@
1
1
  /**
2
- * Turns off `@payloadcms/plugin-mcp`'s OAuth login in apps that use plugin-mcp, unless the app
3
- * sets plugin-mcp's `oauth` option itself. Newer versions of plugin-mcp turn that login on by
4
- * default, but its default tokens need Payload's password login, which Figma apps turn off, so
5
- * MCP clients would be asked to log in and then fail. MCP clients keep using API keys.
2
+ * Lets MCP clients, like Codex or Figma Agent, log in to the app with Figma. It turns on
3
+ * `@payloadcms/plugin-mcp`'s built-in OAuth server and fills in the part that is specific to
4
+ * Figma login, so apps don't configure anything. It sets plugin-mcp's `oauth` option before
5
+ * plugin-mcp runs, unless the app already set one.
6
6
  *
7
- * It only sets an option on plugin-mcp, so apps without plugin-mcp don't get it. Versions of
8
- * plugin-mcp without the option ignore it.
7
+ * The admin panel's Figma login keeps two cookies: a Payload Admin token, which logs the user
8
+ * in and lasts a few minutes, and the user's Figma access token. When the Payload Admin token
9
+ * expires, the admin panel uses the Figma access token as a refresh token to get a new one
10
+ * (`refreshTokens`).
11
+ *
12
+ * With plugin-mcp, an MCP client sends the user to the app's Allow page in the browser, where
13
+ * they log in to the admin panel if needed and click Allow. plugin-mcp then needs tokens for
14
+ * the client, but doesn't know about the admin login's cookies. `issueToken` and
15
+ * `refreshToken` fill that in: they give the client its own Payload Admin token, sealed for MCP,
16
+ * and the same refresh token, so it can refresh the way the admin panel does.
9
17
  */
10
- export declare const createMCPOAuthPlugin: () => import("payload").Plugin;
18
+ export declare const createMCPOAuthPlugin: (options: {
19
+ /** The cookie the admin login keeps its refresh token, the user's Figma access token, in */
20
+ refreshTokenCookie: string;
21
+ }) => import("payload").Plugin;
@@ -1,22 +1,135 @@
1
- import { definePlugin } from 'payload';
1
+ // Types plugin-mcp's options in `plugins`, so its hooks below are checked against its config
2
+ import { APIError, definePlugin, executeAuthStrategies, parseCookies } from 'payload';
3
+ import { formatAdminURL, stripTrailingSlash } from 'payload/shared';
4
+ import { refreshTokens } from '../oauth/utilities/refreshTokens.js';
5
+ const ACCESS_TOKEN_TYPE = 'figma-mcp-access';
2
6
  /**
3
- * Turns off `@payloadcms/plugin-mcp`'s OAuth login in apps that use plugin-mcp, unless the app
4
- * sets plugin-mcp's `oauth` option itself. Newer versions of plugin-mcp turn that login on by
5
- * default, but its default tokens need Payload's password login, which Figma apps turn off, so
6
- * MCP clients would be asked to log in and then fail. MCP clients keep using API keys.
7
+ * Seals the Payload Admin token an MCP client gets, like plugin-mcp's default `issueToken`, so
8
+ * it only works at the MCP endpoint, where `authenticate` unseals it. Raw, it would work as the
9
+ * user's admin panel login on every route.
10
+ */ const sealAccessToken = (req, token)=>req.payload.encrypt(JSON.stringify({
11
+ type: ACCESS_TOKEN_TYPE,
12
+ token
13
+ }));
14
+ const unsealAccessToken = (req, value)=>{
15
+ if (!value.startsWith('v1:')) {
16
+ return undefined;
17
+ }
18
+ try {
19
+ const data = JSON.parse(req.payload.decrypt(value));
20
+ return data.type === ACCESS_TOKEN_TYPE && typeof data.token === 'string' ? data.token : undefined;
21
+ } catch {
22
+ return undefined;
23
+ }
24
+ };
25
+ /**
26
+ * The tokens plugin-mcp gives an MCP client, from a `refreshTokens` result: the new Payload
27
+ * Admin token, sealed, and the same refresh token, which plugin-mcp seals so clients can't
28
+ * read it. Returns `null`, which signs the client out, when Figma refuses, e.g. because the
29
+ * user lost access to the app.
30
+ */ const toTokens = (req, refreshed, refreshToken)=>{
31
+ if (refreshed.status === 'rejected') {
32
+ return null;
33
+ }
34
+ // Other errors, like Figma being down, shouldn't sign MCP clients out
35
+ if (refreshed.status === 'temporary_failure') {
36
+ throw new APIError('Could not get a Payload token from Figma. Try again.', 503);
37
+ }
38
+ return {
39
+ accessToken: sealAccessToken(req, refreshed.token),
40
+ expiresIn: Math.floor((refreshed.expiresAt - Date.now()) / 1000),
41
+ refreshToken
42
+ };
43
+ };
44
+ /**
45
+ * The MCP endpoint's public URL. A deployed app's request URL is the server's own address, like
46
+ * `https://0.0.0.0:3000`, but Figma's sites worker sets `x-forwarded-host` to the host the
47
+ * client used, which can be the `figma.site` domain or a custom one. The path is plugin-mcp's
48
+ * default, which includes Next.js's `basePath`.
49
+ */ const getMCPResource = ({ req })=>{
50
+ const { routes, serverURL } = req.payload.config;
51
+ const requestURL = new URL(serverURL || req.url);
52
+ // With several proxies in a row, the first value is the client's
53
+ const host = serverURL ? undefined : (req.headers.get('x-forwarded-host') ?? req.headers.get('host'))?.split(',')[0].trim();
54
+ const protocol = req.headers.get('x-forwarded-proto')?.split(',')[0].trim() ?? requestURL.protocol.slice(0, -1);
55
+ const origin = host ? `${protocol}://${host}` : requestURL.origin;
56
+ // Without the slash Next.js's `trailingSlash` would add, since plugin-mcp appends to it
57
+ const path = stripTrailingSlash(formatAdminURL({
58
+ apiRoute: routes.api,
59
+ path: '/mcp'
60
+ }));
61
+ return new URL(path, origin).href;
62
+ };
63
+ /**
64
+ * Lets MCP clients, like Codex or Figma Agent, log in to the app with Figma. It turns on
65
+ * `@payloadcms/plugin-mcp`'s built-in OAuth server and fills in the part that is specific to
66
+ * Figma login, so apps don't configure anything. It sets plugin-mcp's `oauth` option before
67
+ * plugin-mcp runs, unless the app already set one.
68
+ *
69
+ * The admin panel's Figma login keeps two cookies: a Payload Admin token, which logs the user
70
+ * in and lasts a few minutes, and the user's Figma access token. When the Payload Admin token
71
+ * expires, the admin panel uses the Figma access token as a refresh token to get a new one
72
+ * (`refreshTokens`).
7
73
  *
8
- * It only sets an option on plugin-mcp, so apps without plugin-mcp don't get it. Versions of
9
- * plugin-mcp without the option ignore it.
74
+ * With plugin-mcp, an MCP client sends the user to the app's Allow page in the browser, where
75
+ * they log in to the admin panel if needed and click Allow. plugin-mcp then needs tokens for
76
+ * the client, but doesn't know about the admin login's cookies. `issueToken` and
77
+ * `refreshToken` fill that in: they give the client its own Payload Admin token, sealed for MCP,
78
+ * and the same refresh token, so it can refresh the way the admin panel does.
10
79
  */ export const createMCPOAuthPlugin = definePlugin({
11
80
  slug: '@payloadcms/figma/mcp-oauth',
12
- // Before @payloadcms/plugin-mcp, which runs at order 10 and reads its options then
81
+ // Before @payloadcms/plugin-mcp, which runs at order 10
13
82
  order: 5,
14
- plugin: ({ config, plugins })=>{
83
+ plugin: ({ config, options: { refreshTokenCookie }, plugins })=>{
15
84
  const mcp = plugins['@payloadcms/plugin-mcp'];
85
+ // plugin-mcp reads its options when it runs. `oauth: false` turns OAuth off.
16
86
  if (mcp && mcp.options?.oauth === undefined) {
17
87
  mcp.options = {
18
88
  ...mcp.options,
19
- oauth: false
89
+ oauth: {
90
+ type: 'builtin',
91
+ authenticate: async ({ req, token })=>{
92
+ const adminToken = unsealAccessToken(req, token);
93
+ if (!adminToken) {
94
+ return null;
95
+ }
96
+ const headers = new Headers({
97
+ Authorization: `Bearer ${adminToken}`,
98
+ DisableAutologin: 'true'
99
+ });
100
+ return (await executeAuthStrategies({
101
+ headers,
102
+ payload: req.payload,
103
+ req
104
+ })).user;
105
+ },
106
+ /**
107
+ * When the user clicks Allow. Reads the refresh token from the browser's cookies.
108
+ * plugin-mcp gives the client fresh tokens from `refreshToken` when it trades its
109
+ * authorization code, but getting a Payload Admin token here already checks that
110
+ * Figma still accepts the user, so they see the error in the browser.
111
+ */ issueToken: async ({ req })=>{
112
+ const refreshToken = parseCookies(req.headers).get(refreshTokenCookie);
113
+ const tokens = refreshToken && toTokens(req, await refreshTokens({
114
+ payload: req.payload,
115
+ refreshToken
116
+ }), refreshToken);
117
+ if (!tokens) {
118
+ throw new APIError('Log in to the admin panel again, then allow the MCP client.', 401);
119
+ }
120
+ return tokens;
121
+ },
122
+ /**
123
+ * When the client trades its authorization code, and when its Payload Admin token
124
+ * expires. There's no browser then, so this uses the refresh token `issueToken`
125
+ * returned. It keeps working until the user's Figma access token expires.
126
+ */ refreshToken: async ({ refreshToken, req })=>toTokens(req, await refreshTokens({
127
+ payload: req.payload,
128
+ refreshToken
129
+ }), refreshToken),
130
+ // plugin-mcp also bases its metadata link and login server's address on it
131
+ resource: getMCPResource
132
+ }
20
133
  };
21
134
  }
22
135
  return config;
@@ -18,9 +18,9 @@ do not ask `@payloadcms/figma` what framework this is, and do not guess. When th
18
18
  evidence conflicts or the shape isn't one Figma Cloud supports, **stop** before
19
19
  touching auth or deploy.
20
20
 
21
- Run the CLI with `npx @payloadcms/figma@alpha <...>` **from the target folder**.
21
+ Run the CLI with `npx @payloadcms/figma@latest <...>` **from the target folder**.
22
22
  If a different invocation is already established in the repo (e.g.
23
- `pnpm start --`), use that instead — but `npx @payloadcms/figma@alpha` is the
23
+ `pnpm start --`), use that instead — but `npx @payloadcms/figma@latest` is the
24
24
  default.
25
25
 
26
26
  If the user's request contains **“Figma staging”** (case-insensitive), append
@@ -149,7 +149,7 @@ The deploy command needs a valid credential and cannot open a browser in a
149
149
  headless/agent context, so authenticate first with the resumable headless flow.
150
150
 
151
151
  ```bash
152
- npx @payloadcms/figma@alpha login --headless --json
152
+ npx @payloadcms/figma@latest login --headless --json
153
153
  ```
154
154
 
155
155
  Parse `status`:
@@ -161,7 +161,7 @@ Parse `status`:
161
161
  `http://localhost:.../callback?...` address the browser lands on). Then:
162
162
 
163
163
  ```bash
164
- npx @payloadcms/figma@alpha login --complete <sessionId> --callback-url '<redirect-url>' --json
164
+ npx @payloadcms/figma@latest login --complete <sessionId> --callback-url '<redirect-url>' --json
165
165
  ```
166
166
 
167
167
  Quote the callback URL in single quotes. Expect `{"status":"authenticated",...}`.
@@ -180,7 +180,7 @@ Run **from the target folder**, non-interactively with `-y`. Always pass
180
180
  explicit `--adapter` / `--output` you verified in Steps 2–3:
181
181
 
182
182
  ```bash
183
- npx @payloadcms/figma@alpha deploy -y --skip-build --adapter <nextjs|nitro|vite> --output <verified-root>
183
+ npx @payloadcms/figma@latest deploy -y --skip-build --adapter <nextjs|nitro|vite> --output <verified-root>
184
184
  ```
185
185
 
186
186
  Add the project-creation flags from Step 4 only for an uninitialized project.
@@ -189,13 +189,13 @@ Examples:
189
189
 
190
190
  ```bash
191
191
  # Next.js app in a monorepo package (already initialized), built to .next
192
- npx @payloadcms/figma@alpha deploy -y --skip-build --adapter nextjs --output .next
192
+ npx @payloadcms/figma@latest deploy -y --skip-build --adapter nextjs --output .next
193
193
 
194
194
  # Vite single-page app, built to dist
195
- npx @payloadcms/figma@alpha deploy -y --skip-build --adapter vite --output dist
195
+ npx @payloadcms/figma@latest deploy -y --skip-build --adapter vite --output dist
196
196
 
197
197
  # Simple static folder (index.html at the folder root), no build
198
- npx @payloadcms/figma@alpha deploy -y --skip-build --adapter vite --output .
198
+ npx @payloadcms/figma@latest deploy -y --skip-build --adapter vite --output .
199
199
  ```
200
200
 
201
201
  ### Deterministic retry — workspace selection
@@ -99,7 +99,7 @@ The deploy command is always explicit — the agent supplies the verified adapte
99
99
  and output root and skips the build (it already ran, or the folder is static):
100
100
 
101
101
  ```bash
102
- npx @payloadcms/figma@alpha deploy -y --skip-build --adapter <nextjs|nitro|vite> --output <root>
102
+ npx @payloadcms/figma@latest deploy -y --skip-build --adapter <nextjs|nitro|vite> --output <root>
103
103
  ```
104
104
 
105
105
  | Flag | Purpose |
@@ -5,8 +5,9 @@
5
5
  * Attachment and sandbox protections remain. This helper is only used when uploadReference
6
6
  * is present; normal file requests use buildMediaResponseHeaders.
7
7
  */
8
- export declare function buildClientUploadFetchBackHeaders({ fallbackContentType, filename, upstreamHeaders, }: {
8
+ export declare function buildClientUploadFetchBackHeaders({ fallbackContentType, filename, status, upstreamHeaders, }: {
9
9
  fallbackContentType?: string;
10
10
  filename: string;
11
+ status: number;
11
12
  upstreamHeaders: Headers;
12
13
  }): Headers;
@@ -6,7 +6,7 @@ import { shouldAttachMedia } from './shouldAttachMedia.js';
6
6
  * Content-Type so Payload uses the original upload MIME type instead of application/octet-stream.
7
7
  * Attachment and sandbox protections remain. This helper is only used when uploadReference
8
8
  * is present; normal file requests use buildMediaResponseHeaders.
9
- */ export function buildClientUploadFetchBackHeaders({ fallbackContentType, filename, upstreamHeaders }) {
9
+ */ export function buildClientUploadFetchBackHeaders({ fallbackContentType, filename, status, upstreamHeaders }) {
10
10
  const effectiveContentType = upstreamHeaders.get('Content-Type') || fallbackContentType;
11
11
  const upstreamHeadersWithFallback = new Headers(upstreamHeaders);
12
12
  if (effectiveContentType) {
@@ -14,6 +14,7 @@ import { shouldAttachMedia } from './shouldAttachMedia.js';
14
14
  }
15
15
  const headers = buildMediaResponseHeaders({
16
16
  filename,
17
+ status,
17
18
  upstreamHeaders: upstreamHeadersWithFallback
18
19
  });
19
20
  if (effectiveContentType && shouldAttachMedia(upstreamHeadersWithFallback)) {
@@ -1,4 +1,5 @@
1
- export declare function buildMediaResponseHeaders({ filename, upstreamHeaders, }: {
1
+ export declare function buildMediaResponseHeaders({ filename, status, upstreamHeaders, }: {
2
2
  filename: string;
3
+ status: number;
3
4
  upstreamHeaders: Headers;
4
5
  }): Headers;
@@ -1,22 +1,28 @@
1
1
  import { buildBaseMediaResponseHeaders } from './buildBaseMediaResponseHeaders.js';
2
2
  import { getMediaType } from './getMediaType.js';
3
3
  import { shouldAttachMedia } from './shouldAttachMedia.js';
4
- const FORWARDED_MEDIA_RESPONSE_HEADERS = [
4
+ const FORWARDED_MEDIA_CACHE_HEADERS = [
5
5
  'Cache-Control',
6
- 'Content-Length',
7
- 'Content-Range',
8
6
  'ETag',
9
7
  'Last-Modified'
10
8
  ];
11
9
  const ATTACHMENT_CSP = "sandbox; default-src 'none'; base-uri 'none'; form-action 'none'";
12
- export function buildMediaResponseHeaders({ filename, upstreamHeaders }) {
10
+ export function buildMediaResponseHeaders({ filename, status, upstreamHeaders }) {
13
11
  const headers = buildBaseMediaResponseHeaders();
14
- for (const name of FORWARDED_MEDIA_RESPONSE_HEADERS){
12
+ const forwardedHeaders = status === 304 ? FORWARDED_MEDIA_CACHE_HEADERS : [
13
+ ...FORWARDED_MEDIA_CACHE_HEADERS,
14
+ 'Content-Length',
15
+ 'Content-Range'
16
+ ];
17
+ for (const name of forwardedHeaders){
15
18
  const value = upstreamHeaders.get(name);
16
19
  if (value) {
17
20
  headers.set(name, value);
18
21
  }
19
22
  }
23
+ if (status === 304) {
24
+ return headers;
25
+ }
20
26
  if (shouldAttachMedia(upstreamHeaders)) {
21
27
  headers.set('Content-Type', 'application/octet-stream');
22
28
  headers.set('Content-Disposition', attachmentDisposition(filename));
@@ -0,0 +1,2 @@
1
+ /** Hosted Figma Cloud deployments run on Lambda behind the tenant site's Sites Worker. */
2
+ export declare function isRunningInLambda(): boolean;
@@ -0,0 +1,3 @@
1
+ /** Hosted Figma Cloud deployments run on Lambda behind the tenant site's Sites Worker. */ export function isRunningInLambda() {
2
+ return process.env.AWS_EXECUTION_ENV?.startsWith('AWS_Lambda_') === true;
3
+ }
@@ -1,11 +1,9 @@
1
1
  import { buildStoragePathData, getFilePrefix } from '@payloadcms/plugin-cloud-storage/utilities';
2
- import { buildClientUploadFetchBackHeaders } from './buildClientUploadFetchBackHeaders.js';
3
2
  import { buildMediaRequestHeaders } from './buildMediaRequestHeaders.js';
4
- import { buildMediaResponseHeaders } from './buildMediaResponseHeaders.js';
5
3
  import { getDownloadResponseHeaderPolicy } from './getDownloadResponseHeaderPolicy.js';
6
- import { hasSupportedContentEncoding } from './hasSupportedContentEncoding.js';
7
- import { mediaErrorResponse } from './mediaErrorResponse.js';
4
+ import { isRunningInLambda } from './isRunningInLambda.js';
8
5
  import { resolveDownloadResponseHeaders } from './resolveDownloadResponseHeaders.js';
6
+ import { streamMediaResponse } from './streamMediaResponse.js';
9
7
  const PRESIGNED_DOWNLOAD_URL_EXPIRES_IN_SECONDS = 300;
10
8
  export const getHandler = ({ client, collection, prefix = '' })=>{
11
9
  return async (req, { doc, headers, params })=>{
@@ -56,45 +54,19 @@ export const getHandler = ({ client, collection, prefix = '' })=>{
56
54
  return Response.redirect(data.url, 302);
57
55
  }
58
56
  const requestHeaders = buildMediaRequestHeaders(req.headers);
59
- let fileResponse;
60
- try {
61
- fileResponse = await fetch(data.url, {
62
- credentials: 'omit',
63
- headers: requestHeaders,
64
- redirect: 'manual',
65
- referrerPolicy: 'no-referrer',
66
- signal: req.signal
67
- });
68
- } catch {
69
- // Fetch errors can contain the signed URL; log only a fixed message to avoid exposing it.
70
- req.payload.logger.error('Failed to fetch file from storage');
71
- return mediaErrorResponse(500, 'Internal Server Error');
72
- }
73
- if (fileResponse.status === 416 && requestHeaders.has('Range')) {
74
- await cancelResponseBody(fileResponse);
75
- return mediaErrorResponse(416, 'Range Not Satisfiable', fileResponse.headers.get('Content-Range') ?? undefined);
76
- }
77
- if (!fileResponse.ok) {
78
- await cancelResponseBody(fileResponse);
79
- req.payload.logger.error(`Failed to fetch file from storage: ${fileResponse.status}`);
80
- return mediaErrorResponse(500, 'Internal Server Error');
81
- }
82
- if (!hasSupportedContentEncoding(fileResponse.headers)) {
83
- await cancelResponseBody(fileResponse);
84
- req.payload.logger.error('Unsupported Content-Encoding from storage');
85
- return mediaErrorResponse(502, 'Bad Gateway');
57
+ // Internal upload and transform reads need bytes even when the viewer has a cached file.
58
+ const ifNoneMatch = req.headers.get('If-None-Match');
59
+ if (!isClientUpload && operation !== 'transform' && ifNoneMatch) {
60
+ requestHeaders.set('If-None-Match', ifNoneMatch);
86
61
  }
87
- const responseHeaders = isClientUpload ? buildClientUploadFetchBackHeaders({
62
+ // Await so unexpected failures reach this handler's catch instead of escaping to Payload.
63
+ return await streamMediaResponse({
88
64
  filename,
89
- upstreamHeaders: fileResponse.headers
90
- }) : buildMediaResponseHeaders({
91
- filename,
92
- upstreamHeaders: fileResponse.headers
93
- });
94
- return new Response(fileResponse.body, {
95
- headers: responseHeaders,
96
- status: fileResponse.status,
97
- statusText: fileResponse.statusText
65
+ kind: isClientUpload ? 'clientUpload' : 'storage',
66
+ req,
67
+ requestHeaders,
68
+ responseHeaderPolicy,
69
+ url: data.url
98
70
  });
99
71
  } catch (err) {
100
72
  req.payload.logger.error({
@@ -107,13 +79,3 @@ export const getHandler = ({ client, collection, prefix = '' })=>{
107
79
  }
108
80
  };
109
81
  };
110
- function isRunningInLambda() {
111
- return process.env.AWS_EXECUTION_ENV?.startsWith('AWS_Lambda_') === true;
112
- }
113
- async function cancelResponseBody(response) {
114
- try {
115
- await response.body?.cancel();
116
- } catch {
117
- // The response will not be consumed after an error; cancellation is best-effort cleanup.
118
- }
119
- }
@@ -0,0 +1,17 @@
1
+ import type { PayloadRequest } from 'payload';
2
+ /**
3
+ * What the streamed bytes are for: a client upload Payload reads back, a Cloudflare image
4
+ * transformation, or a stored file.
5
+ */
6
+ export type MediaResponseKind = 'clientUpload' | 'imageTransform' | 'storage';
7
+ /** Fetch delivery bytes without exposing signed URLs or forwarding viewer credentials. */
8
+ export declare function streamMediaResponse({ filename, kind, req, requestHeaders, responseHeaderPolicy, url, }: {
9
+ filename: string;
10
+ kind: MediaResponseKind;
11
+ req: PayloadRequest;
12
+ requestHeaders: Headers;
13
+ responseHeaderPolicy: {
14
+ cacheControl: string;
15
+ };
16
+ url: string;
17
+ }): Promise<Response>;
@@ -0,0 +1,96 @@
1
+ import { buildClientUploadFetchBackHeaders } from './buildClientUploadFetchBackHeaders.js';
2
+ import { buildMediaResponseHeaders } from './buildMediaResponseHeaders.js';
3
+ import { getMediaType } from './getMediaType.js';
4
+ import { hasSupportedContentEncoding } from './hasSupportedContentEncoding.js';
5
+ import { mediaErrorResponse } from './mediaErrorResponse.js';
6
+ /** Fetch delivery bytes without exposing signed URLs or forwarding viewer credentials. */ export async function streamMediaResponse({ filename, kind, req, requestHeaders, responseHeaderPolicy, url }) {
7
+ const imageTransform = kind === 'imageTransform';
8
+ let fileResponse;
9
+ try {
10
+ fileResponse = await fetch(url, {
11
+ ...imageTransform ? {
12
+ method: req.method
13
+ } : {},
14
+ credentials: 'omit',
15
+ headers: requestHeaders,
16
+ redirect: 'manual',
17
+ referrerPolicy: 'no-referrer',
18
+ signal: req.signal
19
+ });
20
+ } catch {
21
+ // Fetch errors can contain the signed URL; log only a fixed message to avoid exposing it.
22
+ req.payload.logger.error('Failed to fetch file from storage');
23
+ return mediaErrorResponse(500, 'Internal Server Error');
24
+ }
25
+ if (fileResponse.status === 416 && requestHeaders.has('Range')) {
26
+ await cancelResponseBody(fileResponse);
27
+ return mediaErrorResponse(416, 'Range Not Satisfiable', fileResponse.headers.get('Content-Range') ?? undefined);
28
+ }
29
+ if (fileResponse.status === 304 && requestHeaders.has('If-None-Match')) {
30
+ await cancelResponseBody(fileResponse);
31
+ const responseHeaders = buildMediaResponseHeaders({
32
+ filename,
33
+ status: fileResponse.status,
34
+ upstreamHeaders: fileResponse.headers
35
+ });
36
+ // S3 can omit signed response-header overrides on 304 responses.
37
+ responseHeaders.set('Cache-Control', responseHeaderPolicy.cacheControl);
38
+ if (imageTransform) {
39
+ setImageTransformHeaders(responseHeaders);
40
+ }
41
+ return new Response(null, {
42
+ headers: responseHeaders,
43
+ status: 304
44
+ });
45
+ }
46
+ if (!fileResponse.ok) {
47
+ await cancelResponseBody(fileResponse);
48
+ req.payload.logger.error(`Failed to fetch file from storage: ${fileResponse.status}`);
49
+ return mediaErrorResponse(500, 'Internal Server Error');
50
+ }
51
+ if (!hasSupportedContentEncoding(fileResponse.headers)) {
52
+ await cancelResponseBody(fileResponse);
53
+ req.payload.logger.error('Unsupported Content-Encoding from storage');
54
+ return mediaErrorResponse(502, 'Bad Gateway');
55
+ }
56
+ const responseHeaders = kind === 'clientUpload' ? buildClientUploadFetchBackHeaders({
57
+ filename,
58
+ status: fileResponse.status,
59
+ upstreamHeaders: fileResponse.headers
60
+ }) : buildMediaResponseHeaders({
61
+ filename,
62
+ status: fileResponse.status,
63
+ upstreamHeaders: fileResponse.headers
64
+ });
65
+ if (imageTransform) {
66
+ setImageTransformHeaders(responseHeaders);
67
+ const contentSecurityPolicy = fileResponse.headers.get('Content-Security-Policy');
68
+ if (contentSecurityPolicy) {
69
+ responseHeaders.set('Content-Security-Policy', contentSecurityPolicy);
70
+ if (getMediaType(fileResponse.headers) === 'image/svg+xml') {
71
+ // Cloudflare sanitizes SVG; Payload also applies its XML policy to the final response.
72
+ responseHeaders.set('Content-Type', 'image/svg+xml');
73
+ responseHeaders.delete('Content-Disposition');
74
+ }
75
+ }
76
+ }
77
+ return new Response(fileResponse.body, {
78
+ headers: responseHeaders,
79
+ status: fileResponse.status,
80
+ statusText: fileResponse.statusText
81
+ });
82
+ }
83
+ /**
84
+ * Headers every transformation response shares, including a 304, whose headers update the cached
85
+ * response. The image varies with the viewer and `Accept`, and its fetch never forwards `Range`.
86
+ */ function setImageTransformHeaders(headers) {
87
+ headers.set('Vary', 'Cookie, Accept, Origin');
88
+ headers.delete('Accept-Ranges');
89
+ }
90
+ async function cancelResponseBody(response) {
91
+ try {
92
+ await response.body?.cancel();
93
+ } catch {
94
+ // The response will not be consumed after an error; cancellation is best-effort cleanup.
95
+ }
96
+ }
@@ -51,7 +51,7 @@ NODE_ENV=production exec node server.js
51
51
  /**
52
52
  * Add required Next.js config properties using ts-morph AST parsing
53
53
  * - output: 'standalone' (for Lambda deployment)
54
- * - images.loader: 'custom' and images.loaderFile for Payload media
54
+ * - images.loader: 'custom' and images.loaderFile for Payload media when no loader is configured
55
55
  */ async function addNextConfigProperties(projectPath) {
56
56
  const nextConfigPath = await findNextConfigPath(projectPath);
57
57
  const project = new Project({
@@ -22,6 +22,7 @@ export function helpMessage() {
22
22
  ${pc.cyan('upgrade')} Run upgrade migrations
23
23
  ${pc.cyan('upload-schema')} Upload collection schema to the Content API
24
24
  ${pc.cyan('build-lambda-zip')} Build Lambda deployment zip
25
+ ${pc.cyan('build-manifest')} Write a deployment manifest v2 from an existing build (preview)
25
26
 
26
27
  ${pc.bold('OPTIONS')}
27
28
 
@@ -77,6 +78,13 @@ export function helpMessage() {
77
78
  ${pc.dim('--adapter <nextjs|nitro|vite>')} Override framework detection
78
79
  ${pc.dim('--output <path>')} Exact framework build output root
79
80
 
81
+ ${pc.bold('BUILD MANIFEST COMMAND')}
82
+
83
+ ${pc.cyan('@payloadcms/figma build-manifest')} Write manifest v2 from an existing build; no upload
84
+ ${pc.dim('--adapter <vite>')} Override framework detection
85
+ ${pc.dim('--output <path>')} Exact framework build output root
86
+ ${pc.dim('--json')} Print a JSON summary
87
+
80
88
  ${pc.bold('SETUP AGENT COMMAND')}
81
89
 
82
90
  ${pc.cyan('@payloadcms/figma setup-agent')} Prompt for global or project installation
@@ -1,8 +1,13 @@
1
1
  import { Node, SyntaxKind } from 'ts-morph';
2
+ import { warning } from './log.js';
2
3
  import { FIGMA_IMAGE_LOADER_PATH } from './next-image-loader-file.js';
3
4
  export function addFigmaImageLoaderConfig(configObject) {
4
- const imagesProperty = configObject.getProperty('images');
5
+ const imagesProperty = getNamedProperty(configObject, 'images');
5
6
  if (!imagesProperty) {
7
+ if (configObject.getProperties().some(isDynamicProperty)) {
8
+ warnAboutUninspectableImages();
9
+ return;
10
+ }
6
11
  configObject.addPropertyAssignment({
7
12
  name: 'images',
8
13
  initializer: `{
@@ -19,15 +24,21 @@ export function addFigmaImageLoaderConfig(configObject) {
19
24
  imagesValue = imagesProperty.getNameNode();
20
25
  }
21
26
  const imagesObject = resolveLocalObjectLiteral(imagesValue);
22
- if (!imagesObject) {
23
- throw new Error('Figma could not add the image loader because it could not inspect the `images` configuration. ' + 'Define `images` as an object in this Next.js config file and rerun ' + '`npx @payloadcms/figma init`.');
27
+ if (!imagesObject || imagesObject.getProperties().some(isDynamicProperty)) {
28
+ warnAboutUninspectableImages();
29
+ return;
30
+ }
31
+ const loaderProperty = getNamedProperty(imagesObject, 'loader');
32
+ const loaderFileProperty = getNamedProperty(imagesObject, 'loaderFile');
33
+ if (Node.isPropertyAssignment(loaderProperty) && getStringPropertyValue(loaderProperty) === 'default' && !loaderFileProperty) {
34
+ ensureFigmaImageLoaderSetupComment(loaderProperty);
35
+ warning("Keeping Next.js's default image loader. Figma's image loader was not enabled. " + 'Payload images may not display or transform as expected. ' + `To switch, see the setup instructions in ${FIGMA_IMAGE_LOADER_PATH}.`);
36
+ return;
24
37
  }
25
- const loaderProperty = imagesObject.getProperty('loader');
26
- const loaderFileProperty = imagesObject.getProperty('loaderFile');
27
38
  if (loaderProperty || loaderFileProperty) {
28
39
  const isFigmaLoader = getStringPropertyValue(loaderProperty) === 'custom' && getStringPropertyValue(loaderFileProperty) === FIGMA_IMAGE_LOADER_PATH;
29
40
  if (!isFigmaLoader) {
30
- throw new Error('A custom Next.js image loader is already configured, so Figma left it unchanged. ' + 'Remove the existing images.loader and images.loaderFile settings and rerun ' + '`npx @payloadcms/figma init`.');
41
+ warning('A Next.js image loader is already configured, so Figma left it unchanged. ' + "Without Figma's image loader, Payload images may not display or transform as expected. " + `To use Figma's image loader, see the setup instructions in ${FIGMA_IMAGE_LOADER_PATH}.`);
31
42
  }
32
43
  return;
33
44
  }
@@ -40,6 +51,32 @@ export function addFigmaImageLoaderConfig(configObject) {
40
51
  initializer: `'${FIGMA_IMAGE_LOADER_PATH}'`
41
52
  });
42
53
  }
54
+ function ensureFigmaImageLoaderSetupComment(loaderProperty) {
55
+ const setupComment = `// To enable Figma image delivery and transforms, see ${FIGMA_IMAGE_LOADER_PATH}.`;
56
+ if (loaderProperty.getLeadingCommentRanges().some((comment)=>comment.getText() === setupComment)) {
57
+ return;
58
+ }
59
+ const indentation = loaderProperty.getIndentationText();
60
+ const loaderSource = loaderProperty.getText(true);
61
+ // Preserve the source indentation instead of applying the writer's configured indentation.
62
+ loaderProperty.replaceWithText((writer)=>{
63
+ writer.setIndentationLevel(0).queueIndentationLevel(0);
64
+ // A comment on its own line remains a leading comment when init parses the file again.
65
+ if (!loaderProperty.isFirstNodeOnLine()) {
66
+ writer.newLine().write(indentation);
67
+ }
68
+ writer.write(setupComment).newLine().write(indentation).write(loaderSource);
69
+ });
70
+ }
71
+ function warnAboutUninspectableImages() {
72
+ warning('Figma could not inspect the `images` configuration and left it unchanged. ' + `To use Figma's image loader, see the setup instructions in ${FIGMA_IMAGE_LOADER_PATH}.`);
73
+ }
74
+ function isDynamicProperty(property) {
75
+ return Node.isSpreadAssignment(property) || property.getFirstChildByKind(SyntaxKind.ComputedPropertyName) !== undefined;
76
+ }
77
+ function getNamedProperty(object, name) {
78
+ return object.getProperty(name) ?? object.getProperty(`'${name}'`) ?? object.getProperty(`"${name}"`);
79
+ }
43
80
  function resolveLocalObjectLiteral(node) {
44
81
  if (Node.isObjectLiteralExpression(node)) {
45
82
  return node;