create-ailk 0.37.1 → 0.39.0
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.
- package/README.md +129 -0
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +2 -2
- package/dist/add-route.js +19 -12
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +12 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +73 -2
- package/dist/routes.d.ts +130 -0
- package/dist/routes.js +954 -0
- package/dist/site-manifest.js +6 -4
- package/dist/site-roster.d.ts +11 -2
- package/dist/site-roster.js +63 -21
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +26 -0
- package/dist/surfaces.js +105 -293
- package/dist/sync-routes.d.ts +14 -1
- package/dist/sync-routes.js +108 -10
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +26 -1
- package/dist/topology.js +273 -7
- package/dist/update.d.ts +17 -2
- package/dist/update.js +480 -77
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +87 -23
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
- package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
- package/templates/apps/web/account.config.tsx +100 -0
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +2 -2
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
- package/templates/apps/web/app/[locale]/layout.tsx +46 -29
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/auth.config.tsx +107 -0
- package/templates/apps/web/auth.ts +2 -1
- package/templates/apps/web/i18n/request.ts +51 -1
- package/templates/apps/web/jest.config.cjs +17 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/server-api.ts +1 -1
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/lib/topology.generated.ts +5 -0
- package/templates/apps/web/messages/en.json +8 -836
- package/templates/apps/web/middleware.ts +15 -26
- package/templates/apps/web/next.config.mjs +35 -0
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/types/messages.d.ts +6 -1
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +49 -47
- package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
- package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
- package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
- package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
- package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
- package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
- package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
- package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
- package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
- package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
- package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
- package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
- package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
- package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
- package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
- package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
- package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
- package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
- package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
- package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
- package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
- package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/auth-routes.ts +0 -125
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
- package/templates/apps/web/lib/hub-session/config.ts +0 -110
- package/templates/apps/web/lib/hub-session/entry.ts +0 -238
- package/templates/apps/web/lib/hub-session/index.ts +0 -21
- package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
- package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
- package/templates/apps/web/lib/hub-session/seal.ts +0 -86
- package/templates/apps/web/lib/hub-session/session.ts +0 -298
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
- package/templates/apps/web/lib/next-path.ts +0 -35
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The apple-touch-icon (#11244) — 180×180, drawn from the site's brand mark
|
|
3
|
+
* (`brand.logomark.light` in `content/_site.mdx`, else `/logomark.svg`) on
|
|
4
|
+
* the theme's bg, so every site has one. Next.js emits its
|
|
5
|
+
* `<link rel="apple-touch-icon">` in every page's head. It is what the
|
|
6
|
+
* `icon` share style previews with: Messages and Slack show the site icon,
|
|
7
|
+
* title and domain in place of an og:image.
|
|
8
|
+
*
|
|
9
|
+
* Satori reads inline styles only (the /og route's #6514 exception). The
|
|
10
|
+
* icon is rendered at build time, where `public/` is on disk; the /og route
|
|
11
|
+
* keeps its own copy of the mark read because it also fetches at request time.
|
|
12
|
+
*/
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
import { extname, resolve, sep } from "node:path";
|
|
15
|
+
|
|
16
|
+
import { BrandLogomarkSchema } from "@working-theory/site-config/schema";
|
|
17
|
+
import { tokens } from "@working-theory/theme";
|
|
18
|
+
import { ImageResponse } from "next/og";
|
|
19
|
+
|
|
20
|
+
import { SITE_LOGOMARK, SITE_NAME } from "../lib/site-brand";
|
|
21
|
+
|
|
22
|
+
export const size = { width: 180, height: 180 };
|
|
23
|
+
export const contentType = "image/png";
|
|
24
|
+
|
|
25
|
+
const MIME: Record<string, string> = {
|
|
26
|
+
".svg": "image/svg+xml",
|
|
27
|
+
".png": "image/png",
|
|
28
|
+
".jpg": "image/jpeg",
|
|
29
|
+
".jpeg": "image/jpeg",
|
|
30
|
+
".webp": "image/webp",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** The site's brand mark from `public/`, as a data URI. */
|
|
34
|
+
function markDataUri(): string | undefined {
|
|
35
|
+
try {
|
|
36
|
+
const src =
|
|
37
|
+
SITE_LOGOMARK === undefined ? "/logomark.svg" : BrandLogomarkSchema.parse(SITE_LOGOMARK).light;
|
|
38
|
+
const type = MIME[extname(src).toLowerCase()];
|
|
39
|
+
const root = resolve(process.cwd(), "public");
|
|
40
|
+
const file = resolve(root, `.${src}`);
|
|
41
|
+
if (type === undefined || !file.startsWith(root + sep)) return undefined;
|
|
42
|
+
return `data:${type};base64,${readFileSync(file).toString("base64")}`;
|
|
43
|
+
} catch {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default function AppleIcon(): ImageResponse {
|
|
49
|
+
const colors = tokens.colors.light;
|
|
50
|
+
const mark = markDataUri();
|
|
51
|
+
return new ImageResponse(
|
|
52
|
+
<div
|
|
53
|
+
style={{
|
|
54
|
+
display: "flex",
|
|
55
|
+
alignItems: "center",
|
|
56
|
+
justifyContent: "center",
|
|
57
|
+
width: "100%",
|
|
58
|
+
height: "100%",
|
|
59
|
+
backgroundColor: colors.bg,
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
{mark ? (
|
|
63
|
+
<img src={mark} alt="" width={128} height={128} />
|
|
64
|
+
) : (
|
|
65
|
+
<div style={{ color: colors.fg, fontSize: "96px", fontWeight: 700 }}>
|
|
66
|
+
{SITE_NAME.slice(0, 1).toUpperCase()}
|
|
67
|
+
</div>
|
|
68
|
+
)}
|
|
69
|
+
</div>,
|
|
70
|
+
size,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -3,30 +3,40 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* #10940 D3 —
|
|
7
|
-
*
|
|
6
|
+
* #10940 D3 — the llms route reads the site listing and skips `ThankYouPage`
|
|
7
|
+
* rows.
|
|
8
8
|
*
|
|
9
9
|
* AC-1: on a database-backed site each public page is listed once, at the
|
|
10
10
|
* route that serves it. AC-3: with the empty listing (the default dep) the
|
|
11
11
|
* output is today's convention listing, apart from the ThankYouPage skip.
|
|
12
|
+
*
|
|
13
|
+
* #11394 — this suite is a template file `create-ailk update` carries, so it
|
|
14
|
+
* runs only the route that serves GET /llms.txt, which update carries with
|
|
15
|
+
* it. The docs-blog variant (`lib/slices/docs-blog/llms-route.ts`) is that
|
|
16
|
+
* module's bundle file: update never moves it, so a site's copy is the one
|
|
17
|
+
* its bundle delivered and can predate the listing. Its own suite beside it
|
|
18
|
+
* pins the same cases in this repo.
|
|
12
19
|
*/
|
|
13
20
|
|
|
14
21
|
import type { ContentAdapter } from "@working-theory/content-adapters";
|
|
15
22
|
import type { SiteListing } from "@working-theory/page-renderer";
|
|
16
23
|
|
|
24
|
+
// The site's own flags and listing are per-site files (`create-ailk` writes
|
|
25
|
+
// the flags; the listing is site-owned): this suite tests a site with public
|
|
26
|
+
// pages and the empty listing, never the site's own values (#11246).
|
|
27
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: a per-site generated or site-owned file; this suite pins the value it tests (#11246)
|
|
28
|
+
jest.mock("../../../lib/modules.generated", () => ({
|
|
29
|
+
__esModule: true,
|
|
30
|
+
...jest.requireActual<object>("../../../lib/modules.generated"),
|
|
31
|
+
PUBLIC_PAGES: true,
|
|
32
|
+
}));
|
|
33
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: a per-site generated or site-owned file; this suite pins the value it tests (#11246)
|
|
34
|
+
jest.mock("../../../lib/site-listing", () => ({ __esModule: true, SITE_LISTING: {} }));
|
|
35
|
+
|
|
17
36
|
type Route = typeof import("../route");
|
|
18
37
|
|
|
19
38
|
const BASE = "https://example.com";
|
|
20
|
-
|
|
21
|
-
// docs-blog carries no copy — only the routes that resolve here are run (#11085).
|
|
22
|
-
const ROUTES = ["../route", "../../../lib/slices/docs-blog/llms-route"].filter((path) => {
|
|
23
|
-
try {
|
|
24
|
-
require.resolve(path);
|
|
25
|
-
return true;
|
|
26
|
-
} catch {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
39
|
+
const ROUTES = ["../route"];
|
|
30
40
|
|
|
31
41
|
const PUBLIC_ROWS: Record<string, Array<{ type: string; slug: string; title: string }>> = {
|
|
32
42
|
AboutPage: [{ type: "AboutPage", slug: "about", title: "About" }],
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`/og — the brand card (#11244) matches its snapshot 1`] = `"<div data-card="share" data-schema-type="AboutPage" style="display:flex;width:100%;height:100%;background-color:#ffffff;font-family:system-ui, -apple-system, sans-serif"><div style="display:flex;width:16px;height:100%;background-color:#0a0a0a"></div><div style="display:flex;flex-direction:column;justify-content:space-between;flex:1;padding:72px 80px"><div style="display:flex;align-items:center;gap:20px"><img src="data:image/svg+xml;base64,<mark>" alt="" width="64" height="64"/><div style="color:#030712;font-size:30px;font-weight:600">Northwind Studio</div></div><div style="display:flex;color:#030712;font-size:76px;font-weight:700;line-height:1.1;letter-spacing:-0.02em">About us</div><div style="color:#4a5565;font-size:26px">northwind.example</div></div></div>"`;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment node
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The `card` share style (#11244): /og draws a 1200×630 card from the site's
|
|
6
|
+
* brand — its mark (or photo), the page title set large, the site name and
|
|
7
|
+
* domain — in place of the plain brand-colour block it replaced. The
|
|
8
|
+
* snapshot pins the card's markup; the last case holds it apart from the
|
|
9
|
+
* plain block.
|
|
10
|
+
*/
|
|
11
|
+
import { mkdtempSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
|
|
15
|
+
import { tokens } from "@working-theory/theme";
|
|
16
|
+
import { ImageResponse } from "next/og";
|
|
17
|
+
import type { ReactElement } from "react";
|
|
18
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
19
|
+
|
|
20
|
+
// The site's brand comes from the env and `content/_site.mdx`, read at module
|
|
21
|
+
// load: set before the route is imported, with an empty content root.
|
|
22
|
+
const EMPTY_ROOT = mkdtempSync(join(tmpdir(), "og-card-empty-"));
|
|
23
|
+
process.env.NEXT_PUBLIC_SITE_NAME = "Northwind Studio";
|
|
24
|
+
process.env.NEXT_PUBLIC_BASE_URL = "https://northwind.example";
|
|
25
|
+
process.env.AILK_CONTENT_ROOT = EMPTY_ROOT;
|
|
26
|
+
|
|
27
|
+
jest.mock("next/og", () => ({
|
|
28
|
+
ImageResponse: jest.fn().mockImplementation(() => new Response("PNG", { status: 200 })),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
let GET: typeof import("../route").GET;
|
|
32
|
+
let appleIcon: typeof import("../../apple-icon");
|
|
33
|
+
beforeAll(async () => {
|
|
34
|
+
({ GET } = await import("../route"));
|
|
35
|
+
appleIcon = await import("../../apple-icon");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
async function cardFor(query: string): Promise<{ markup: string; options: unknown }> {
|
|
39
|
+
await GET(new Request(`https://example.com/og?${query}`));
|
|
40
|
+
const [tree, options] = jest.mocked(ImageResponse).mock.calls.at(-1)!;
|
|
41
|
+
return { markup: renderToStaticMarkup(tree as ReactElement), options };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
describe("/og — the brand card (#11244)", () => {
|
|
45
|
+
it("is 1200×630", async () => {
|
|
46
|
+
const { options } = await cardFor("title=About+us&schemaType=AboutPage");
|
|
47
|
+
expect(options).toMatchObject({ width: 1200, height: 630 });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("sets the page title large, with the site name, the domain and the brand mark", async () => {
|
|
51
|
+
const { markup } = await cardFor("title=About+us&schemaType=AboutPage");
|
|
52
|
+
expect(markup).toContain(">About us</div>");
|
|
53
|
+
expect(markup).toContain("font-size:76px");
|
|
54
|
+
expect(markup).toMatch(/<img src="data:image\/svg\+xml;base64,[^"]+"/);
|
|
55
|
+
expect(markup).toContain(">Northwind Studio</div>");
|
|
56
|
+
expect(markup).toContain(">northwind.example</div>");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("drops a long title to the smaller size", async () => {
|
|
60
|
+
const { markup } = await cardFor(`title=${"A".repeat(80)}`);
|
|
61
|
+
expect(markup).toContain("font-size:60px");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("matches its snapshot", async () => {
|
|
65
|
+
const { markup } = await cardFor("title=About+us&schemaType=AboutPage");
|
|
66
|
+
expect(markup.replace(/base64,[^"]+/, "base64,<mark>")).toMatchSnapshot();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("is no longer the plain block: text on the bg surface, not a brand-colour fill", async () => {
|
|
70
|
+
const { markup } = await cardFor("title=About+us&schemaType=AboutPage");
|
|
71
|
+
const plainBlock = `background-color:${tokens.colors.light.brand};padding:80px`;
|
|
72
|
+
expect(markup).not.toContain(plainBlock);
|
|
73
|
+
expect(markup).toMatch(new RegExp(`^<div[^>]*background-color:${tokens.colors.light.bg}`));
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("shows a Person site's photo in place of the mark", async () => {
|
|
77
|
+
const root = mkdtempSync(join(tmpdir(), "og-card-"));
|
|
78
|
+
writeFileSync(
|
|
79
|
+
join(root, "_site.mdx"),
|
|
80
|
+
"---\nsiteIdentity:\n kind: Person\n image: https://cdn.example/sam.jpg\n---\n",
|
|
81
|
+
);
|
|
82
|
+
const fetchSpy = jest
|
|
83
|
+
.spyOn(globalThis, "fetch")
|
|
84
|
+
.mockResolvedValue(new Response("JPG", { headers: { "content-type": "image/jpeg" } }));
|
|
85
|
+
process.env.AILK_CONTENT_ROOT = root;
|
|
86
|
+
try {
|
|
87
|
+
const { markup } = await cardFor("title=About+us");
|
|
88
|
+
expect(fetchSpy).toHaveBeenCalledWith("https://cdn.example/sam.jpg", expect.anything());
|
|
89
|
+
expect(markup).toContain(`src="data:image/jpeg;base64,${Buffer.from("JPG").toString("base64")}"`);
|
|
90
|
+
expect(markup).not.toContain("data:image/svg+xml");
|
|
91
|
+
} finally {
|
|
92
|
+
process.env.AILK_CONTENT_ROOT = EMPTY_ROOT;
|
|
93
|
+
fetchSpy.mockRestore();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("falls back to the mark when the photo cannot be fetched", async () => {
|
|
98
|
+
const root = mkdtempSync(join(tmpdir(), "og-card-"));
|
|
99
|
+
writeFileSync(
|
|
100
|
+
join(root, "_site.mdx"),
|
|
101
|
+
"---\nsiteIdentity:\n kind: Person\n image: https://cdn.example/sam.jpg\n---\n",
|
|
102
|
+
);
|
|
103
|
+
const fetchSpy = jest.spyOn(globalThis, "fetch").mockRejectedValue(new Error("timeout"));
|
|
104
|
+
process.env.AILK_CONTENT_ROOT = root;
|
|
105
|
+
try {
|
|
106
|
+
const { markup } = await cardFor("title=About+us");
|
|
107
|
+
expect(markup).toMatch(/<img src="data:image\/svg\+xml;base64,/);
|
|
108
|
+
} finally {
|
|
109
|
+
process.env.AILK_CONTENT_ROOT = EMPTY_ROOT;
|
|
110
|
+
fetchSpy.mockRestore();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("draws no image a query names", async () => {
|
|
115
|
+
const { markup } = await cardFor("title=T&photo=https%3A%2F%2Fevil.example%2Fx.png");
|
|
116
|
+
expect(markup).not.toContain("evil.example");
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("apple-icon — the 180×180 touch icon from the brand mark (#11244)", () => {
|
|
121
|
+
it("is a 180×180 PNG of the site's mark", () => {
|
|
122
|
+
expect(appleIcon.size).toEqual({ width: 180, height: 180 });
|
|
123
|
+
expect(appleIcon.contentType).toBe("image/png");
|
|
124
|
+
appleIcon.default();
|
|
125
|
+
const [tree, options] = jest.mocked(ImageResponse).mock.calls.at(-1)!;
|
|
126
|
+
expect(options).toEqual({ width: 180, height: 180 });
|
|
127
|
+
expect(renderToStaticMarkup(tree as ReactElement)).toMatch(/<img src="data:image\/svg\+xml;base64,/);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
@@ -12,12 +12,11 @@
|
|
|
12
12
|
* - Post-sanitization empty title triggers fallback (302 redirect to static PNG)
|
|
13
13
|
* - On ImageResponse throw, falls back via 302 redirect to /og-default.png
|
|
14
14
|
*
|
|
15
|
-
* Fallback is a 302 redirect to /og-default.png
|
|
15
|
+
* Fallback is a 302 redirect to /og-default.png.
|
|
16
16
|
* Per spec § 3: "redirecting is simpler but exposes the fallback URL; both acceptable."
|
|
17
17
|
*
|
|
18
|
-
* Note: next/og's ImageResponse
|
|
19
|
-
*
|
|
20
|
-
* spinning up an actual V8 isolate.
|
|
18
|
+
* Note: in tests next/og's ImageResponse is mocked to return a minimal
|
|
19
|
+
* Response, so the handler contract is verified without rasterising.
|
|
21
20
|
*/
|
|
22
21
|
|
|
23
22
|
// --- Mocks set up BEFORE imports ---
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Universal OG image route — /og?title=...&schemaType=...
|
|
3
3
|
*
|
|
4
|
+
* The `card` share style (#11244): a 1200×630 card built from the site's
|
|
5
|
+
* brand — its photo (a Person site's `siteIdentity.image`) or else its brand
|
|
6
|
+
* mark, the page title set large, and the site name and domain. It replaced
|
|
7
|
+
* the plain brand-colour block with the title on it.
|
|
8
|
+
*
|
|
4
9
|
* Design decisions (per spec § 3):
|
|
5
10
|
* - next/og ImageResponse at 1200×630 (Open Graph standard)
|
|
6
11
|
* - System sans-serif only — no .ttf fetches (the #1 source of OG bugs)
|
|
7
|
-
* -
|
|
12
|
+
* - Node.js runtime (#11244, was edge): the card reads the site's own name,
|
|
13
|
+
* photo and mark from `content/_site.mdx` and `public/`, which the edge
|
|
14
|
+
* runtime has no filesystem for. Only the title and type come from the
|
|
15
|
+
* query; no image URL does, so the route fetches nothing a link names —
|
|
16
|
+
* only the operator's own photo URL and its own origin's mark.
|
|
17
|
+
* - force-dynamic: the card is drawn from its query (#11239 — each page links
|
|
18
|
+
* /og?title=<page title>&schemaType=<type>); force-static handed the handler
|
|
19
|
+
* an empty query, so every page's card read the site name. Each distinct
|
|
20
|
+
* URL is cached for a day (CARD_CACHE_CONTROL) in place of ImageResponse's
|
|
21
|
+
* production default, max-age=0.
|
|
22
|
+
* - Text is fg on the bg surface; the brand fill is an accent rule only — the
|
|
23
|
+
* fills-only pairing.
|
|
8
24
|
* - Fallback strategy: on any ImageResponse throw, return a 302 redirect to
|
|
9
|
-
* /og-default.png (the static PNG in apps/web/public/).
|
|
10
|
-
* edge-compatible (no fs access needed) and exposing the fallback URL is
|
|
11
|
-
* acceptable per spec § 3 ("redirecting is simpler but exposes the fallback URL;
|
|
12
|
-
* both acceptable"). Chosen over stream-bytes because edge runtime has no fs.
|
|
25
|
+
* /og-default.png (the static PNG in apps/web/public/).
|
|
13
26
|
*
|
|
14
27
|
* Sanitization:
|
|
15
28
|
* - Strip control characters \x00–\x1F and \x7F from title and schemaType
|
|
@@ -22,124 +35,194 @@
|
|
|
22
35
|
* a JSX tree to PNG — it reads only inline styles, supports no stylesheet or
|
|
23
36
|
* Tailwind classes, and cannot render @working-theory/ui components.
|
|
24
37
|
*/
|
|
38
|
+
import { readFileSync } from "node:fs";
|
|
39
|
+
import { extname, join, resolve, sep } from "node:path";
|
|
40
|
+
|
|
25
41
|
import { clientError } from "@working-theory/page-renderer/edge";
|
|
42
|
+
import { BrandLogomarkSchema } from "@working-theory/site-config/schema";
|
|
26
43
|
import { tokens } from "@working-theory/theme";
|
|
27
44
|
import { ImageResponse } from "next/og";
|
|
45
|
+
import { parse as parseYaml } from "yaml";
|
|
46
|
+
|
|
47
|
+
import {
|
|
48
|
+
resolveContentRoot,
|
|
49
|
+
SITE_BASE_URL,
|
|
50
|
+
SITE_LOGOMARK,
|
|
51
|
+
SITE_NAME,
|
|
52
|
+
} from "../../lib/site-brand";
|
|
28
53
|
|
|
29
|
-
export const runtime = "
|
|
30
|
-
export const dynamic = "force-
|
|
54
|
+
export const runtime = "nodejs";
|
|
55
|
+
export const dynamic = "force-dynamic";
|
|
31
56
|
|
|
32
57
|
// Strips C0 control characters (U+0000–U+001F) and DEL (U+007F).
|
|
33
58
|
// eslint-disable-next-line no-control-regex
|
|
34
59
|
const CONTROL_CHAR_RE = new RegExp("[\u0000-\u001F\u007F]", "g");
|
|
35
60
|
|
|
36
61
|
const SYSTEM_FONT = "system-ui, -apple-system, sans-serif";
|
|
62
|
+
const CARD_CACHE_CONTROL = "public, max-age=86400, s-maxage=86400";
|
|
63
|
+
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
64
|
+
const MIME: Record<string, string> = {
|
|
65
|
+
".svg": "image/svg+xml",
|
|
66
|
+
".png": "image/png",
|
|
67
|
+
".jpg": "image/jpeg",
|
|
68
|
+
".jpeg": "image/jpeg",
|
|
69
|
+
".webp": "image/webp",
|
|
70
|
+
};
|
|
37
71
|
|
|
38
72
|
function sanitize(raw: string, cap: number): string {
|
|
39
73
|
return raw.replace(CONTROL_CHAR_RE, "").slice(0, cap);
|
|
40
74
|
}
|
|
41
75
|
|
|
42
76
|
function serveFallback(): Response {
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
// Using new Response + Location header instead of Response.redirect() because
|
|
46
|
-
// Response.redirect() requires an absolute URL in the Fetch API spec, but
|
|
47
|
-
// relative redirects work correctly in Next.js edge middleware at runtime.
|
|
77
|
+
// A relative Location: Response.redirect() needs an absolute URL, and the
|
|
78
|
+
// static PNG is served from /public on the request's own origin.
|
|
48
79
|
return new Response(null, {
|
|
49
80
|
status: 302,
|
|
50
81
|
headers: { Location: "/og-default.png" },
|
|
51
82
|
});
|
|
52
83
|
}
|
|
53
84
|
|
|
54
|
-
|
|
55
|
-
|
|
85
|
+
/** A Person site's photo — `siteIdentity.image`, an https URL — if it has one. */
|
|
86
|
+
function sitePhotoUrl(): string | undefined {
|
|
87
|
+
try {
|
|
88
|
+
const raw = readFileSync(join(resolveContentRoot(), "_site.mdx"), "utf8");
|
|
89
|
+
const parsed: unknown = parseYaml(FRONTMATTER_RE.exec(raw)?.[1] ?? "");
|
|
90
|
+
const identity = (parsed as { siteIdentity?: { kind?: unknown; image?: unknown } } | null)
|
|
91
|
+
?.siteIdentity;
|
|
92
|
+
const image = identity?.kind === "Person" ? identity.image : undefined;
|
|
93
|
+
return typeof image === "string" && /^https:\/\//.test(image) ? image : undefined;
|
|
94
|
+
} catch {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
56
98
|
|
|
57
|
-
|
|
58
|
-
|
|
99
|
+
/** The site's brand mark's path under `public/`: `brand.logomark.light`, else /logomark.svg. */
|
|
100
|
+
function siteMarkPath(): string | undefined {
|
|
101
|
+
try {
|
|
102
|
+
return SITE_LOGOMARK === undefined
|
|
103
|
+
? "/logomark.svg"
|
|
104
|
+
: BrandLogomarkSchema.parse(SITE_LOGOMARK).light;
|
|
105
|
+
} catch {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
59
109
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
110
|
+
/**
|
|
111
|
+
* An image as a data URI, read before the card renders: Satori fetches an
|
|
112
|
+
* `<img>` while the response streams, after this handler's try/catch, so a
|
|
113
|
+
* dead or slow image would break the card rather than drop out of it. A site
|
|
114
|
+
* path is read from `public/` (never outside it), else fetched from the
|
|
115
|
+
* site's own `SITE_BASE_URL` — never the request's Host, which the caller
|
|
116
|
+
* picks — since a serverless bundle may not carry `public/`. Any
|
|
117
|
+
* failure, or more than two seconds, is `undefined`.
|
|
118
|
+
*/
|
|
119
|
+
async function imageDataUri(src: string): Promise<string | undefined> {
|
|
120
|
+
if (src.startsWith("/") && !src.startsWith("//")) {
|
|
121
|
+
const type = MIME[extname(src).toLowerCase()];
|
|
122
|
+
if (type === undefined) return undefined;
|
|
123
|
+
const root = resolve(process.cwd(), "public");
|
|
124
|
+
const file = resolve(root, `.${src}`);
|
|
125
|
+
if (!file.startsWith(root + sep)) return undefined;
|
|
126
|
+
try {
|
|
127
|
+
return `data:${type};base64,${readFileSync(file).toString("base64")}`;
|
|
128
|
+
} catch {
|
|
129
|
+
return fetchDataUri(new URL(src, SITE_BASE_URL).href);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return /^https:\/\//.test(src) ? fetchDataUri(src) : undefined;
|
|
133
|
+
}
|
|
70
134
|
|
|
71
|
-
|
|
72
|
-
|
|
135
|
+
async function fetchDataUri(url: string): Promise<string | undefined> {
|
|
136
|
+
try {
|
|
137
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(2000) });
|
|
138
|
+
const type = res.headers.get("content-type")?.split(";")[0]?.trim() ?? "";
|
|
139
|
+
if (!res.ok || !Object.values(MIME).includes(type)) return undefined;
|
|
140
|
+
return `data:${type};base64,${Buffer.from(await res.arrayBuffer()).toString("base64")}`;
|
|
141
|
+
} catch {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function siteDomain(): string {
|
|
147
|
+
try {
|
|
148
|
+
return new URL(SITE_BASE_URL).host;
|
|
149
|
+
} catch {
|
|
150
|
+
return SITE_BASE_URL;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export async function GET(request: Request): Promise<Response> {
|
|
155
|
+
const { searchParams } = new URL(request.url);
|
|
156
|
+
|
|
157
|
+
const title = sanitize(searchParams.get("title") || SITE_NAME, 200);
|
|
158
|
+
const schemaType = sanitize(searchParams.get("schemaType") ?? "", 50);
|
|
73
159
|
|
|
74
160
|
// Post-sanitization empty title → fallback
|
|
75
161
|
if (!title) {
|
|
76
162
|
return serveFallback();
|
|
77
163
|
}
|
|
78
164
|
|
|
165
|
+
const colors = tokens.colors.light;
|
|
166
|
+
const photoUrl = sitePhotoUrl();
|
|
167
|
+
const photo = photoUrl === undefined ? undefined : await imageDataUri(photoUrl);
|
|
168
|
+
const markPath = photo === undefined ? siteMarkPath() : undefined;
|
|
169
|
+
const mark = markPath === undefined ? undefined : await imageDataUri(markPath);
|
|
170
|
+
|
|
79
171
|
try {
|
|
80
172
|
return new ImageResponse(
|
|
81
173
|
<div
|
|
174
|
+
data-card="share"
|
|
175
|
+
data-schema-type={schemaType || undefined}
|
|
82
176
|
style={{
|
|
83
177
|
display: "flex",
|
|
84
|
-
flexDirection: "column",
|
|
85
|
-
justifyContent: "center",
|
|
86
|
-
alignItems: "flex-start",
|
|
87
178
|
width: "100%",
|
|
88
179
|
height: "100%",
|
|
89
|
-
backgroundColor:
|
|
90
|
-
padding: "80px",
|
|
180
|
+
backgroundColor: colors.bg,
|
|
91
181
|
fontFamily: SYSTEM_FONT,
|
|
92
|
-
position: "relative",
|
|
93
182
|
}}
|
|
94
183
|
>
|
|
95
|
-
{
|
|
184
|
+
<div style={{ display: "flex", width: "16px", height: "100%", backgroundColor: colors.brand }} />
|
|
185
|
+
<div
|
|
186
|
+
style={{
|
|
187
|
+
display: "flex",
|
|
188
|
+
flexDirection: "column",
|
|
189
|
+
justifyContent: "space-between",
|
|
190
|
+
flex: 1,
|
|
191
|
+
padding: "72px 80px",
|
|
192
|
+
}}
|
|
193
|
+
>
|
|
194
|
+
<div style={{ display: "flex", alignItems: "center", gap: "20px" }}>
|
|
195
|
+
{mark ? <img src={mark} alt="" width={64} height={64} /> : null}
|
|
196
|
+
<div style={{ color: colors.fg, fontSize: "30px", fontWeight: 600 }}>{SITE_NAME}</div>
|
|
197
|
+
</div>
|
|
96
198
|
<div
|
|
97
199
|
style={{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
padding: "6px 18px",
|
|
105
|
-
fontSize: "18px",
|
|
106
|
-
fontFamily: SYSTEM_FONT,
|
|
200
|
+
display: "flex",
|
|
201
|
+
color: colors.fg,
|
|
202
|
+
fontSize: title.length > 60 ? "60px" : "76px",
|
|
203
|
+
fontWeight: 700,
|
|
204
|
+
lineHeight: 1.1,
|
|
205
|
+
letterSpacing: "-0.02em",
|
|
107
206
|
}}
|
|
108
207
|
>
|
|
109
|
-
{
|
|
208
|
+
{title}
|
|
110
209
|
</div>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<div
|
|
114
|
-
style={{
|
|
115
|
-
color: tokens.colors.light.fg,
|
|
116
|
-
fontSize: "56px",
|
|
117
|
-
fontWeight: 700,
|
|
118
|
-
lineHeight: 1.1,
|
|
119
|
-
maxWidth: "880px",
|
|
120
|
-
fontFamily: SYSTEM_FONT,
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
{title}
|
|
124
|
-
</div>
|
|
125
|
-
|
|
126
|
-
<div
|
|
127
|
-
style={{
|
|
128
|
-
position: "absolute",
|
|
129
|
-
bottom: "48px",
|
|
130
|
-
right: "48px",
|
|
131
|
-
color: tokens.colors.light.fg,
|
|
132
|
-
fontSize: "24px",
|
|
133
|
-
opacity: 0.75,
|
|
134
|
-
fontFamily: SYSTEM_FONT,
|
|
135
|
-
}}
|
|
136
|
-
>
|
|
137
|
-
{wordmark}
|
|
210
|
+
<div style={{ color: colors.textMuted, fontSize: "26px" }}>{siteDomain()}</div>
|
|
138
211
|
</div>
|
|
212
|
+
{photo ? (
|
|
213
|
+
<img
|
|
214
|
+
src={photo}
|
|
215
|
+
alt=""
|
|
216
|
+
width={420}
|
|
217
|
+
height={630}
|
|
218
|
+
style={{ width: "420px", height: "630px", objectFit: "cover" }}
|
|
219
|
+
/>
|
|
220
|
+
) : null}
|
|
139
221
|
</div>,
|
|
140
222
|
{
|
|
141
223
|
width: 1200,
|
|
142
224
|
height: 630,
|
|
225
|
+
headers: { "Cache-Control": CARD_CACHE_CONTROL },
|
|
143
226
|
},
|
|
144
227
|
);
|
|
145
228
|
} catch (err) {
|
|
@@ -12,6 +12,18 @@
|
|
|
12
12
|
import type { ContentAdapter } from "@working-theory/content-adapters";
|
|
13
13
|
import type { SiteListing } from "@working-theory/page-renderer";
|
|
14
14
|
|
|
15
|
+
// The site's own flags and listing are per-site files (`create-ailk` writes
|
|
16
|
+
// the flags; the listing is site-owned): this suite tests a site with public
|
|
17
|
+
// pages and the empty listing, never the site's own values (#11246).
|
|
18
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: a per-site generated or site-owned file; this suite pins the value it tests (#11246)
|
|
19
|
+
jest.mock("../../../lib/modules.generated", () => ({
|
|
20
|
+
__esModule: true,
|
|
21
|
+
...jest.requireActual<object>("../../../lib/modules.generated"),
|
|
22
|
+
PUBLIC_PAGES: true,
|
|
23
|
+
}));
|
|
24
|
+
// eslint-disable-next-line no-restricted-syntax -- #507: a per-site generated or site-owned file; this suite pins the value it tests (#11246)
|
|
25
|
+
jest.mock("../../../lib/site-listing", () => ({ __esModule: true, SITE_LISTING: {} }));
|
|
26
|
+
|
|
15
27
|
import { createSitemapHandler } from "../route";
|
|
16
28
|
|
|
17
29
|
const BASE = "https://example.com";
|