@makeswift/runtime 0.24.9-canary.1 → 0.24.9
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/dist/cjs/api/site-version/index.js +103 -0
- package/dist/cjs/api/site-version/index.js.map +1 -0
- package/dist/cjs/api-handler/cookies.js +38 -0
- package/dist/cjs/api-handler/cookies.js.map +1 -0
- package/dist/cjs/api-handler/cors.js +48 -0
- package/dist/cjs/api-handler/cors.js.map +1 -0
- package/dist/cjs/api-handler/handlers/element-tree.js +41 -0
- package/dist/cjs/api-handler/handlers/element-tree.js.map +1 -0
- package/dist/cjs/api-handler/handlers/fonts.js +33 -0
- package/dist/cjs/api-handler/handlers/fonts.js.map +1 -0
- package/dist/cjs/api-handler/handlers/manifest.js +49 -0
- package/dist/cjs/api-handler/handlers/manifest.js.map +1 -0
- package/dist/cjs/api-handler/handlers/merge-translated-data.js +41 -0
- package/dist/cjs/api-handler/handlers/merge-translated-data.js.map +1 -0
- package/dist/cjs/api-handler/handlers/redirect-live.js +52 -0
- package/dist/cjs/api-handler/handlers/redirect-live.js.map +1 -0
- package/dist/cjs/api-handler/handlers/revalidate.js +60 -0
- package/dist/cjs/api-handler/handlers/revalidate.js.map +1 -0
- package/dist/cjs/api-handler/handlers/translatable-data.js +42 -0
- package/dist/cjs/api-handler/handlers/translatable-data.js.map +1 -0
- package/dist/cjs/api-handler/handlers/webhook/index.js +51 -0
- package/dist/cjs/api-handler/handlers/webhook/index.js.map +1 -0
- package/dist/cjs/api-handler/handlers/webhook/site-published.js +37 -0
- package/dist/cjs/api-handler/handlers/webhook/site-published.js.map +1 -0
- package/dist/cjs/api-handler/handlers/webhook/types.js +46 -0
- package/dist/cjs/api-handler/handlers/webhook/types.js.map +1 -0
- package/dist/cjs/api-handler/index.js +117 -0
- package/dist/cjs/api-handler/index.js.map +1 -0
- package/dist/cjs/api-handler/node-request-response.js +99 -0
- package/dist/cjs/api-handler/node-request-response.js.map +1 -0
- package/dist/cjs/api-handler/preview.js +34 -0
- package/dist/cjs/api-handler/preview.js.map +1 -0
- package/dist/cjs/api-handler/request-response.js +52 -0
- package/dist/cjs/api-handler/request-response.js.map +1 -0
- package/dist/cjs/components/shared/react-player.js +41 -0
- package/dist/cjs/components/shared/react-player.js.map +1 -0
- package/dist/cjs/jest-setup.js +41 -0
- package/dist/cjs/jest-setup.js.map +1 -0
- package/dist/cjs/next/api-handler/app-router-handler.js +17 -0
- package/dist/cjs/next/api-handler/app-router-handler.js.map +1 -0
- package/dist/cjs/next/api-handler/config/app-router.js +63 -0
- package/dist/cjs/next/api-handler/config/app-router.js.map +1 -0
- package/dist/cjs/next/api-handler/config/base.js +39 -0
- package/dist/cjs/next/api-handler/config/base.js.map +1 -0
- package/dist/cjs/next/api-handler/config/pages-router.js +63 -0
- package/dist/cjs/next/api-handler/config/pages-router.js.map +1 -0
- package/dist/cjs/next/api-handler/handlers/app-router-redirect-preview.js +81 -0
- package/dist/cjs/next/api-handler/handlers/app-router-redirect-preview.js.map +1 -0
- package/dist/cjs/next/api-handler/handlers/clear-draft.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/element-tree.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/fonts.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/next/api-handler/handlers/manifest.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/merge-translated-data.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/pages-router-redirect-preview.js +68 -0
- package/dist/cjs/next/api-handler/handlers/pages-router-redirect-preview.js.map +1 -0
- package/dist/cjs/next/api-handler/handlers/redirect-draft.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/redirect-preview.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/revalidate.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/translatable-data.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/webhook/index.js.map +1 -1
- package/dist/cjs/next/api-handler/index.js +3 -2
- package/dist/cjs/next/api-handler/index.js.map +1 -1
- package/dist/cjs/next/api-handler/preview.js +43 -0
- package/dist/cjs/next/api-handler/preview.js.map +1 -0
- package/dist/cjs/next/app-router-site-version.js +47 -0
- package/dist/cjs/next/app-router-site-version.js.map +1 -0
- package/dist/cjs/next/components/framework-provider/app-router/HeadSnippet.js +43 -0
- package/dist/cjs/next/components/framework-provider/app-router/HeadSnippet.js.map +1 -0
- package/dist/cjs/next/components/framework-provider/app-router/index.js +36 -0
- package/dist/cjs/next/components/framework-provider/app-router/index.js.map +1 -0
- package/dist/cjs/next/components/framework-provider/index.js +64 -0
- package/dist/cjs/next/components/framework-provider/index.js.map +1 -0
- package/dist/cjs/next/components/framework-provider/link.js +69 -0
- package/dist/cjs/next/components/framework-provider/link.js.map +1 -0
- package/dist/cjs/next/components/framework-provider/pages-router/HeadSnippet.js +58 -0
- package/dist/cjs/next/components/framework-provider/pages-router/HeadSnippet.js.map +1 -0
- package/dist/cjs/next/components/framework-provider/pages-router/index.js +44 -0
- package/dist/cjs/next/components/framework-provider/pages-router/index.js.map +1 -0
- package/dist/cjs/next/components/tests/__fixtures__/element-data/box-component.js +124 -0
- package/dist/cjs/next/components/tests/__fixtures__/element-data/box-component.js.map +1 -0
- package/dist/cjs/next/components/tests/__fixtures__/element-data/button-component.js +109 -0
- package/dist/cjs/next/components/tests/__fixtures__/element-data/button-component.js.map +1 -0
- package/dist/cjs/next/components/tests/__fixtures__/element-data/image-component.js +193 -0
- package/dist/cjs/next/components/tests/__fixtures__/element-data/image-component.js.map +1 -0
- package/dist/cjs/next/components/tests/__fixtures__/page-document.js +46 -0
- package/dist/cjs/next/components/tests/__fixtures__/page-document.js.map +1 -0
- package/dist/cjs/next/components/tests/__fixtures__/resources/files.js +39 -0
- package/dist/cjs/next/components/tests/__fixtures__/resources/files.js.map +1 -0
- package/dist/cjs/next/components/tests/__fixtures__/resources/index.js +27 -0
- package/dist/cjs/next/components/tests/__fixtures__/resources/index.js.map +1 -0
- package/dist/cjs/next/components/tests/__fixtures__/resources/page-pathname-slices.js +33 -0
- package/dist/cjs/next/components/tests/__fixtures__/resources/page-pathname-slices.js.map +1 -0
- package/dist/cjs/next/components/tests/__fixtures__/resources/swatches.js +35 -0
- package/dist/cjs/next/components/tests/__fixtures__/resources/swatches.js.map +1 -0
- package/dist/cjs/next/hooks/use-router-locale-sync.js +49 -0
- package/dist/cjs/next/hooks/use-router-locale-sync.js.map +1 -0
- package/dist/cjs/next/runtime-provider.js +37 -0
- package/dist/cjs/next/runtime-provider.js.map +1 -0
- package/dist/cjs/next/testing/breakpoints.js +35 -0
- package/dist/cjs/next/testing/breakpoints.js.map +1 -0
- package/dist/cjs/next/testing/element-data.js +102 -0
- package/dist/cjs/next/testing/element-data.js.map +1 -0
- package/dist/cjs/next/testing/index.js +29 -0
- package/dist/cjs/next/testing/index.js.map +1 -0
- package/dist/cjs/next/testing/page-rendering.js +65 -0
- package/dist/cjs/next/testing/page-rendering.js.map +1 -0
- package/dist/cjs/next/testing/react-provider.js +40 -0
- package/dist/cjs/next/testing/react-provider.js.map +1 -0
- package/dist/cjs/next/tests/__fixtures__/element-tree.js +1776 -0
- package/dist/cjs/next/tests/__fixtures__/element-tree.js.map +1 -0
- package/dist/cjs/next/tests/__fixtures__/resources.js +99 -0
- package/dist/cjs/next/tests/__fixtures__/resources.js.map +1 -0
- package/dist/cjs/next/tests/__fixtures__/translated-data.js +83 -0
- package/dist/cjs/next/tests/__fixtures__/translated-data.js.map +1 -0
- package/dist/cjs/runtimes/react/components/MakeswiftComponent.js +51 -0
- package/dist/cjs/runtimes/react/components/MakeswiftComponent.js.map +1 -0
- package/dist/cjs/runtimes/react/components/Slot.js +38 -0
- package/dist/cjs/runtimes/react/components/Slot.js.map +1 -0
- package/dist/cjs/runtimes/react/components/SlotProvider.js +41 -0
- package/dist/cjs/runtimes/react/components/SlotProvider.js.map +1 -0
- package/dist/cjs/runtimes/react/components/framework-context.js +76 -0
- package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -0
- package/dist/cjs/runtimes/react/components/hooks/use-framework-context.js +33 -0
- package/dist/cjs/runtimes/react/components/hooks/use-framework-context.js.map +1 -0
- package/dist/cjs/runtimes/react/components/hooks/use-page-snippets.js +89 -0
- package/dist/cjs/runtimes/react/components/hooks/use-page-snippets.js.map +1 -0
- package/dist/cjs/runtimes/react/components/page/BodySnippet.js +65 -0
- package/dist/cjs/runtimes/react/components/page/BodySnippet.js.map +1 -0
- package/dist/cjs/runtimes/react/components/page/HeadSnippet.js +118 -0
- package/dist/cjs/runtimes/react/components/page/HeadSnippet.js.map +1 -0
- package/dist/cjs/runtimes/react/components/page/Page.js +44 -0
- package/dist/cjs/runtimes/react/components/page/Page.js.map +1 -0
- package/dist/cjs/runtimes/react/components/page/PageHead.js +121 -0
- package/dist/cjs/runtimes/react/components/page/PageHead.js.map +1 -0
- package/dist/cjs/runtimes/react/components/page/head-tags.js +52 -0
- package/dist/cjs/runtimes/react/components/page/head-tags.js.map +1 -0
- package/dist/cjs/runtimes/react/components/page/index.js +63 -0
- package/dist/cjs/runtimes/react/components/page/index.js.map +1 -0
- package/dist/cjs/runtimes/react/components/page/page-seo-settings.js +43 -0
- package/dist/cjs/runtimes/react/components/page/page-seo-settings.js.map +1 -0
- package/dist/cjs/runtimes/react/components/preview-switcher/preview-switcher.js +58 -0
- package/dist/cjs/runtimes/react/components/preview-switcher/preview-switcher.js.map +1 -0
- package/dist/cjs/runtimes/react/components/preview-switcher/preview-toolbar.js +87 -0
- package/dist/cjs/runtimes/react/components/preview-switcher/preview-toolbar.js.map +1 -0
- package/dist/cjs/runtimes/react/root-style-registry.js +105 -0
- package/dist/cjs/runtimes/react/root-style-registry.js.map +1 -0
- package/dist/cjs/state/toolkit.js +54 -0
- package/dist/cjs/state/toolkit.js.map +1 -0
- package/dist/cjs/testing/fixtures.js +38 -0
- package/dist/cjs/testing/fixtures.js.map +1 -0
- package/dist/cjs/utils/esm-compat.js +29 -0
- package/dist/cjs/utils/esm-compat.js.map +1 -0
- package/dist/esm/api/site-version/index.js +75 -0
- package/dist/esm/api/site-version/index.js.map +1 -0
- package/dist/esm/api-handler/cookies.js +13 -0
- package/dist/esm/api-handler/cookies.js.map +1 -0
- package/dist/esm/api-handler/cors.js +24 -0
- package/dist/esm/api-handler/cors.js.map +1 -0
- package/dist/esm/api-handler/handlers/element-tree.js +17 -0
- package/dist/esm/api-handler/handlers/element-tree.js.map +1 -0
- package/dist/esm/api-handler/handlers/fonts.js +9 -0
- package/dist/esm/api-handler/handlers/fonts.js.map +1 -0
- package/dist/esm/api-handler/handlers/manifest.js +28 -0
- package/dist/esm/api-handler/handlers/manifest.js.map +1 -0
- package/dist/esm/api-handler/handlers/merge-translated-data.js +17 -0
- package/dist/esm/api-handler/handlers/merge-translated-data.js.map +1 -0
- package/dist/esm/api-handler/handlers/redirect-live.js +27 -0
- package/dist/esm/api-handler/handlers/redirect-live.js.map +1 -0
- package/dist/esm/api-handler/handlers/revalidate.js +29 -0
- package/dist/esm/api-handler/handlers/revalidate.js.map +1 -0
- package/dist/esm/api-handler/handlers/translatable-data.js +18 -0
- package/dist/esm/api-handler/handlers/translatable-data.js.map +1 -0
- package/dist/esm/api-handler/handlers/webhook/index.js +30 -0
- package/dist/esm/api-handler/handlers/webhook/index.js.map +1 -0
- package/dist/esm/api-handler/handlers/webhook/site-published.js +13 -0
- package/dist/esm/api-handler/handlers/webhook/site-published.js.map +1 -0
- package/dist/esm/api-handler/handlers/webhook/types.js +21 -0
- package/dist/esm/api-handler/handlers/webhook/types.js.map +1 -0
- package/dist/esm/api-handler/index.js +96 -0
- package/dist/esm/api-handler/index.js.map +1 -0
- package/dist/esm/api-handler/node-request-response.js +73 -0
- package/dist/esm/api-handler/node-request-response.js.map +1 -0
- package/dist/esm/api-handler/preview.js +9 -0
- package/dist/esm/api-handler/preview.js.map +1 -0
- package/dist/esm/api-handler/request-response.js +27 -0
- package/dist/esm/api-handler/request-response.js.map +1 -0
- package/dist/esm/components/shared/react-player.js +7 -0
- package/dist/esm/components/shared/react-player.js.map +1 -0
- package/dist/esm/jest-setup.js +40 -0
- package/dist/esm/jest-setup.js.map +1 -0
- package/dist/esm/next/api-handler/app-router-handler.js +1 -0
- package/dist/esm/next/api-handler/app-router-handler.js.map +1 -0
- package/dist/esm/next/api-handler/config/app-router.js +38 -0
- package/dist/esm/next/api-handler/config/app-router.js.map +1 -0
- package/dist/esm/next/api-handler/config/base.js +15 -0
- package/dist/esm/next/api-handler/config/base.js.map +1 -0
- package/dist/esm/next/api-handler/config/pages-router.js +38 -0
- package/dist/esm/next/api-handler/config/pages-router.js.map +1 -0
- package/dist/esm/next/api-handler/handlers/app-router-redirect-preview.js +64 -0
- package/dist/esm/next/api-handler/handlers/app-router-redirect-preview.js.map +1 -0
- package/dist/esm/next/api-handler/handlers/clear-draft.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/element-tree.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/fonts.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/next/api-handler/handlers/manifest.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/merge-translated-data.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/pages-router-redirect-preview.js +52 -0
- package/dist/esm/next/api-handler/handlers/pages-router-redirect-preview.js.map +1 -0
- package/dist/esm/next/api-handler/handlers/redirect-draft.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/redirect-preview.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/revalidate.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/translatable-data.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/webhook/index.js.map +1 -1
- package/dist/esm/next/api-handler/index.js +3 -2
- package/dist/esm/next/api-handler/index.js.map +1 -1
- package/dist/esm/next/api-handler/preview.js +15 -0
- package/dist/esm/next/api-handler/preview.js.map +1 -0
- package/dist/esm/next/app-router-site-version.js +23 -0
- package/dist/esm/next/app-router-site-version.js.map +1 -0
- package/dist/esm/next/components/framework-provider/app-router/HeadSnippet.js +22 -0
- package/dist/esm/next/components/framework-provider/app-router/HeadSnippet.js.map +1 -0
- package/dist/esm/next/components/framework-provider/app-router/index.js +14 -0
- package/dist/esm/next/components/framework-provider/app-router/index.js.map +1 -0
- package/dist/esm/next/components/framework-provider/index.js +33 -0
- package/dist/esm/next/components/framework-provider/index.js.map +1 -0
- package/dist/esm/next/components/framework-provider/link.js +35 -0
- package/dist/esm/next/components/framework-provider/link.js.map +1 -0
- package/dist/esm/next/components/framework-provider/pages-router/HeadSnippet.js +28 -0
- package/dist/esm/next/components/framework-provider/pages-router/HeadSnippet.js.map +1 -0
- package/dist/esm/next/components/framework-provider/pages-router/index.js +10 -0
- package/dist/esm/next/components/framework-provider/pages-router/index.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/element-data/box-component.js +99 -0
- package/dist/esm/next/components/tests/__fixtures__/element-data/box-component.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/element-data/button-component.js +83 -0
- package/dist/esm/next/components/tests/__fixtures__/element-data/button-component.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/element-data/image-component.js +169 -0
- package/dist/esm/next/components/tests/__fixtures__/element-data/image-component.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/page-document.js +22 -0
- package/dist/esm/next/components/tests/__fixtures__/page-document.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/files.js +15 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/files.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/index.js +4 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/index.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/page-pathname-slices.js +9 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/page-pathname-slices.js.map +1 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/swatches.js +11 -0
- package/dist/esm/next/components/tests/__fixtures__/resources/swatches.js.map +1 -0
- package/dist/esm/next/hooks/use-router-locale-sync.js +25 -0
- package/dist/esm/next/hooks/use-router-locale-sync.js.map +1 -0
- package/dist/esm/next/runtime-provider.js +13 -0
- package/dist/esm/next/runtime-provider.js.map +1 -0
- package/dist/esm/next/testing/breakpoints.js +9 -0
- package/dist/esm/next/testing/breakpoints.js.map +1 -0
- package/dist/esm/next/testing/element-data.js +76 -0
- package/dist/esm/next/testing/element-data.js.map +1 -0
- package/dist/esm/next/testing/index.js +5 -0
- package/dist/esm/next/testing/index.js.map +1 -0
- package/dist/esm/next/testing/page-rendering.js +40 -0
- package/dist/esm/next/testing/page-rendering.js.map +1 -0
- package/dist/esm/next/testing/react-provider.js +16 -0
- package/dist/esm/next/testing/react-provider.js.map +1 -0
- package/dist/esm/next/tests/__fixtures__/element-tree.js +1752 -0
- package/dist/esm/next/tests/__fixtures__/element-tree.js.map +1 -0
- package/dist/esm/next/tests/__fixtures__/resources.js +69 -0
- package/dist/esm/next/tests/__fixtures__/resources.js.map +1 -0
- package/dist/esm/next/tests/__fixtures__/translated-data.js +59 -0
- package/dist/esm/next/tests/__fixtures__/translated-data.js.map +1 -0
- package/dist/esm/runtimes/react/components/MakeswiftComponent.js +29 -0
- package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +1 -0
- package/dist/esm/runtimes/react/components/Slot.js +14 -0
- package/dist/esm/runtimes/react/components/Slot.js.map +1 -0
- package/dist/esm/runtimes/react/components/SlotProvider.js +16 -0
- package/dist/esm/runtimes/react/components/SlotProvider.js.map +1 -0
- package/dist/esm/runtimes/react/components/framework-context.js +53 -0
- package/dist/esm/runtimes/react/components/framework-context.js.map +1 -0
- package/dist/esm/runtimes/react/components/hooks/use-framework-context.js +9 -0
- package/dist/esm/runtimes/react/components/hooks/use-framework-context.js.map +1 -0
- package/dist/esm/runtimes/react/components/hooks/use-page-snippets.js +55 -0
- package/dist/esm/runtimes/react/components/hooks/use-page-snippets.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/BodySnippet.js +41 -0
- package/dist/esm/runtimes/react/components/page/BodySnippet.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/HeadSnippet.js +80 -0
- package/dist/esm/runtimes/react/components/page/HeadSnippet.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/Page.js +20 -0
- package/dist/esm/runtimes/react/components/page/Page.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/PageHead.js +97 -0
- package/dist/esm/runtimes/react/components/page/PageHead.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/head-tags.js +25 -0
- package/dist/esm/runtimes/react/components/page/head-tags.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/index.js +41 -0
- package/dist/esm/runtimes/react/components/page/index.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/page-seo-settings.js +19 -0
- package/dist/esm/runtimes/react/components/page/page-seo-settings.js.map +1 -0
- package/dist/esm/runtimes/react/components/preview-switcher/preview-switcher.js +34 -0
- package/dist/esm/runtimes/react/components/preview-switcher/preview-switcher.js.map +1 -0
- package/dist/esm/runtimes/react/components/preview-switcher/preview-toolbar.js +63 -0
- package/dist/esm/runtimes/react/components/preview-switcher/preview-toolbar.js.map +1 -0
- package/dist/esm/runtimes/react/root-style-registry.js +66 -0
- package/dist/esm/runtimes/react/root-style-registry.js.map +1 -0
- package/dist/esm/state/toolkit.js +28 -0
- package/dist/esm/state/toolkit.js.map +1 -0
- package/dist/esm/testing/fixtures.js +13 -0
- package/dist/esm/testing/fixtures.js.map +1 -0
- package/dist/esm/utils/esm-compat.js +5 -0
- package/dist/esm/utils/esm-compat.js.map +1 -0
- package/dist/types/api/site-version/index.d.ts +19 -0
- package/dist/types/api/site-version/index.d.ts.map +1 -0
- package/dist/types/api/site-version/site-version.test.d.ts +2 -0
- package/dist/types/api/site-version/site-version.test.d.ts.map +1 -0
- package/dist/types/api-handler/cookies.d.ts +9 -0
- package/dist/types/api-handler/cookies.d.ts.map +1 -0
- package/dist/types/api-handler/cors.d.ts +10 -0
- package/dist/types/api-handler/cors.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/element-tree.d.ts +9 -0
- package/dist/types/api-handler/handlers/element-tree.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/fonts.d.ts +18 -0
- package/dist/types/api-handler/handlers/fonts.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/manifest.d.ts +18 -0
- package/dist/types/api-handler/handlers/manifest.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/merge-translated-data.d.ts +11 -0
- package/dist/types/api-handler/handlers/merge-translated-data.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/redirect-live.d.ts +6 -0
- package/dist/types/api-handler/handlers/redirect-live.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/revalidate.d.ts +10 -0
- package/dist/types/api-handler/handlers/revalidate.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/translatable-data.d.ts +15 -0
- package/dist/types/api-handler/handlers/translatable-data.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/webhook/index.d.ts +12 -0
- package/dist/types/api-handler/handlers/webhook/index.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/webhook/site-published.d.ts +8 -0
- package/dist/types/api-handler/handlers/webhook/site-published.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/webhook/types.d.ts +120 -0
- package/dist/types/api-handler/handlers/webhook/types.d.ts.map +1 -0
- package/dist/types/api-handler/index.d.ts +35 -0
- package/dist/types/api-handler/index.d.ts.map +1 -0
- package/dist/types/api-handler/node-request-response.d.ts +8 -0
- package/dist/types/api-handler/node-request-response.d.ts.map +1 -0
- package/dist/types/api-handler/node-request-response.test.d.ts +2 -0
- package/dist/types/api-handler/node-request-response.test.d.ts.map +1 -0
- package/dist/types/api-handler/preview.d.ts +5 -0
- package/dist/types/api-handler/preview.d.ts.map +1 -0
- package/dist/types/api-handler/request-response.d.ts +13 -0
- package/dist/types/api-handler/request-response.d.ts.map +1 -0
- package/dist/types/components/shared/react-player.d.ts +3 -0
- package/dist/types/components/shared/react-player.d.ts.map +1 -0
- package/dist/types/next/api-handler/app-router-handler.d.ts +8 -0
- package/dist/types/next/api-handler/app-router-handler.d.ts.map +1 -0
- package/dist/types/next/api-handler/config/app-router.d.ts +18 -0
- package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -0
- package/dist/types/next/api-handler/config/base.d.ts +15 -0
- package/dist/types/next/api-handler/config/base.d.ts.map +1 -0
- package/dist/types/next/api-handler/config/pages-router.d.ts +11 -0
- package/dist/types/next/api-handler/config/pages-router.d.ts.map +1 -0
- package/dist/types/next/api-handler/handlers/app-router-redirect-preview.d.ts +5 -0
- package/dist/types/next/api-handler/handlers/app-router-redirect-preview.d.ts.map +1 -0
- package/dist/types/next/api-handler/handlers/app-router-redirect-preview.test.d.ts +2 -0
- package/dist/types/next/api-handler/handlers/app-router-redirect-preview.test.d.ts.map +1 -0
- package/dist/types/next/api-handler/handlers/clear-draft.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/clear-draft.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/element-tree.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/element-tree.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/fonts.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/fonts.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/manifest.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/manifest.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/merge-translated-data.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/merge-translated-data.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/pages-router-redirect-preview.d.ts +4 -0
- package/dist/types/next/api-handler/handlers/pages-router-redirect-preview.d.ts.map +1 -0
- package/dist/types/next/api-handler/handlers/redirect-draft.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/redirect-draft.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/redirect-preview.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/redirect-preview.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/revalidate.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/revalidate.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/translatable-data.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/translatable-data.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/webhook/index.d.ts +1 -5
- package/dist/types/next/api-handler/handlers/webhook/index.d.ts.map +1 -1
- package/dist/types/next/api-handler/index.d.ts +2 -6
- package/dist/types/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/next/api-handler/preview.d.ts +8 -0
- package/dist/types/next/api-handler/preview.d.ts.map +1 -0
- package/dist/types/next/app-router-site-version.d.ts +3 -0
- package/dist/types/next/app-router-site-version.d.ts.map +1 -0
- package/dist/types/next/components/framework-provider/app-router/HeadSnippet.d.ts +5 -0
- package/dist/types/next/components/framework-provider/app-router/HeadSnippet.d.ts.map +1 -0
- package/dist/types/next/components/framework-provider/app-router/index.d.ts +3 -0
- package/dist/types/next/components/framework-provider/app-router/index.d.ts.map +1 -0
- package/dist/types/next/components/framework-provider/index.d.ts +5 -0
- package/dist/types/next/components/framework-provider/index.d.ts.map +1 -0
- package/dist/types/next/components/framework-provider/link.d.ts +2 -0
- package/dist/types/next/components/framework-provider/link.d.ts.map +1 -0
- package/dist/types/next/components/framework-provider/pages-router/HeadSnippet.d.ts +5 -0
- package/dist/types/next/components/framework-provider/pages-router/HeadSnippet.d.ts.map +1 -0
- package/dist/types/next/components/framework-provider/pages-router/index.d.ts +3 -0
- package/dist/types/next/components/framework-provider/pages-router/index.d.ts.map +1 -0
- package/dist/types/next/components/tests/__fixtures__/element-data/box-component.d.ts +8 -0
- package/dist/types/next/components/tests/__fixtures__/element-data/box-component.d.ts.map +1 -0
- package/dist/types/next/components/tests/__fixtures__/element-data/button-component.d.ts +9 -0
- package/dist/types/next/components/tests/__fixtures__/element-data/button-component.d.ts.map +1 -0
- package/dist/types/next/components/tests/__fixtures__/element-data/image-component.d.ts +7 -0
- package/dist/types/next/components/tests/__fixtures__/element-data/image-component.d.ts.map +1 -0
- package/dist/types/next/components/tests/__fixtures__/page-document.d.ts +3 -0
- package/dist/types/next/components/tests/__fixtures__/page-document.d.ts.map +1 -0
- package/dist/types/next/components/tests/__fixtures__/resources/files.d.ts +3 -0
- package/dist/types/next/components/tests/__fixtures__/resources/files.d.ts.map +1 -0
- package/dist/types/next/components/tests/__fixtures__/resources/index.d.ts +4 -0
- package/dist/types/next/components/tests/__fixtures__/resources/index.d.ts.map +1 -0
- package/dist/types/next/components/tests/__fixtures__/resources/page-pathname-slices.d.ts +3 -0
- package/dist/types/next/components/tests/__fixtures__/resources/page-pathname-slices.d.ts.map +1 -0
- package/dist/types/next/components/tests/__fixtures__/resources/swatches.d.ts +3 -0
- package/dist/types/next/components/tests/__fixtures__/resources/swatches.d.ts.map +1 -0
- package/dist/types/next/components/tests/components/box-component-rendering.test.d.ts +3 -0
- package/dist/types/next/components/tests/components/box-component-rendering.test.d.ts.map +1 -0
- package/dist/types/next/components/tests/components/button-component-rendering.test.d.ts +3 -0
- package/dist/types/next/components/tests/components/button-component-rendering.test.d.ts.map +1 -0
- package/dist/types/next/components/tests/components/image-component-rendering.test.d.ts +3 -0
- package/dist/types/next/components/tests/components/image-component-rendering.test.d.ts.map +1 -0
- package/dist/types/next/components/tests/makeswift-page-snippets-rendering.test.d.ts +3 -0
- package/dist/types/next/components/tests/makeswift-page-snippets-rendering.test.d.ts.map +1 -0
- package/dist/types/next/hooks/use-router-locale-sync.d.ts +2 -0
- package/dist/types/next/hooks/use-router-locale-sync.d.ts.map +1 -0
- package/dist/types/next/runtime-provider.d.ts +4 -0
- package/dist/types/next/runtime-provider.d.ts.map +1 -0
- package/dist/types/next/testing/breakpoints.d.ts +4 -0
- package/dist/types/next/testing/breakpoints.d.ts.map +1 -0
- package/dist/types/next/testing/element-data.d.ts +55 -0
- package/dist/types/next/testing/element-data.d.ts.map +1 -0
- package/dist/types/next/testing/index.d.ts +5 -0
- package/dist/types/next/testing/index.d.ts.map +1 -0
- package/dist/types/next/testing/page-rendering.d.ts +10 -0
- package/dist/types/next/testing/page-rendering.d.ts.map +1 -0
- package/dist/types/next/testing/react-provider.d.ts +9 -0
- package/dist/types/next/testing/react-provider.d.ts.map +1 -0
- package/dist/types/next/tests/__fixtures__/element-tree.d.ts +3 -0
- package/dist/types/next/tests/__fixtures__/element-tree.d.ts.map +1 -0
- package/dist/types/next/tests/__fixtures__/resources.d.ts +9 -0
- package/dist/types/next/tests/__fixtures__/resources.d.ts.map +1 -0
- package/dist/types/next/tests/__fixtures__/translated-data.d.ts +56 -0
- package/dist/types/next/tests/__fixtures__/translated-data.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-app-router-redirect-preview.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-app-router-redirect-preview.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-cors.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-cors.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-element-tree.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-element-tree.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-error-handling.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-error-handling.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-fonts.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-fonts.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-manifest.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-manifest.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-merge-translated-data.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-merge-translated-data.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-pages-router-redirect-preview.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-pages-router-redirect-preview.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-redirect-live.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-redirect-live.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-resources.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-resources.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-revalidate.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-revalidate.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-translatable-data.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-translatable-data.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-webhook.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-webhook.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/__tests__/react-runtime.test.d.ts +2 -0
- package/dist/types/runtimes/react/__tests__/react-runtime.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/MakeswiftComponent.d.ts +10 -0
- package/dist/types/runtimes/react/components/MakeswiftComponent.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/Slot.d.ts +10 -0
- package/dist/types/runtimes/react/components/Slot.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/SlotProvider.d.ts +11 -0
- package/dist/types/runtimes/react/components/SlotProvider.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/framework-context.d.ts +42 -0
- package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/hooks/use-framework-context.d.ts +3 -0
- package/dist/types/runtimes/react/components/hooks/use-framework-context.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/hooks/use-page-snippets.d.ts +8 -0
- package/dist/types/runtimes/react/components/hooks/use-page-snippets.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/page/BodySnippet.d.ts +7 -0
- package/dist/types/runtimes/react/components/page/BodySnippet.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/page/HeadSnippet.d.ts +9 -0
- package/dist/types/runtimes/react/components/page/HeadSnippet.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/page/Page.d.ts +11 -0
- package/dist/types/runtimes/react/components/page/Page.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/page/PageHead.d.ts +9 -0
- package/dist/types/runtimes/react/components/page/PageHead.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/page/head-tags.d.ts +19 -0
- package/dist/types/runtimes/react/components/page/head-tags.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/page/index.d.ts +28 -0
- package/dist/types/runtimes/react/components/page/index.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/page/page-seo-settings.d.ts +11 -0
- package/dist/types/runtimes/react/components/page/page-seo-settings.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/preview-switcher/preview-switcher.d.ts +4 -0
- package/dist/types/runtimes/react/components/preview-switcher/preview-switcher.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/preview-switcher/preview-toolbar.d.ts +2 -0
- package/dist/types/runtimes/react/components/preview-switcher/preview-toolbar.d.ts.map +1 -0
- package/dist/types/runtimes/react/root-style-registry.d.ts +42 -0
- package/dist/types/runtimes/react/root-style-registry.d.ts.map +1 -0
- package/dist/types/state/__tests__/actions.test.d.ts +2 -0
- package/dist/types/state/__tests__/actions.test.d.ts.map +1 -0
- package/dist/types/state/toolkit.d.ts +11 -0
- package/dist/types/state/toolkit.d.ts.map +1 -0
- package/dist/types/testing/fixtures.d.ts +7 -0
- package/dist/types/testing/fixtures.d.ts.map +1 -0
- package/dist/types/utils/esm-compat.d.ts +2 -0
- package/dist/types/utils/esm-compat.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var base_exports = {};
|
|
20
|
+
__export(base_exports, {
|
|
21
|
+
validateApiRoute: () => validateApiRoute
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(base_exports);
|
|
24
|
+
function validateApiRoute(params) {
|
|
25
|
+
const { makeswift } = params;
|
|
26
|
+
if (!Array.isArray(makeswift)) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`The Makeswift Next.js API handler must be used in a dynamic catch-all route named \`[...makeswift]\`.
|
|
29
|
+
Received "${makeswift}" for the \`makeswift\` param instead.
|
|
30
|
+
Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return "/" + makeswift.join("/");
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
validateApiRoute
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/config/base.ts"],"sourcesContent":["import { type ApiHandlerInternalConfig } from '../../../api-handler'\nimport { type ApiRequest, type ApiResponse } from '../../../api-handler/request-response'\n\nexport type ApiHandlerConfig = Omit<ApiHandlerInternalConfig, 'client' | 'revalidationHandler'> & {\n req: ApiRequest\n route: string\n sendResponse: (res: ApiResponse) => Promise<Response | void>\n revalidationHandler: (path?: string) => Promise<void>\n customRoutes: (route: string) => Promise<{ res: Response | void } | null>\n}\n\nexport function validateApiRoute(params: Partial<{ [key: string]: string | string[] }>): string {\n const { makeswift } = params\n\n if (!Array.isArray(makeswift)) {\n throw new Error(\n 'The Makeswift Next.js API handler must be used in a dynamic catch-all route named `[...makeswift]`.\\n' +\n `Received \"${makeswift}\" for the \\`makeswift\\` param instead.\\n` +\n 'Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes',\n )\n }\n\n return '/' + makeswift.join('/')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,iBAAiB,QAA+D;AAC9F,QAAM,EAAE,UAAU,IAAI;AAEtB,MAAI,CAAC,MAAM,QAAQ,SAAS,GAAG;AAC7B,UAAM,IAAI;AAAA,MACR;AAAA,YACe,SAAS;AAAA;AAAA,IAE1B;AAAA,EACF;AAEA,SAAO,MAAM,UAAU,KAAK,GAAG;AACjC;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pages_router_exports = {};
|
|
20
|
+
__export(pages_router_exports, {
|
|
21
|
+
argsPattern: () => argsPattern,
|
|
22
|
+
config: () => config
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(pages_router_exports);
|
|
25
|
+
var import_ts_pattern = require("ts-pattern");
|
|
26
|
+
var import_node_request_response = require("../../../api-handler/node-request-response");
|
|
27
|
+
var import_pages_router_redirect_preview = require("../handlers/pages-router-redirect-preview");
|
|
28
|
+
var import_preview = require("../preview");
|
|
29
|
+
var import_base = require("./base");
|
|
30
|
+
const argsPattern = [import_ts_pattern.P.any, import_ts_pattern.P.any];
|
|
31
|
+
async function config({
|
|
32
|
+
req,
|
|
33
|
+
res,
|
|
34
|
+
client
|
|
35
|
+
}) {
|
|
36
|
+
return {
|
|
37
|
+
req: (0, import_node_request_response.toApiRequest)(req),
|
|
38
|
+
route: (0, import_base.validateApiRoute)(await apiRequestParams(req)),
|
|
39
|
+
previewCookieNames: [import_preview.PRERENDER_BYPASS_COOKIE, import_preview.PREVIEW_DATA_COOKIE],
|
|
40
|
+
sendResponse: (apiResponse) => (0, import_node_request_response.pipeResponseTo)(apiResponse, res),
|
|
41
|
+
revalidationHandler: async (path) => {
|
|
42
|
+
if (path != null) {
|
|
43
|
+
res.revalidate(path);
|
|
44
|
+
} else {
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
customRoutes: async (route) => {
|
|
48
|
+
if (route === "/redirect-preview") {
|
|
49
|
+
return { res: await (0, import_pages_router_redirect_preview.pagesRouterRedirectPreviewHandler)(req, res, client) };
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function apiRequestParams(request) {
|
|
56
|
+
return Promise.resolve(request.query);
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
argsPattern,
|
|
61
|
+
config
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=pages-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/config/pages-router.ts"],"sourcesContent":["import { P } from 'ts-pattern'\nimport { NextApiRequest, NextApiResponse } from 'next'\n\nimport { type ApiResponse } from '../../../api-handler/request-response'\nimport { toApiRequest, pipeResponseTo } from '../../../api-handler/node-request-response'\n\nimport { pagesRouterRedirectPreviewHandler } from '../handlers/pages-router-redirect-preview'\nimport { PRERENDER_BYPASS_COOKIE, PREVIEW_DATA_COOKIE } from '../preview'\n\nimport { validateApiRoute, type ApiHandlerConfig } from './base'\nimport { MakeswiftClient } from '../../../client'\n\nexport type ApiHandlerArgs = [NextApiRequest, NextApiResponse]\nexport const argsPattern = [P.any, P.any] as const\n\nexport async function config({\n req,\n res,\n client,\n}: {\n req: NextApiRequest\n res: NextApiResponse\n client: MakeswiftClient\n}): Promise<ApiHandlerConfig> {\n return {\n req: toApiRequest(req),\n route: validateApiRoute(await apiRequestParams(req)),\n previewCookieNames: [PRERENDER_BYPASS_COOKIE, PREVIEW_DATA_COOKIE],\n\n sendResponse: (apiResponse: ApiResponse): Promise<Response | void> =>\n pipeResponseTo(apiResponse, res),\n\n revalidationHandler: async (path?: string): Promise<void> => {\n if (path != null) {\n res.revalidate(path)\n } else {\n // No-op, Pages Router does not support tag-based revalidation\n }\n },\n\n customRoutes: async (route: string) => {\n if (route === '/redirect-preview') {\n return { res: await pagesRouterRedirectPreviewHandler(req, res, client) }\n }\n\n return null\n },\n }\n}\n\nfunction apiRequestParams(request: NextApiRequest): Promise<NextApiRequest['query']> {\n // `NextApiRequest.query` prop became async in Next.js 15, but it's not reflected in the type definition;\n // force-casting it to a `Promise` manually\n return Promise.resolve(request.query)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAkB;AAIlB,mCAA6C;AAE7C,2CAAkD;AAClD,qBAA6D;AAE7D,kBAAwD;AAIjD,MAAM,cAAc,CAAC,oBAAE,KAAK,oBAAE,GAAG;AAExC,eAAsB,OAAO;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACF,GAI8B;AAC5B,SAAO;AAAA,IACL,SAAK,2CAAa,GAAG;AAAA,IACrB,WAAO,8BAAiB,MAAM,iBAAiB,GAAG,CAAC;AAAA,IACnD,oBAAoB,CAAC,wCAAyB,kCAAmB;AAAA,IAEjE,cAAc,CAAC,oBACb,6CAAe,aAAa,GAAG;AAAA,IAEjC,qBAAqB,OAAO,SAAiC;AAC3D,UAAI,QAAQ,MAAM;AAChB,YAAI,WAAW,IAAI;AAAA,MACrB,OAAO;AAAA,MAEP;AAAA,IACF;AAAA,IAEA,cAAc,OAAO,UAAkB;AACrC,UAAI,UAAU,qBAAqB;AACjC,eAAO,EAAE,KAAK,UAAM,wEAAkC,KAAK,KAAK,MAAM,EAAE;AAAA,MAC1E;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,SAAS,iBAAiB,SAA2D;AAGnF,SAAO,QAAQ,QAAQ,QAAQ,KAAK;AACtC;","names":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var app_router_redirect_preview_exports = {};
|
|
20
|
+
__export(app_router_redirect_preview_exports, {
|
|
21
|
+
appRouterRedirectPreviewHandler: () => appRouterRedirectPreviewHandler,
|
|
22
|
+
originalRequestProtocol: () => originalRequestProtocol
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(app_router_redirect_preview_exports);
|
|
25
|
+
var import_server = require("next/server");
|
|
26
|
+
var import_headers = require("next/headers");
|
|
27
|
+
var import_cookie = require("cookie");
|
|
28
|
+
var import_cookies = require("../../../api-handler/cookies");
|
|
29
|
+
var import_site_version = require("../../../api/site-version");
|
|
30
|
+
var import_preview = require("../preview");
|
|
31
|
+
function originalRequestProtocol(request) {
|
|
32
|
+
const forwardedProto = request.headers.get("x-forwarded-proto");
|
|
33
|
+
return forwardedProto != null ? forwardedProto.split(",")[0].trim() : null;
|
|
34
|
+
}
|
|
35
|
+
async function appRouterRedirectPreviewHandler(request, _context, client) {
|
|
36
|
+
const previewToken = request.nextUrl.searchParams.get(import_preview.SearchParams.PreviewToken);
|
|
37
|
+
if (previewToken == null) {
|
|
38
|
+
return new import_server.NextResponse("Bad request: no preview token provided", { status: 400 });
|
|
39
|
+
}
|
|
40
|
+
const verificationResult = await client.readPreviewToken(previewToken);
|
|
41
|
+
if (verificationResult == null) {
|
|
42
|
+
return new import_server.NextResponse("Failed to verify preview token", { status: 401 });
|
|
43
|
+
}
|
|
44
|
+
const { payload } = verificationResult;
|
|
45
|
+
const draft = await (0, import_headers.draftMode)();
|
|
46
|
+
const cookieStore = await (0, import_headers.cookies)();
|
|
47
|
+
draft.enable();
|
|
48
|
+
const prerenderBypassCookie = cookieStore.get(import_preview.PRERENDER_BYPASS_COOKIE);
|
|
49
|
+
if (prerenderBypassCookie?.value == null) {
|
|
50
|
+
return new import_server.NextResponse("Could not retrieve draft mode bypass cookie", { status: 500 });
|
|
51
|
+
}
|
|
52
|
+
const siteVersion = { version: payload.version, token: previewToken };
|
|
53
|
+
const serializedSiteVersion = (0, import_site_version.serializeSiteVersion)(siteVersion);
|
|
54
|
+
const secondsUntilExpiration = (0, import_site_version.secondsUntilSiteVersionExpiration)(siteVersion);
|
|
55
|
+
const draftCookies = [
|
|
56
|
+
prerenderBypassCookie,
|
|
57
|
+
{ name: import_preview.MAKESWIFT_SITE_VERSION_COOKIE, value: serializedSiteVersion }
|
|
58
|
+
];
|
|
59
|
+
const redirectProtocol = originalRequestProtocol(request) ?? request.nextUrl.protocol.replace(":", "");
|
|
60
|
+
const redirectHost = request.headers.get("x-forwarded-host") ?? request.headers.get("host") ?? request.nextUrl.host;
|
|
61
|
+
const redirectUrl = new URL(
|
|
62
|
+
`${redirectProtocol}://${redirectHost}${request.nextUrl.pathname}${request.nextUrl.search}`
|
|
63
|
+
);
|
|
64
|
+
redirectUrl.searchParams.delete(import_preview.SearchParams.PreviewToken);
|
|
65
|
+
redirectUrl.searchParams.delete(import_preview.RewriteRuleMatches.PreviewToken);
|
|
66
|
+
redirectUrl.searchParams.delete(import_preview.RewriteRuleMatches.OriginalPath);
|
|
67
|
+
const headers = new Headers();
|
|
68
|
+
draftCookies.forEach(({ name, value }) => {
|
|
69
|
+
headers.append(
|
|
70
|
+
import_cookies.SET_COOKIE_HEADER,
|
|
71
|
+
(0, import_cookie.serialize)(name, value, { ...import_cookies.cookieSettingOptions, maxAge: secondsUntilExpiration })
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
return import_server.NextResponse.redirect(redirectUrl, { headers });
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
appRouterRedirectPreviewHandler,
|
|
79
|
+
originalRequestProtocol
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=app-router-redirect-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/app-router-redirect-preview.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server'\nimport { cookies, draftMode } from 'next/headers'\n\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { cookieSettingOptions, SET_COOKIE_HEADER } from '../../../api-handler/cookies'\nimport {\n secondsUntilSiteVersionExpiration,\n serializeSiteVersion,\n type SiteVersion,\n} from '../../../api/site-version'\n\nimport {\n MAKESWIFT_SITE_VERSION_COOKIE,\n PRERENDER_BYPASS_COOKIE,\n RewriteRuleMatches,\n SearchParams,\n} from '../preview'\nimport { MakeswiftClient } from '../../../client'\n\nexport function originalRequestProtocol(request: NextRequest): string | null {\n // The `x-forwarded-proto` header is not formally standardized, but many proxies\n // *append* the protocol used for the request to the existing value. As a result,\n // if the request passes through multiple proxies, the header may contain a\n // comma-separated list of protocols: https://code.djangoproject.com/ticket/33569\n const forwardedProto = request.headers.get('x-forwarded-proto')\n return forwardedProto != null ? forwardedProto.split(',')[0].trim() : null\n}\n\nexport async function appRouterRedirectPreviewHandler(\n request: NextRequest,\n _context: any,\n client: MakeswiftClient,\n): Promise<NextResponse> {\n const previewToken = request.nextUrl.searchParams.get(SearchParams.PreviewToken)\n\n if (previewToken == null) {\n return new NextResponse('Bad request: no preview token provided', { status: 400 })\n }\n\n const verificationResult = await client.readPreviewToken(previewToken)\n\n if (verificationResult == null) {\n return new NextResponse('Failed to verify preview token', { status: 401 })\n }\n\n const { payload } = verificationResult\n\n const draft = await draftMode()\n const cookieStore = await cookies()\n\n draft.enable()\n\n const prerenderBypassCookie = cookieStore.get(PRERENDER_BYPASS_COOKIE)\n\n if (prerenderBypassCookie?.value == null) {\n return new NextResponse('Could not retrieve draft mode bypass cookie', { status: 500 })\n }\n\n const siteVersion: SiteVersion = { version: payload.version, token: previewToken }\n const serializedSiteVersion = serializeSiteVersion(siteVersion)\n const secondsUntilExpiration = secondsUntilSiteVersionExpiration(siteVersion)\n\n const draftCookies: { name: string; value: string }[] = [\n prerenderBypassCookie,\n { name: MAKESWIFT_SITE_VERSION_COOKIE, value: serializedSiteVersion },\n ]\n\n const redirectProtocol =\n originalRequestProtocol(request) ?? request.nextUrl.protocol.replace(':', '')\n\n const redirectHost =\n request.headers.get('x-forwarded-host') ?? request.headers.get('host') ?? request.nextUrl.host\n\n const redirectUrl = new URL(\n `${redirectProtocol}://${redirectHost}${request.nextUrl.pathname}${request.nextUrl.search}`,\n )\n\n redirectUrl.searchParams.delete(SearchParams.PreviewToken)\n redirectUrl.searchParams.delete(RewriteRuleMatches.PreviewToken)\n redirectUrl.searchParams.delete(RewriteRuleMatches.OriginalPath)\n\n const headers = new Headers()\n draftCookies.forEach(({ name, value }) => {\n headers.append(\n SET_COOKIE_HEADER,\n serializeCookie(name, value, { ...cookieSettingOptions, maxAge: secondsUntilExpiration }),\n )\n })\n\n return NextResponse.redirect(redirectUrl, { headers })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0C;AAC1C,qBAAmC;AAEnC,oBAA6C;AAE7C,qBAAwD;AACxD,0BAIO;AAEP,qBAKO;AAGA,SAAS,wBAAwB,SAAqC;AAK3E,QAAM,iBAAiB,QAAQ,QAAQ,IAAI,mBAAmB;AAC9D,SAAO,kBAAkB,OAAO,eAAe,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,IAAI;AACxE;AAEA,eAAsB,gCACpB,SACA,UACA,QACuB;AACvB,QAAM,eAAe,QAAQ,QAAQ,aAAa,IAAI,4BAAa,YAAY;AAE/E,MAAI,gBAAgB,MAAM;AACxB,WAAO,IAAI,2BAAa,0CAA0C,EAAE,QAAQ,IAAI,CAAC;AAAA,EACnF;AAEA,QAAM,qBAAqB,MAAM,OAAO,iBAAiB,YAAY;AAErE,MAAI,sBAAsB,MAAM;AAC9B,WAAO,IAAI,2BAAa,kCAAkC,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC3E;AAEA,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,QAAQ,UAAM,0BAAU;AAC9B,QAAM,cAAc,UAAM,wBAAQ;AAElC,QAAM,OAAO;AAEb,QAAM,wBAAwB,YAAY,IAAI,sCAAuB;AAErE,MAAI,uBAAuB,SAAS,MAAM;AACxC,WAAO,IAAI,2BAAa,+CAA+C,EAAE,QAAQ,IAAI,CAAC;AAAA,EACxF;AAEA,QAAM,cAA2B,EAAE,SAAS,QAAQ,SAAS,OAAO,aAAa;AACjF,QAAM,4BAAwB,0CAAqB,WAAW;AAC9D,QAAM,6BAAyB,uDAAkC,WAAW;AAE5E,QAAM,eAAkD;AAAA,IACtD;AAAA,IACA,EAAE,MAAM,8CAA+B,OAAO,sBAAsB;AAAA,EACtE;AAEA,QAAM,mBACJ,wBAAwB,OAAO,KAAK,QAAQ,QAAQ,SAAS,QAAQ,KAAK,EAAE;AAE9E,QAAM,eACJ,QAAQ,QAAQ,IAAI,kBAAkB,KAAK,QAAQ,QAAQ,IAAI,MAAM,KAAK,QAAQ,QAAQ;AAE5F,QAAM,cAAc,IAAI;AAAA,IACtB,GAAG,gBAAgB,MAAM,YAAY,GAAG,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,QAAQ,MAAM;AAAA,EAC3F;AAEA,cAAY,aAAa,OAAO,4BAAa,YAAY;AACzD,cAAY,aAAa,OAAO,kCAAmB,YAAY;AAC/D,cAAY,aAAa,OAAO,kCAAmB,YAAY;AAE/D,QAAM,UAAU,IAAI,QAAQ;AAC5B,eAAa,QAAQ,CAAC,EAAE,MAAM,MAAM,MAAM;AACxC,YAAQ;AAAA,MACN;AAAA,UACA,cAAAA,WAAgB,MAAM,OAAO,EAAE,GAAG,qCAAsB,QAAQ,uBAAuB,CAAC;AAAA,IAC1F;AAAA,EACF,CAAC;AAED,SAAO,2BAAa,SAAS,aAAa,EAAE,QAAQ,CAAC;AACvD;","names":["serializeCookie"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/clear-draft.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport {\n MAKESWIFT_DRAFT_DATA_COOKIE,\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n SET_COOKIE_HEADER,\n cookieSettingOptions,\n} from './utils/draft'\nimport { serialize as serializeCookie } from 'cookie'\n\nfunction clearCookiesHeader(cookieNames: string[]): string {\n const headers = new Headers()\n\n cookieNames.forEach(name => {\n headers.append(\n SET_COOKIE_HEADER,\n serializeCookie(name, '', { ...cookieSettingOptions, expires: new Date(0) }),\n )\n })\n\n const setCookieHeader = headers.get(SET_COOKIE_HEADER)\n\n if (setCookieHeader == null) {\n throw new Error(\n `Could not generate set-cookie header to clear cookies: ${cookieNames.join(', ')}`,\n )\n }\n\n return setCookieHeader\n}\n\ntype
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/clear-draft.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport {\n MAKESWIFT_DRAFT_DATA_COOKIE,\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n SET_COOKIE_HEADER,\n cookieSettingOptions,\n} from './utils/draft'\nimport { serialize as serializeCookie } from 'cookie'\nimport { type Context } from '../app-router-handler'\n\nfunction clearCookiesHeader(cookieNames: string[]): string {\n const headers = new Headers()\n\n cookieNames.forEach(name => {\n headers.append(\n SET_COOKIE_HEADER,\n serializeCookie(name, '', { ...cookieSettingOptions, expires: new Date(0) }),\n )\n })\n\n const setCookieHeader = headers.get(SET_COOKIE_HEADER)\n\n if (setCookieHeader == null) {\n throw new Error(\n `Could not generate set-cookie header to clear cookies: ${cookieNames.join(', ')}`,\n )\n }\n\n return setCookieHeader\n}\n\ntype ClearDraftError = string\n\ntype Response = { __brand: 'ClearDraftResponse' }\n\nexport type ClearDraftResponse = ClearDraftError | Response\n\ntype ClearDraftHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<ClearDraftResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function clearDraftHandler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<ClearDraftResponse>>\nexport default async function clearDraftHandler(\n req: NextApiRequest,\n res: NextApiResponse<ClearDraftResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function clearDraftHandler(\n ...args: ClearDraftHandlerArgs\n): Promise<NextResponse<ClearDraftResponse> | void> {\n return match(args)\n .with(routeHandlerPattern, args => clearDraftRouteHandler(...args))\n .with(apiRoutePattern, args => clearDraftApiRouteHandler(...args))\n .exhaustive()\n}\n\nasync function clearDraftRouteHandler(\n _request: NextRequest,\n _context: Context,\n {}: { apiKey: string },\n): Promise<NextResponse<ClearDraftResponse>> {\n const headers = new Headers()\n\n headers.append(\n SET_COOKIE_HEADER,\n clearCookiesHeader([PRERENDER_BYPASS_COOKIE, MAKESWIFT_DRAFT_DATA_COOKIE]),\n )\n\n return NextResponse.json({ __brand: 'ClearDraftResponse' }, { headers })\n}\n\nasync function clearDraftApiRouteHandler(\n _req: NextApiRequest,\n res: NextApiResponse<ClearDraftResponse>,\n {}: { apiKey: string },\n): Promise<void> {\n res.setHeader(\n SET_COOKIE_HEADER,\n clearCookiesHeader([PRERENDER_BYPASS_COOKIE, PREVIEW_DATA_COOKIE]),\n )\n\n return res.json({ __brand: 'ClearDraftResponse' })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AACzB,mBAMO;AACP,oBAA6C;AAG7C,SAAS,mBAAmB,aAA+B;AACzD,QAAM,UAAU,IAAI,QAAQ;AAE5B,cAAY,QAAQ,UAAQ;AAC1B,YAAQ;AAAA,MACN;AAAA,UACA,cAAAA,WAAgB,MAAM,IAAI,EAAE,GAAG,mCAAsB,SAAS,oBAAI,KAAK,CAAC,EAAE,CAAC;AAAA,IAC7E;AAAA,EACF,CAAC;AAED,QAAM,kBAAkB,QAAQ,IAAI,8BAAiB;AAErD,MAAI,mBAAmB,MAAM;AAC3B,UAAM,IAAI;AAAA,MACR,0DAA0D,YAAY,KAAK,IAAI,CAAC;AAAA,IAClF;AAAA,EACF;AAEA,SAAO;AACT;AAYA,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,qBACF,MAC+C;AAClD,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,CAAAC,UAAQ,uBAAuB,GAAGA,KAAI,CAAC,EACjE,KAAK,iBAAiB,CAAAA,UAAQ,0BAA0B,GAAGA,KAAI,CAAC,EAChE,WAAW;AAChB;AAEA,eAAe,uBACb,UACA,UACA,CAAC,GAC0C;AAC3C,QAAM,UAAU,IAAI,QAAQ;AAE5B,UAAQ;AAAA,IACN;AAAA,IACA,mBAAmB,CAAC,sCAAyB,wCAA2B,CAAC;AAAA,EAC3E;AAEA,SAAO,2BAAa,KAAK,EAAE,SAAS,qBAAqB,GAAG,EAAE,QAAQ,CAAC;AACzE;AAEA,eAAe,0BACb,MACA,KACA,CAAC,GACc;AACf,MAAI;AAAA,IACF;AAAA,IACA,mBAAmB,CAAC,sCAAyB,gCAAmB,CAAC;AAAA,EACnE;AAEA,SAAO,IAAI,KAAK,EAAE,SAAS,qBAAqB,CAAC;AACnD;","names":["serializeCookie","args"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/element-tree.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { ReactRuntime } from '../../../react'\nimport { Element } from '../../../state/react-page'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/element-tree.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { ReactRuntime } from '../../../react'\nimport { Element } from '../../../state/react-page'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { type Context } from '../app-router-handler'\n\ntype ElementTreeResult = { elementTree: Element }\n\ntype ElementTreeError = { message: string }\n\nexport type ElementTreeResponse = ElementTreeResult | ElementTreeError\n\ntype ElementTreeHandlerArgs =\n | [request: NextRequest, context: Context, runtime: ReactRuntime]\n | [req: NextApiRequest, res: NextApiResponse<ElementTreeResponse>, runtime: ReactRuntime]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function elementTree(\n request: NextRequest,\n context: Context,\n runtime: ReactRuntime,\n): Promise<NextResponse<ElementTreeResponse>>\nexport default async function elementTree(\n req: NextApiRequest,\n res: NextApiResponse<ElementTreeResponse>,\n runtime: ReactRuntime,\n): Promise<void>\nexport default async function elementTree(\n ...args: ElementTreeHandlerArgs\n): Promise<NextResponse<ElementTreeResponse> | void> {\n const [, , runtime] = args\n\n const body = await match(args)\n .with(routeHandlerPattern, ([request]) => request.json())\n .with(apiRoutePattern, ([req]) => req.body)\n .exhaustive()\n const elementTree = body.elementTree\n const replacementContext = body.replacementContext\n\n if (elementTree == null) {\n const status = 400\n const body = { message: 'elementTree must be defined' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n if (replacementContext == null) {\n const status = 400\n const body = { message: 'replacementContext must be defined' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const generatedElementTree = runtime.copyElementTree(elementTree, replacementContext)\n\n const response = { elementTree: generatedElementTree }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(response))\n .with(apiRoutePattern, ([, res]) => res.json(response))\n .exhaustive()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA0C;AAC1C,wBAAyB;AAazB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,eACF,MACgD;AACnD,QAAM,CAAC,EAAE,EAAE,OAAO,IAAI;AAEtB,QAAM,OAAO,UAAM,yBAAM,IAAI,EAC1B,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,KAAK,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EACzC,WAAW;AACd,QAAMA,eAAc,KAAK;AACzB,QAAM,qBAAqB,KAAK;AAEhC,MAAIA,gBAAe,MAAM;AACvB,UAAM,SAAS;AACf,UAAMC,QAAO,EAAE,SAAS,8BAA8B;AAEtD,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,MAAI,sBAAsB,MAAM;AAC9B,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,qCAAqC;AAE7D,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAM,uBAAuB,QAAQ,gBAAgBD,cAAa,kBAAkB;AAEpF,QAAM,WAAW,EAAE,aAAa,qBAAqB;AAErD,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,QAAQ,CAAC,EAC3D,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAK,QAAQ,CAAC,EACrD,WAAW;AAChB;","names":["elementTree","body"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/fonts.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/fonts.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { type Context } from '../app-router-handler'\n\ntype FontVariant = { weight: string; style: 'italic' | 'normal'; src?: string }\n\nexport type Font = {\n family: string\n label?: string\n variants: FontVariant[]\n}\n\ntype Fonts = Font[]\n\nexport type GetFonts = () => Fonts | Promise<Fonts>\n\nexport type FontsResponse = Fonts\n\ntype FontsHandlerArgs =\n | [request: NextRequest, context: Context, params: { getFonts?: GetFonts }]\n | [req: NextApiRequest, res: NextApiResponse<FontsResponse>, params: { getFonts?: GetFonts }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function fonts(\n request: NextRequest,\n context: Context,\n { getFonts }: { getFonts?: GetFonts },\n): Promise<NextResponse<FontsResponse>>\nexport default async function fonts(\n _req: NextApiRequest,\n res: NextApiResponse<FontsResponse>,\n { getFonts }: { getFonts?: GetFonts },\n): Promise<void>\nexport default async function fonts(\n ...args: FontsHandlerArgs\n): Promise<NextResponse<FontsResponse> | void> {\n const [, , { getFonts }] = args\n\n const fonts = (await getFonts?.()) ?? []\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(fonts))\n .with(apiRoutePattern, ([, res]) => res.json(fonts))\n .exhaustive()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AAqBzB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,SACF,MAC0C;AAC7C,QAAM,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI;AAE3B,QAAMA,SAAS,MAAM,WAAW,KAAM,CAAC;AAEvC,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,MAAK,CAAC,EACxD,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAKA,MAAK,CAAC,EAClD,WAAW;AAChB;","names":["fonts"]}
|
|
@@ -37,7 +37,7 @@ async function handler(...args) {
|
|
|
37
37
|
const supportsDraftMode = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
|
|
38
38
|
const supportsWebhook = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
|
|
39
39
|
const body = {
|
|
40
|
-
version: "0.24.9
|
|
40
|
+
version: "0.24.9",
|
|
41
41
|
previewMode: supportsPreviewMode,
|
|
42
42
|
draftMode: supportsDraftMode,
|
|
43
43
|
interactionMode: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/manifest.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/manifest.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { type Context } from '../app-router-handler'\n\nexport type Manifest = {\n version: string\n previewMode: boolean\n interactionMode: boolean\n clientSideNavigation: boolean\n elementFromPoint: boolean\n customBreakpoints: boolean\n siteVersions: boolean\n unstable_siteVersions: boolean\n localizedPageSSR: boolean\n webhook: boolean\n localizedPagesOnlineByDefault: boolean\n}\n\ntype ManifestError = { message: string }\n\nexport type ManifestResponse = Manifest | ManifestError\n\ntype ManifestHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<ManifestResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function handler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<ManifestResponse>>\nexport default async function handler(\n req: NextApiRequest,\n res: NextApiResponse<ManifestResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function handler(\n ...args: ManifestHandlerArgs\n): Promise<NextResponse<ManifestResponse> | void> {\n const [, , { apiKey }] = args\n\n const secret = match(args)\n .with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get('secret'))\n .with(apiRoutePattern, ([req]) => req.query.secret)\n .exhaustive()\n\n if (secret !== apiKey) {\n const status = 401\n const body = { message: 'Unauthorized' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const supportsPreviewMode = match(args)\n .with(routeHandlerPattern, () => false)\n .with(apiRoutePattern, () => true)\n .exhaustive()\n\n const supportsDraftMode = match(args)\n .with(routeHandlerPattern, () => true)\n .with(apiRoutePattern, () => false)\n .exhaustive()\n\n const supportsWebhook = match(args)\n .with(routeHandlerPattern, () => true)\n .with(apiRoutePattern, () => false)\n .exhaustive()\n\n const body = {\n version: PACKAGE_VERSION,\n previewMode: supportsPreviewMode,\n draftMode: supportsDraftMode,\n interactionMode: true,\n clientSideNavigation: false,\n elementFromPoint: false,\n customBreakpoints: true,\n siteVersions: true,\n unstable_siteVersions: true,\n localizedPageSSR: true,\n webhook: supportsWebhook,\n localizedPagesOnlineByDefault: true,\n }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body))\n .with(apiRoutePattern, ([, res]) => res.json(body))\n .exhaustive()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AAyBzB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,WACF,MAC6C;AAChD,QAAM,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI;AAEzB,QAAM,aAAS,yBAAM,IAAI,EACtB,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,QAAQ,aAAa,IAAI,QAAQ,CAAC,EACnF,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,MAAM,EACjD,WAAW;AAEd,MAAI,WAAW,QAAQ;AACrB,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,eAAe;AAEvC,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAM,0BAAsB,yBAAM,IAAI,EACnC,KAAK,qBAAqB,MAAM,KAAK,EACrC,KAAK,iBAAiB,MAAM,IAAI,EAChC,WAAW;AAEd,QAAM,wBAAoB,yBAAM,IAAI,EACjC,KAAK,qBAAqB,MAAM,IAAI,EACpC,KAAK,iBAAiB,MAAM,KAAK,EACjC,WAAW;AAEd,QAAM,sBAAkB,yBAAM,IAAI,EAC/B,KAAK,qBAAqB,MAAM,IAAI,EACpC,KAAK,iBAAiB,MAAM,KAAK,EACjC,WAAW;AAEd,QAAM,OAAO;AAAA,IACX,SAAS;AAAA,IACT,aAAa;AAAA,IACb,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,sBAAsB;AAAA,IACtB,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,cAAc;AAAA,IACd,uBAAuB;AAAA,IACvB,kBAAkB;AAAA,IAClB,SAAS;AAAA,IACT,+BAA+B;AAAA,EACjC;AAEA,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,IAAI,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAK,IAAI,CAAC,EACjD,WAAW;AAChB;","names":["body"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/merge-translated-data.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { Element } from '../../../state/react-page'\nimport { Makeswift } from '../../client'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/merge-translated-data.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { Element } from '../../../state/react-page'\nimport { Makeswift } from '../../client'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { type Context } from '../app-router-handler'\n\ntype TranslatedDataResult = { elementTree: Element }\n\ntype TranslatedDataError = { message: string }\n\nexport type TranslatedDataResponse = TranslatedDataResult | TranslatedDataError\n\ntype MergeTranslatedDataHandlerArgs =\n | [request: NextRequest, context: Context, client: Makeswift]\n | [req: NextApiRequest, res: NextApiResponse<TranslatedDataResponse>, client: Makeswift]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function mergeTranslatedData(\n request: NextRequest,\n context: Context,\n client: Makeswift,\n): Promise<NextResponse<TranslatedDataResponse>>\nexport default async function mergeTranslatedData(\n req: NextApiRequest,\n res: NextApiResponse<TranslatedDataResponse>,\n client: Makeswift,\n): Promise<void>\nexport default async function mergeTranslatedData(\n ...args: MergeTranslatedDataHandlerArgs\n): Promise<NextResponse<TranslatedDataResponse> | void> {\n const [, , client] = args\n\n const body = await match(args)\n .with(routeHandlerPattern, ([request]) => request.json())\n .with(apiRoutePattern, ([req]) => req.body)\n .exhaustive()\n\n const translatedData = body.translatedData\n const elementTree = body.elementTree\n\n if (translatedData == null) {\n const status = 400\n const body = { message: 'translatedData must be defined' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n if (elementTree == null) {\n const status = 400\n const body = { message: 'elementTree must be defined' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const translatedElementTree = client.mergeTranslatedData(elementTree, translatedData)\n\n const responseBody = { elementTree: translatedElementTree }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(responseBody))\n .with(apiRoutePattern, ([, res]) => res.json(responseBody))\n .exhaustive()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA0C;AAC1C,wBAAyB;AAazB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,uBACF,MACmD;AACtD,QAAM,CAAC,EAAE,EAAE,MAAM,IAAI;AAErB,QAAM,OAAO,UAAM,yBAAM,IAAI,EAC1B,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,KAAK,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EACzC,WAAW;AAEd,QAAM,iBAAiB,KAAK;AAC5B,QAAM,cAAc,KAAK;AAEzB,MAAI,kBAAkB,MAAM;AAC1B,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,iCAAiC;AAEzD,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,MAAI,eAAe,MAAM;AACvB,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,8BAA8B;AAEtD,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAM,wBAAwB,OAAO,oBAAoB,aAAa,cAAc;AAEpF,QAAM,eAAe,EAAE,aAAa,sBAAsB;AAE1D,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,YAAY,CAAC,EAC/D,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAK,YAAY,CAAC,EACzD,WAAW;AAChB;","names":["body"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pages_router_redirect_preview_exports = {};
|
|
20
|
+
__export(pages_router_redirect_preview_exports, {
|
|
21
|
+
pagesRouterRedirectPreviewHandler: () => pagesRouterRedirectPreviewHandler
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(pages_router_redirect_preview_exports);
|
|
24
|
+
var import_set_cookie_parser = require("set-cookie-parser");
|
|
25
|
+
var import_cookie = require("cookie");
|
|
26
|
+
var import_cookies = require("../../../api-handler/cookies");
|
|
27
|
+
var import_preview = require("../preview");
|
|
28
|
+
var import_site_version = require("../../../api/site-version");
|
|
29
|
+
async function pagesRouterRedirectPreviewHandler(req, res, client) {
|
|
30
|
+
const pathname = req.query[import_preview.RewriteRuleMatches.OriginalPath];
|
|
31
|
+
if (pathname == null) {
|
|
32
|
+
return res.status(400).send("Bad request: incoming request does not have an associated pathname");
|
|
33
|
+
}
|
|
34
|
+
const previewToken = req.query[import_preview.SearchParams.PreviewToken];
|
|
35
|
+
if (previewToken == null) {
|
|
36
|
+
return res.status(400).send("Bad request: no preview token provided");
|
|
37
|
+
}
|
|
38
|
+
const verificationResult = await client.readPreviewToken(previewToken);
|
|
39
|
+
if (verificationResult == null) {
|
|
40
|
+
return res.status(401).send("Failed to verify preview token");
|
|
41
|
+
}
|
|
42
|
+
const { payload } = verificationResult;
|
|
43
|
+
const siteVersion = { version: payload.version, token: previewToken };
|
|
44
|
+
const secondsUntilExpiration = (0, import_site_version.secondsUntilSiteVersionExpiration)(siteVersion);
|
|
45
|
+
const serializedSiteVersion = (0, import_site_version.serializeSiteVersion)(siteVersion);
|
|
46
|
+
const setCookie = res.setPreviewData({ siteVersion: serializedSiteVersion }).getHeader(import_cookies.SET_COOKIE_HEADER);
|
|
47
|
+
res.removeHeader(import_cookies.SET_COOKIE_HEADER);
|
|
48
|
+
const parsedCookies = (0, import_set_cookie_parser.parse)(Array.isArray(setCookie) ? setCookie : "");
|
|
49
|
+
const prerenderBypassCookie = parsedCookies.find((c) => c.name === import_preview.PRERENDER_BYPASS_COOKIE);
|
|
50
|
+
const previewDataCookie = parsedCookies.find((c) => c.name === import_preview.PREVIEW_DATA_COOKIE);
|
|
51
|
+
if (prerenderBypassCookie?.value == null || previewDataCookie?.value == null) {
|
|
52
|
+
return res.status(500).send("Could not retrieve preview mode cookies");
|
|
53
|
+
}
|
|
54
|
+
const patchedCookies = [prerenderBypassCookie, previewDataCookie].map(({ name, value }) => {
|
|
55
|
+
return (0, import_cookie.serialize)(name, value, { ...import_cookies.cookieSettingOptions, maxAge: secondsUntilExpiration });
|
|
56
|
+
});
|
|
57
|
+
res.setHeader(import_cookies.SET_COOKIE_HEADER, patchedCookies);
|
|
58
|
+
const destinationUrl = new URL(pathname, "http://test.com");
|
|
59
|
+
destinationUrl.searchParams.delete(import_preview.SearchParams.PreviewToken);
|
|
60
|
+
destinationUrl.searchParams.delete(import_preview.RewriteRuleMatches.PreviewToken);
|
|
61
|
+
destinationUrl.searchParams.delete(import_preview.RewriteRuleMatches.OriginalPath);
|
|
62
|
+
res.redirect(`${destinationUrl.pathname}?${destinationUrl.searchParams.toString()}`);
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
pagesRouterRedirectPreviewHandler
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=pages-router-redirect-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/pages-router-redirect-preview.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\n\nimport { parse as parseSetCookie } from 'set-cookie-parser'\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { cookieSettingOptions, SET_COOKIE_HEADER } from '../../../api-handler/cookies'\n\nimport {\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n RewriteRuleMatches,\n SearchParams,\n} from '../preview'\nimport { MakeswiftClient } from '../../../client'\nimport {\n secondsUntilSiteVersionExpiration,\n serializeSiteVersion,\n type SiteVersion,\n} from '../../../api/site-version'\n\nexport async function pagesRouterRedirectPreviewHandler(\n req: NextApiRequest,\n res: NextApiResponse,\n client: MakeswiftClient,\n): Promise<void> {\n // Next.js automatically strips the locale prefix from rewritten request's URL, even when the\n // rewrite's `locale` option is set to `false`: https://github.com/vercel/next.js/discussions/21798.\n // At the same time, it also maps rewrite's URL segments (e.g. `:path`) to query parameters\n // on the rewritten request, so we use the `query` to recover the original request path.\n const pathname = req.query[RewriteRuleMatches.OriginalPath] as string | undefined\n\n if (pathname == null) {\n return res\n .status(400)\n .send('Bad request: incoming request does not have an associated pathname')\n }\n\n const previewToken = req.query[SearchParams.PreviewToken] as string | undefined\n\n if (previewToken == null) {\n return res.status(400).send('Bad request: no preview token provided')\n }\n\n const verificationResult = await client.readPreviewToken(previewToken)\n\n if (verificationResult == null) {\n return res.status(401).send('Failed to verify preview token')\n }\n\n const { payload } = verificationResult\n\n const siteVersion: SiteVersion = { version: payload.version, token: previewToken }\n const secondsUntilExpiration = secondsUntilSiteVersionExpiration(siteVersion)\n const serializedSiteVersion = serializeSiteVersion(siteVersion)\n\n const setCookie = res\n .setPreviewData({ siteVersion: serializedSiteVersion })\n .getHeader(SET_COOKIE_HEADER)\n\n res.removeHeader(SET_COOKIE_HEADER)\n\n const parsedCookies = parseSetCookie(Array.isArray(setCookie) ? setCookie : '')\n\n const prerenderBypassCookie = parsedCookies.find(c => c.name === PRERENDER_BYPASS_COOKIE)\n const previewDataCookie = parsedCookies.find(c => c.name === PREVIEW_DATA_COOKIE)\n\n if (prerenderBypassCookie?.value == null || previewDataCookie?.value == null) {\n return res.status(500).send('Could not retrieve preview mode cookies')\n }\n\n const patchedCookies = [prerenderBypassCookie, previewDataCookie].map(({ name, value }) => {\n return serializeCookie(name, value, { ...cookieSettingOptions, maxAge: secondsUntilExpiration })\n })\n res.setHeader(SET_COOKIE_HEADER, patchedCookies)\n\n const destinationUrl = new URL(pathname, 'http://test.com')\n destinationUrl.searchParams.delete(SearchParams.PreviewToken)\n destinationUrl.searchParams.delete(RewriteRuleMatches.PreviewToken)\n destinationUrl.searchParams.delete(RewriteRuleMatches.OriginalPath)\n\n res.redirect(`${destinationUrl.pathname}?${destinationUrl.searchParams.toString()}`)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,+BAAwC;AACxC,oBAA6C;AAE7C,qBAAwD;AAExD,qBAKO;AAEP,0BAIO;AAEP,eAAsB,kCACpB,KACA,KACA,QACe;AAKf,QAAM,WAAW,IAAI,MAAM,kCAAmB,YAAY;AAE1D,MAAI,YAAY,MAAM;AACpB,WAAO,IACJ,OAAO,GAAG,EACV,KAAK,oEAAoE;AAAA,EAC9E;AAEA,QAAM,eAAe,IAAI,MAAM,4BAAa,YAAY;AAExD,MAAI,gBAAgB,MAAM;AACxB,WAAO,IAAI,OAAO,GAAG,EAAE,KAAK,wCAAwC;AAAA,EACtE;AAEA,QAAM,qBAAqB,MAAM,OAAO,iBAAiB,YAAY;AAErE,MAAI,sBAAsB,MAAM;AAC9B,WAAO,IAAI,OAAO,GAAG,EAAE,KAAK,gCAAgC;AAAA,EAC9D;AAEA,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,cAA2B,EAAE,SAAS,QAAQ,SAAS,OAAO,aAAa;AACjF,QAAM,6BAAyB,uDAAkC,WAAW;AAC5E,QAAM,4BAAwB,0CAAqB,WAAW;AAE9D,QAAM,YAAY,IACf,eAAe,EAAE,aAAa,sBAAsB,CAAC,EACrD,UAAU,gCAAiB;AAE9B,MAAI,aAAa,gCAAiB;AAElC,QAAM,oBAAgB,yBAAAA,OAAe,MAAM,QAAQ,SAAS,IAAI,YAAY,EAAE;AAE9E,QAAM,wBAAwB,cAAc,KAAK,OAAK,EAAE,SAAS,sCAAuB;AACxF,QAAM,oBAAoB,cAAc,KAAK,OAAK,EAAE,SAAS,kCAAmB;AAEhF,MAAI,uBAAuB,SAAS,QAAQ,mBAAmB,SAAS,MAAM;AAC5E,WAAO,IAAI,OAAO,GAAG,EAAE,KAAK,yCAAyC;AAAA,EACvE;AAEA,QAAM,iBAAiB,CAAC,uBAAuB,iBAAiB,EAAE,IAAI,CAAC,EAAE,MAAM,MAAM,MAAM;AACzF,eAAO,cAAAC,WAAgB,MAAM,OAAO,EAAE,GAAG,qCAAsB,QAAQ,uBAAuB,CAAC;AAAA,EACjG,CAAC;AACD,MAAI,UAAU,kCAAmB,cAAc;AAE/C,QAAM,iBAAiB,IAAI,IAAI,UAAU,iBAAiB;AAC1D,iBAAe,aAAa,OAAO,4BAAa,YAAY;AAC5D,iBAAe,aAAa,OAAO,kCAAmB,YAAY;AAClE,iBAAe,aAAa,OAAO,kCAAmB,YAAY;AAElE,MAAI,SAAS,GAAG,eAAe,QAAQ,IAAI,eAAe,aAAa,SAAS,CAAC,EAAE;AACrF;","names":["parseSetCookie","serializeCookie"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/redirect-draft.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { cookies, draftMode } from 'next/headers'\n\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { MakeswiftSiteVersion } from '../../../api/site-version'\nimport {\n cookieSettingOptions,\n MAKESWIFT_DRAFT_DATA_COOKIE,\n PRERENDER_BYPASS_COOKIE,\n SearchParams,\n SET_COOKIE_HEADER,\n} from './utils/draft'\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/redirect-draft.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { cookies, draftMode } from 'next/headers'\n\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { MakeswiftSiteVersion } from '../../../api/site-version'\nimport {\n cookieSettingOptions,\n MAKESWIFT_DRAFT_DATA_COOKIE,\n PRERENDER_BYPASS_COOKIE,\n SearchParams,\n SET_COOKIE_HEADER,\n} from './utils/draft'\nimport { type Context } from '../app-router-handler'\n\ntype RedirectDraftError = string\n\ntype Response = unknown\n\nexport type RedirectDraftResponse = RedirectDraftError | Response\n\ntype RedirectDraftHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<RedirectDraftResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function redirectDraftHandler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<RedirectDraftResponse>>\nexport default async function redirectDraftHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectDraftResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function redirectDraftHandler(\n ...args: RedirectDraftHandlerArgs\n): Promise<NextResponse<RedirectDraftResponse> | void> {\n return match(args)\n .with(routeHandlerPattern, args => redirectDraftRouteHandler(...args))\n .with(apiRoutePattern, args => redirectDraftApiRouteHandler(...args))\n .exhaustive()\n}\n\nexport function originalRequestProtocol(request: NextRequest): string | null {\n // The `x-forwarded-proto` header is not formally standardized, but many proxies\n // *append* the protocol used for the request to the existing value. As a result,\n // if the request passes through multiple proxies, the header may contain a\n // comma-separated list of protocols: https://code.djangoproject.com/ticket/33569\n const forwardedProto = request.headers.get('x-forwarded-proto')\n return forwardedProto != null ? forwardedProto.split(',')[0].trim() : null\n}\n\nasync function redirectDraftRouteHandler(\n request: NextRequest,\n _context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<RedirectDraftResponse>> {\n const secret = request.nextUrl.searchParams.get(SearchParams.DraftMode)\n\n if (secret == null) {\n return new NextResponse('Unauthorized to enable draft mode: no secret provided', {\n status: 401,\n })\n }\n if (secret !== apiKey) {\n return new NextResponse('Unauthorized to enable draft mode: incorrect secret', { status: 401 })\n }\n\n const draft = await draftMode()\n const cookieStore = await cookies()\n\n draft.enable()\n\n const prerenderBypassCookie = cookieStore.get(PRERENDER_BYPASS_COOKIE)\n\n if (prerenderBypassCookie?.value == null) {\n return new NextResponse('Could not retrieve draft mode bypass cookie', { status: 500 })\n }\n\n const draftCookies: { name: string; value: string }[] = [\n prerenderBypassCookie,\n {\n name: MAKESWIFT_DRAFT_DATA_COOKIE,\n // Eventually, we can make this value dynamic using the request\n value: JSON.stringify({ makeswift: true, siteVersion: MakeswiftSiteVersion.Working }),\n },\n ]\n\n const redirectProtocol =\n originalRequestProtocol(request) ?? request.nextUrl.protocol.replace(':', '')\n\n const redirectHost =\n request.headers.get('x-forwarded-host') ?? request.headers.get('host') ?? request.nextUrl.host\n\n const redirectUrl = new URL(\n `${redirectProtocol}://${redirectHost}${request.nextUrl.pathname}${request.nextUrl.search}`,\n )\n\n redirectUrl.searchParams.delete(SearchParams.DraftMode)\n\n const headers = new Headers()\n draftCookies.forEach(({ name, value }) => {\n headers.append(SET_COOKIE_HEADER, serializeCookie(name, value, { ...cookieSettingOptions }))\n })\n\n return NextResponse.redirect(redirectUrl, { headers })\n}\n\nasync function redirectDraftApiRouteHandler(\n _req: NextApiRequest,\n res: NextApiResponse<RedirectDraftResponse>,\n {}: { apiKey: string },\n): Promise<void> {\n const message =\n 'Cannot request draft endpoint from an API handler registered in `pages`. Move your Makeswift API handler to the `app` directory'\n console.error(message)\n return res.status(500).send(message)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AACzB,qBAAmC;AAEnC,oBAA6C;AAE7C,0BAAqC;AACrC,mBAMO;AAaP,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,wBACF,MACkD;AACrD,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,CAAAA,UAAQ,0BAA0B,GAAGA,KAAI,CAAC,EACpE,KAAK,iBAAiB,CAAAA,UAAQ,6BAA6B,GAAGA,KAAI,CAAC,EACnE,WAAW;AAChB;AAEO,SAAS,wBAAwB,SAAqC;AAK3E,QAAM,iBAAiB,QAAQ,QAAQ,IAAI,mBAAmB;AAC9D,SAAO,kBAAkB,OAAO,eAAe,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,IAAI;AACxE;AAEA,eAAe,0BACb,SACA,UACA,EAAE,OAAO,GACqC;AAC9C,QAAM,SAAS,QAAQ,QAAQ,aAAa,IAAI,0BAAa,SAAS;AAEtE,MAAI,UAAU,MAAM;AAClB,WAAO,IAAI,2BAAa,yDAAyD;AAAA,MAC/E,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AACA,MAAI,WAAW,QAAQ;AACrB,WAAO,IAAI,2BAAa,uDAAuD,EAAE,QAAQ,IAAI,CAAC;AAAA,EAChG;AAEA,QAAM,QAAQ,UAAM,0BAAU;AAC9B,QAAM,cAAc,UAAM,wBAAQ;AAElC,QAAM,OAAO;AAEb,QAAM,wBAAwB,YAAY,IAAI,oCAAuB;AAErE,MAAI,uBAAuB,SAAS,MAAM;AACxC,WAAO,IAAI,2BAAa,+CAA+C,EAAE,QAAQ,IAAI,CAAC;AAAA,EACxF;AAEA,QAAM,eAAkD;AAAA,IACtD;AAAA,IACA;AAAA,MACE,MAAM;AAAA;AAAA,MAEN,OAAO,KAAK,UAAU,EAAE,WAAW,MAAM,aAAa,yCAAqB,QAAQ,CAAC;AAAA,IACtF;AAAA,EACF;AAEA,QAAM,mBACJ,wBAAwB,OAAO,KAAK,QAAQ,QAAQ,SAAS,QAAQ,KAAK,EAAE;AAE9E,QAAM,eACJ,QAAQ,QAAQ,IAAI,kBAAkB,KAAK,QAAQ,QAAQ,IAAI,MAAM,KAAK,QAAQ,QAAQ;AAE5F,QAAM,cAAc,IAAI;AAAA,IACtB,GAAG,gBAAgB,MAAM,YAAY,GAAG,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,QAAQ,MAAM;AAAA,EAC3F;AAEA,cAAY,aAAa,OAAO,0BAAa,SAAS;AAEtD,QAAM,UAAU,IAAI,QAAQ;AAC5B,eAAa,QAAQ,CAAC,EAAE,MAAM,MAAM,MAAM;AACxC,YAAQ,OAAO,oCAAmB,cAAAC,WAAgB,MAAM,OAAO,EAAE,GAAG,kCAAqB,CAAC,CAAC;AAAA,EAC7F,CAAC;AAED,SAAO,2BAAa,SAAS,aAAa,EAAE,QAAQ,CAAC;AACvD;AAEA,eAAe,6BACb,MACA,KACA,CAAC,GACc;AACf,QAAM,UACJ;AACF,UAAQ,MAAM,OAAO;AACrB,SAAO,IAAI,OAAO,GAAG,EAAE,KAAK,OAAO;AACrC;","names":["args","serializeCookie"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/redirect-preview.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\nimport { parse as parseSetCookie } from 'set-cookie-parser'\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { MakeswiftSiteVersion } from '../../../api/site-version'\nimport {\n cookieSettingOptions,\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n SearchParams,\n SET_COOKIE_HEADER,\n} from './utils/draft'\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/redirect-preview.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\n\nimport { parse as parseSetCookie } from 'set-cookie-parser'\nimport { serialize as serializeCookie } from 'cookie'\n\nimport { MakeswiftSiteVersion } from '../../../api/site-version'\nimport {\n cookieSettingOptions,\n PRERENDER_BYPASS_COOKIE,\n PREVIEW_DATA_COOKIE,\n SearchParams,\n SET_COOKIE_HEADER,\n} from './utils/draft'\nimport { type Context } from '../app-router-handler'\n\ntype RedirectPreviewError = string\n\ntype Response = unknown\n\nexport type RedirectPreviewResponse = RedirectPreviewError | Response\n\ntype RedirectPreviewHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<RedirectPreviewResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function redirectPreviewHandler(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>>\nexport default async function redirectPreviewHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport default async function redirectPreviewHandler(\n ...args: RedirectPreviewHandlerArgs\n): Promise<NextResponse<RedirectPreviewResponse> | void> {\n return match(args)\n .with(routeHandlerPattern, args => redirectPreviewRouteHandler(...args))\n .with(apiRoutePattern, args => redirectPreviewApiRouteHandler(...args))\n .exhaustive()\n}\n\nasync function redirectPreviewRouteHandler(\n _request: NextRequest,\n _context: Context,\n {}: { apiKey: string },\n): Promise<NextResponse<RedirectPreviewResponse>> {\n const message =\n 'Cannot request preview endpoint from an API handler registered in `app`. Move your Makeswift API handler to the `pages/api` directory'\n console.error(message)\n return NextResponse.json(message, { status: 500 })\n}\n\nasync function redirectPreviewApiRouteHandler(\n req: NextApiRequest,\n res: NextApiResponse<RedirectPreviewResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void> {\n const secret = req.query[SearchParams.PreviewMode]\n // Next.js automatically strips the locale prefix from rewritten request's URL, even when the\n // rewrite's `locale` option is set to `false`: https://github.com/vercel/next.js/discussions/21798.\n // At the same time, it also maps rewrite's URL segments (e.g. `:path`) to query parameters\n // on the rewritten request, so we use `query.path` to recover the original request path.\n const pathname = req.query.path as string | undefined\n\n if (secret == null) {\n return res.status(401).send('Unauthorized to enable preview mode: no secret provided')\n }\n\n if (secret !== apiKey) {\n return res.status(401).send('Unauthorized to enable preview mode: secret is incorrect')\n }\n\n if (pathname == null) {\n return res\n .status(400)\n .send('Bad request: incoming request does not have an associated pathname')\n }\n\n const setCookie = res\n // Eventually, we can make the preview data value dynamic using the request\n .setPreviewData({ makeswift: true, siteVersion: MakeswiftSiteVersion.Working })\n .getHeader(SET_COOKIE_HEADER)\n\n res.removeHeader(SET_COOKIE_HEADER)\n\n const parsedCookies = parseSetCookie(Array.isArray(setCookie) ? setCookie : '')\n\n const prerenderBypassCookie = parsedCookies.find(c => c.name === PRERENDER_BYPASS_COOKIE)\n const previewDataCookie = parsedCookies.find(c => c.name === PREVIEW_DATA_COOKIE)\n\n if (prerenderBypassCookie?.value == null || previewDataCookie?.value == null) {\n return res.status(500).send('Could not retrieve preview mode cookies')\n }\n\n const patchedCookies = [prerenderBypassCookie, previewDataCookie].map(({ name, value }) => {\n return serializeCookie(name, value, { ...cookieSettingOptions })\n })\n\n res.setHeader(SET_COOKIE_HEADER, patchedCookies)\n\n const destinationUrl = new URL(pathname, 'http://test.com')\n destinationUrl.searchParams.delete(SearchParams.PreviewMode)\n\n res.redirect(`${destinationUrl.pathname}?${destinationUrl.searchParams.toString()}`)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AAEzB,+BAAwC;AACxC,oBAA6C;AAE7C,0BAAqC;AACrC,mBAMO;AAaP,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,0BACF,MACoD;AACvD,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,CAAAA,UAAQ,4BAA4B,GAAGA,KAAI,CAAC,EACtE,KAAK,iBAAiB,CAAAA,UAAQ,+BAA+B,GAAGA,KAAI,CAAC,EACrE,WAAW;AAChB;AAEA,eAAe,4BACb,UACA,UACA,CAAC,GAC+C;AAChD,QAAM,UACJ;AACF,UAAQ,MAAM,OAAO;AACrB,SAAO,2BAAa,KAAK,SAAS,EAAE,QAAQ,IAAI,CAAC;AACnD;AAEA,eAAe,+BACb,KACA,KACA,EAAE,OAAO,GACM;AACf,QAAM,SAAS,IAAI,MAAM,0BAAa,WAAW;AAKjD,QAAM,WAAW,IAAI,MAAM;AAE3B,MAAI,UAAU,MAAM;AAClB,WAAO,IAAI,OAAO,GAAG,EAAE,KAAK,yDAAyD;AAAA,EACvF;AAEA,MAAI,WAAW,QAAQ;AACrB,WAAO,IAAI,OAAO,GAAG,EAAE,KAAK,0DAA0D;AAAA,EACxF;AAEA,MAAI,YAAY,MAAM;AACpB,WAAO,IACJ,OAAO,GAAG,EACV,KAAK,oEAAoE;AAAA,EAC9E;AAEA,QAAM,YAAY,IAEf,eAAe,EAAE,WAAW,MAAM,aAAa,yCAAqB,QAAQ,CAAC,EAC7E,UAAU,8BAAiB;AAE9B,MAAI,aAAa,8BAAiB;AAElC,QAAM,oBAAgB,yBAAAC,OAAe,MAAM,QAAQ,SAAS,IAAI,YAAY,EAAE;AAE9E,QAAM,wBAAwB,cAAc,KAAK,OAAK,EAAE,SAAS,oCAAuB;AACxF,QAAM,oBAAoB,cAAc,KAAK,OAAK,EAAE,SAAS,gCAAmB;AAEhF,MAAI,uBAAuB,SAAS,QAAQ,mBAAmB,SAAS,MAAM;AAC5E,WAAO,IAAI,OAAO,GAAG,EAAE,KAAK,yCAAyC;AAAA,EACvE;AAEA,QAAM,iBAAiB,CAAC,uBAAuB,iBAAiB,EAAE,IAAI,CAAC,EAAE,MAAM,MAAM,MAAM;AACzF,eAAO,cAAAC,WAAgB,MAAM,OAAO,EAAE,GAAG,kCAAqB,CAAC;AAAA,EACjE,CAAC;AAED,MAAI,UAAU,gCAAmB,cAAc;AAE/C,QAAM,iBAAiB,IAAI,IAAI,UAAU,iBAAiB;AAC1D,iBAAe,aAAa,OAAO,0BAAa,WAAW;AAE3D,MAAI,SAAS,GAAG,eAAe,QAAQ,IAAI,eAAe,aAAa,SAAS,CAAC,EAAE;AACrF;","names":["args","parseSetCookie","serializeCookie"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/revalidate.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport isErrorWithMessage from '../../../utils/isErrorWithMessage'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { revalidatePath } from 'next/cache'\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/revalidate.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport isErrorWithMessage from '../../../utils/isErrorWithMessage'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { revalidatePath } from 'next/cache'\nimport { type Context } from '../app-router-handler'\n\ntype RevalidationResult = { revalidated: boolean }\n\ntype RevalidationError = { message: string }\n\nexport type RevalidationResponse = RevalidationResult | RevalidationError\n\ntype RevalidateHandlerArgs =\n | [request: NextRequest, context: Context, params: { apiKey: string }]\n | [req: NextApiRequest, res: NextApiResponse<RevalidationResponse>, params: { apiKey: string }]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport async function revalidate(\n request: NextRequest,\n context: Context,\n { apiKey }: { apiKey: string },\n): Promise<NextResponse<RevalidationResponse>>\nexport async function revalidate(\n req: NextApiRequest,\n res: NextApiResponse<RevalidationResponse>,\n { apiKey }: { apiKey: string },\n): Promise<void>\nexport async function revalidate(\n ...args: RevalidateHandlerArgs\n): Promise<NextResponse<RevalidationResponse> | void> {\n const [, , { apiKey }] = args\n\n const secret = match(args)\n .with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get('secret'))\n .with(apiRoutePattern, ([req]) => req.query.secret)\n .exhaustive()\n\n if (secret !== apiKey) {\n const body = { message: 'Unauthorized' }\n const status = 401\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const path = match(args)\n .with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get('path'))\n .with(apiRoutePattern, ([req]) => req.query.path)\n .exhaustive()\n\n if (typeof path !== 'string') {\n const status = 400\n const body = { message: 'Bad Request' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const revalidate = match(args)\n .with(routeHandlerPattern, () => revalidatePath)\n .with(apiRoutePattern, ([, res]) => res.revalidate)\n .exhaustive()\n\n try {\n await revalidate(path)\n\n const body = { revalidated: true }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body))\n .with(apiRoutePattern, ([, res]) => res.json(body))\n .exhaustive()\n } catch (error) {\n if (isErrorWithMessage(error)) {\n const status = 500\n const body = { message: error.message }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n const status = 500\n const body = { message: 'Error Revalidating' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gCAA+B;AAC/B,oBAA0C;AAC1C,wBAAyB;AACzB,mBAA+B;AAa/B,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAsB,cACjB,MACiD;AACpD,QAAM,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI;AAEzB,QAAM,aAAS,yBAAM,IAAI,EACtB,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,QAAQ,aAAa,IAAI,QAAQ,CAAC,EACnF,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,MAAM,EACjD,WAAW;AAEd,MAAI,WAAW,QAAQ;AACrB,UAAM,OAAO,EAAE,SAAS,eAAe;AACvC,UAAM,SAAS;AAEf,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAK,IAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAM,WAAO,yBAAM,IAAI,EACpB,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,QAAQ,aAAa,IAAI,MAAM,CAAC,EACjF,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,IAAI,EAC/C,WAAW;AAEd,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,SAAS;AACf,UAAM,OAAO,EAAE,SAAS,cAAc;AAEtC,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAK,IAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,QAAMA,kBAAa,yBAAM,IAAI,EAC1B,KAAK,qBAAqB,MAAM,2BAAc,EAC9C,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,UAAU,EACjD,WAAW;AAEd,MAAI;AACF,UAAMA,YAAW,IAAI;AAErB,UAAM,OAAO,EAAE,aAAa,KAAK;AAEjC,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,IAAI,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAK,IAAI,CAAC,EACjD,WAAW;AAAA,EAChB,SAAS,OAAO;AACd,YAAI,0BAAAC,SAAmB,KAAK,GAAG;AAC7B,YAAMC,UAAS;AACf,YAAMC,QAAO,EAAE,SAAS,MAAM,QAAQ;AAEtC,iBAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,QAAAD,QAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAOA,OAAM,EAAE,KAAKC,KAAI,CAAC,EAChE,WAAW;AAAA,IAChB;AAEA,UAAM,SAAS;AACf,UAAM,OAAO,EAAE,SAAS,qBAAqB;AAE7C,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAK,IAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AACF;","names":["revalidate","isErrorWithMessage","status","body"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/translatable-data.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { Data } from '../../../state/react-page'\nimport { Makeswift } from '../../client'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/api-handler/handlers/translatable-data.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { Data } from '../../../state/react-page'\nimport { Makeswift } from '../../client'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { type Context } from '../app-router-handler'\n\ntype TranslatableDataResult = { translatableData: Record<string, Data> }\n\ntype TranslatableDataError = { message: string }\n\nexport type TranslatableDataResponse = TranslatableDataResult | TranslatableDataError\n\ntype TranslatableDataHandlerArgs =\n | [request: NextRequest, context: Context, client: Makeswift]\n | [req: NextApiRequest, res: NextApiResponse<TranslatableDataResponse>, client: Makeswift]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nexport default async function translatableData(\n request: NextRequest,\n context: Context,\n client: Makeswift,\n): Promise<NextResponse<TranslatableDataResponse>>\nexport default async function translatableData(\n req: NextApiRequest,\n res: NextApiResponse<TranslatableDataResponse>,\n client: Makeswift,\n): Promise<void>\nexport default async function translatableData(\n ...args: TranslatableDataHandlerArgs\n): Promise<NextResponse<TranslatableDataResponse> | void> {\n const [, , client] = args\n\n const body = await match(args)\n .with(routeHandlerPattern, ([request]) => request.json())\n .with(apiRoutePattern, ([req]) => req.body)\n .exhaustive()\n const elementTree = body.elementTree\n\n if (elementTree == null) {\n const status = 400\n const body = { message: 'elementTree must be defined.' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n\n try {\n let translatableData = client.getTranslatableData(elementTree)\n\n const body = { translatableData }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body))\n .with(apiRoutePattern, ([, res]) => res.json(body))\n .exhaustive()\n } catch (error) {\n const status = 500\n const body = { message: 'Failed to get traslatable data.' }\n\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(body, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status).json(body))\n .exhaustive()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA0C;AAC1C,wBAAyB;AAazB,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAY5C,eAAO,oBACF,MACqD;AACxD,QAAM,CAAC,EAAE,EAAE,MAAM,IAAI;AAErB,QAAM,OAAO,UAAM,yBAAM,IAAI,EAC1B,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,KAAK,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EACzC,WAAW;AACd,QAAM,cAAc,KAAK;AAEzB,MAAI,eAAe,MAAM;AACvB,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,+BAA+B;AAEvD,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AAEA,MAAI;AACF,QAAIC,oBAAmB,OAAO,oBAAoB,WAAW;AAE7D,UAAMD,QAAO,EAAE,kBAAAC,kBAAiB;AAEhC,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKD,KAAI,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,KAAKA,KAAI,CAAC,EACjD,WAAW;AAAA,EAChB,SAAS,OAAO;AACd,UAAM,SAAS;AACf,UAAMA,QAAO,EAAE,SAAS,kCAAkC;AAE1D,eAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAKA,OAAM,EAAE,OAAO,CAAC,CAAC,EACnE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,KAAKA,KAAI,CAAC,EAChE,WAAW;AAAA,EAChB;AACF;","names":["body","translatableData"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/next/api-handler/handlers/webhook/index.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { handleSitePublished } from './site-published'\nimport {\n OnPublish,\n sitePublishedWebhookPayloadSchema,\n WebhookEventType,\n WebhookPayloadSchema,\n WebhookResponseBody,\n} from './types'\
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/next/api-handler/handlers/webhook/index.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest, NextResponse } from 'next/server'\nimport { P, match } from 'ts-pattern'\nimport { handleSitePublished } from './site-published'\nimport {\n OnPublish,\n sitePublishedWebhookPayloadSchema,\n WebhookEventType,\n WebhookPayloadSchema,\n WebhookResponseBody,\n} from './types'\nimport { Context } from '../../app-router-handler'\n\ntype WebhookParams = {\n apiKey: string\n events?: { onPublish?: OnPublish }\n}\n\nexport type WebhookHandlerArgs =\n | [request: NextRequest, context: Context, params: WebhookParams]\n | [req: NextApiRequest, res: NextApiResponse<WebhookResponseBody>, params: WebhookParams]\n\nconst routeHandlerPattern = [P.instanceOf(Request), P.any, P.any] as const\nconst apiRoutePattern = [P.any, P.any, P.any] as const\n\nfunction getSecret(args: WebhookHandlerArgs) {\n return match(args)\n .with(routeHandlerPattern, ([request]) => request.nextUrl.searchParams.get('secret'))\n .with(apiRoutePattern, ([req]) => req.query.secret)\n .exhaustive()\n}\n\nfunction getRequestBody(args: WebhookHandlerArgs) {\n return match(args)\n .with(routeHandlerPattern, ([request]) => request.json())\n .with(apiRoutePattern, ([req]) => req.body)\n .exhaustive()\n}\n\nfunction respond(args: WebhookHandlerArgs, response: WebhookResponseBody, status?: number) {\n return match(args)\n .with(routeHandlerPattern, () => NextResponse.json(response, { status }))\n .with(apiRoutePattern, ([, res]) => res.status(status ?? 200).json(response))\n .exhaustive()\n}\n\nexport default async function handler(\n request: NextRequest,\n context: Context,\n { apiKey, events }: WebhookParams,\n): Promise<NextResponse<WebhookResponseBody>>\nexport default async function handler(\n req: NextApiRequest,\n res: NextApiResponse<WebhookResponseBody>,\n { apiKey, events }: WebhookParams,\n): Promise<void>\nexport default async function handler(\n ...args: WebhookHandlerArgs\n): Promise<NextResponse<WebhookResponseBody> | void> {\n const [, , { apiKey, events }] = args\n const secret = getSecret(args)\n\n if (secret !== apiKey) return respond(args, { message: 'Unauthorized' }, 401)\n\n let payload: WebhookPayloadSchema\n\n try {\n const body = await getRequestBody(args)\n payload = sitePublishedWebhookPayloadSchema.parse(body)\n } catch (error) {\n console.error(error)\n return respond(args, { message: 'Invalid request body' }, 400)\n }\n\n const result = await match(payload.type)\n .with(WebhookEventType.SITE_PUBLISHED, () =>\n handleSitePublished(payload, { onPublish: events?.onPublish }),\n )\n .exhaustive()\n\n return respond(args, result.body, result.status)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0C;AAC1C,wBAAyB;AACzB,4BAAoC;AACpC,mBAMO;AAYP,MAAM,sBAAsB,CAAC,oBAAE,WAAW,OAAO,GAAG,oBAAE,KAAK,oBAAE,GAAG;AAChE,MAAM,kBAAkB,CAAC,oBAAE,KAAK,oBAAE,KAAK,oBAAE,GAAG;AAE5C,SAAS,UAAU,MAA0B;AAC3C,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,QAAQ,aAAa,IAAI,QAAQ,CAAC,EACnF,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,MAAM,EACjD,WAAW;AAChB;AAEA,SAAS,eAAe,MAA0B;AAChD,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,CAAC,CAAC,OAAO,MAAM,QAAQ,KAAK,CAAC,EACvD,KAAK,iBAAiB,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,EACzC,WAAW;AAChB;AAEA,SAAS,QAAQ,MAA0B,UAA+B,QAAiB;AACzF,aAAO,yBAAM,IAAI,EACd,KAAK,qBAAqB,MAAM,2BAAa,KAAK,UAAU,EAAE,OAAO,CAAC,CAAC,EACvE,KAAK,iBAAiB,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,OAAO,UAAU,GAAG,EAAE,KAAK,QAAQ,CAAC,EAC3E,WAAW;AAChB;AAYA,eAAO,WACF,MACgD;AACnD,QAAM,CAAC,EAAE,EAAE,EAAE,QAAQ,OAAO,CAAC,IAAI;AACjC,QAAM,SAAS,UAAU,IAAI;AAE7B,MAAI,WAAW;AAAQ,WAAO,QAAQ,MAAM,EAAE,SAAS,eAAe,GAAG,GAAG;AAE5E,MAAI;AAEJ,MAAI;AACF,UAAM,OAAO,MAAM,eAAe,IAAI;AACtC,cAAU,+CAAkC,MAAM,IAAI;AAAA,EACxD,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO,QAAQ,MAAM,EAAE,SAAS,uBAAuB,GAAG,GAAG;AAAA,EAC/D;AAEA,QAAM,SAAS,UAAM,yBAAM,QAAQ,IAAI,EACpC;AAAA,IAAK,8BAAiB;AAAA,IAAgB,UACrC,2CAAoB,SAAS,EAAE,WAAW,QAAQ,UAAU,CAAC;AAAA,EAC/D,EACC,WAAW;AAEd,SAAO,QAAQ,MAAM,OAAO,MAAM,OAAO,MAAM;AACjD;","names":[]}
|
|
@@ -66,7 +66,7 @@ Received "${apiKey}" instead.`
|
|
|
66
66
|
}
|
|
67
67
|
const routeHandlerPattern = [import_ts_pattern.P.instanceOf(Request), import_ts_pattern.P.any];
|
|
68
68
|
const apiRoutePattern = [import_ts_pattern.P.any, import_ts_pattern.P.any];
|
|
69
|
-
|
|
69
|
+
function handler(...args) {
|
|
70
70
|
return (0, import_ts_pattern.match)(args).with(routeHandlerPattern, async (args2) => {
|
|
71
71
|
const [req] = args2;
|
|
72
72
|
if (req.method.toUpperCase() === "OPTIONS") {
|
|
@@ -97,7 +97,8 @@ Received "${apiKey}" instead.`
|
|
|
97
97
|
});
|
|
98
98
|
return await makeswiftApiHandler(...args2);
|
|
99
99
|
}).exhaustive();
|
|
100
|
-
}
|
|
100
|
+
}
|
|
101
|
+
return handler;
|
|
101
102
|
function getSiteVersionFromRequest(args) {
|
|
102
103
|
const header = (0, import_ts_pattern.match)(args).with(
|
|
103
104
|
routeHandlerPattern,
|