eddev 2.0.0-beta.21 → 2.0.0-beta.211
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/css/editor-styles.css +4 -0
- package/dist/app/entry/HydrationOverlay.d.ts +2 -0
- package/dist/app/entry/HydrationOverlay.d.ts.map +1 -0
- package/dist/app/entry/HydrationOverlay.js +2 -0
- package/dist/app/entry/MetaTags.d.ts +8 -0
- package/dist/app/entry/MetaTags.d.ts.map +1 -0
- package/dist/app/entry/MetaTags.js +30 -0
- package/dist/app/entry/boot-admin.d.ts +1 -0
- package/dist/app/entry/boot-admin.d.ts.map +1 -0
- package/dist/app/entry/boot-admin.js +7 -3
- package/dist/app/entry/hydration-script.d.ts +2 -0
- package/dist/app/entry/hydration-script.d.ts.map +1 -0
- package/dist/app/entry/hydration-script.js +18 -0
- package/dist/app/entry/spa-root.d.ts +1 -0
- package/dist/app/entry/spa-root.d.ts.map +1 -0
- package/dist/app/entry/spa-root.js +3 -5
- package/dist/app/entry/ssr-root-client.d.ts +4 -1
- package/dist/app/entry/ssr-root-client.d.ts.map +1 -0
- package/dist/app/entry/ssr-root-client.js +18 -6
- package/dist/app/entry/ssr-root.d.ts +6 -4
- package/dist/app/entry/ssr-root.d.ts.map +1 -0
- package/dist/app/entry/ssr-root.js +20 -19
- package/dist/app/lib/admin/defineField.d.ts +1 -0
- package/dist/app/lib/admin/defineField.d.ts.map +1 -0
- package/dist/app/lib/admin/defineWidget.d.ts +1 -0
- package/dist/app/lib/admin/defineWidget.d.ts.map +1 -0
- package/dist/app/lib/admin/index.d.ts +1 -0
- package/dist/app/lib/admin/index.d.ts.map +1 -0
- package/dist/app/lib/admin/installFieldTypes.d.ts +1 -0
- package/dist/app/lib/admin/installFieldTypes.d.ts.map +1 -0
- package/dist/app/lib/admin/installFieldTypes.js +2 -0
- package/dist/app/lib/admin/runWidgets.d.ts +1 -0
- package/dist/app/lib/admin/runWidgets.d.ts.map +1 -0
- package/dist/app/lib/admin/runWidgets.js +7 -2
- package/dist/app/lib/blocks/ContentBlocks.d.ts +7 -4
- package/dist/app/lib/blocks/ContentBlocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/ContentBlocks.js +16 -3
- package/dist/app/lib/blocks/EditableText.d.ts +30 -5
- package/dist/app/lib/blocks/EditableText.d.ts.map +1 -0
- package/dist/app/lib/blocks/EditableText.js +34 -5
- package/dist/app/lib/blocks/InnerBlocks.d.ts +21 -6
- package/dist/app/lib/blocks/InnerBlocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/InnerBlocks.js +73 -25
- package/dist/app/lib/blocks/SlotBlocks.d.ts +8 -0
- package/dist/app/lib/blocks/SlotBlocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/SlotBlocks.js +46 -0
- package/dist/app/lib/blocks/block-utils.d.ts +2 -1
- package/dist/app/lib/blocks/block-utils.d.ts.map +1 -0
- package/dist/app/lib/blocks/block-utils.js +3 -1
- package/dist/app/lib/blocks/builtin-blocks.d.ts +2 -0
- package/dist/app/lib/blocks/builtin-blocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/builtin-blocks.js +55 -0
- package/dist/app/lib/blocks/defineBlock.d.ts +4 -0
- package/dist/app/lib/blocks/defineBlock.d.ts.map +1 -0
- package/dist/app/lib/blocks/defineBlock.js +9 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +8 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.js +164 -0
- package/dist/app/lib/blocks/editor/EditorSupport.d.ts +1 -0
- package/dist/app/lib/blocks/editor/EditorSupport.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/EditorSupport.js +17 -10
- package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +2 -1
- package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/block-templates.d.ts +8 -1
- package/dist/app/lib/blocks/editor/block-templates.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/block-templates.js +71 -2
- package/dist/app/lib/blocks/editor/blocks-by-tag.d.ts +1 -0
- package/dist/app/lib/blocks/editor/blocks-by-tag.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/controls.d.ts +1 -0
- package/dist/app/lib/blocks/editor/controls.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/create-block.d.ts +10 -0
- package/dist/app/lib/blocks/editor/create-block.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/create-block.js +13 -0
- package/dist/app/lib/blocks/editor/editor-config.d.ts +77 -8
- package/dist/app/lib/blocks/editor/editor-config.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/editor-config.js +29 -62
- package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts +4 -0
- package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +126 -21
- package/dist/app/lib/blocks/editor/root-blocks.d.ts +7 -0
- package/dist/app/lib/blocks/editor/root-blocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts +12 -1
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/usePostEditor.js +28 -13
- package/dist/app/lib/blocks/index.d.ts +8 -5
- package/dist/app/lib/blocks/index.d.ts.map +1 -0
- package/dist/app/lib/blocks/index.js +7 -5
- package/dist/app/lib/blocks/inline-editing.d.ts +10 -0
- package/dist/app/lib/blocks/inline-editing.d.ts.map +1 -0
- package/dist/app/lib/blocks/inline-editing.js +12 -2
- package/dist/app/lib/devtools/components/BreakpointIndicator.d.ts +1 -0
- package/dist/app/lib/devtools/components/BreakpointIndicator.d.ts.map +1 -0
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +2 -2
- package/dist/app/lib/devtools/components/DevUI.d.ts +1 -0
- package/dist/app/lib/devtools/components/DevUI.d.ts.map +1 -0
- package/dist/app/lib/devtools/components/DevUI.js +3 -2
- package/dist/app/lib/devtools/components/GridIndicator.d.ts +2 -0
- package/dist/app/lib/devtools/components/GridIndicator.d.ts.map +1 -0
- package/dist/app/lib/devtools/components/GridIndicator.js +29 -0
- package/dist/app/lib/devtools/dev-tools-store.d.ts +1 -0
- package/dist/app/lib/devtools/dev-tools-store.d.ts.map +1 -0
- package/dist/app/lib/devtools/hooks/usePersistState.d.ts +2 -1
- package/dist/app/lib/devtools/hooks/usePersistState.d.ts.map +1 -0
- package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +77 -76
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts.map +1 -0
- package/dist/app/lib/devtools/index.d.ts +1 -0
- package/dist/app/lib/devtools/index.d.ts.map +1 -0
- package/dist/app/lib/devtools/loader.d.ts +1 -0
- package/dist/app/lib/devtools/loader.d.ts.map +1 -0
- package/dist/app/lib/devtools/loader.js +6 -5
- package/dist/app/lib/devtools/tailwind.config.d.ts +1 -0
- package/dist/app/lib/devtools/tailwind.config.d.ts.map +1 -0
- package/dist/app/lib/devtools/useQueryDebug.d.ts +8 -1
- package/dist/app/lib/devtools/useQueryDebug.d.ts.map +1 -0
- package/dist/app/lib/devtools/useQueryDebug.js +5 -8
- package/dist/app/lib/dynamic/dynamic.d.ts +2 -1
- package/dist/app/lib/dynamic/dynamic.d.ts.map +1 -0
- package/dist/app/lib/dynamic/dynamic.js +5 -1
- package/dist/app/lib/dynamic/index.d.ts +1 -0
- package/dist/app/lib/dynamic/index.d.ts.map +1 -0
- package/dist/app/lib/hooks/index.d.ts +3 -3
- package/dist/app/lib/hooks/index.d.ts.map +1 -0
- package/dist/app/lib/hooks/index.js +2 -3
- package/dist/app/lib/hooks/{queryUtils.d.ts → query-hooks.d.ts} +42 -3
- package/dist/app/lib/hooks/query-hooks.d.ts.map +1 -0
- package/dist/app/lib/hooks/{queryUtils.js → query-hooks.js} +90 -28
- package/dist/app/lib/hooks/useAppData.d.ts +1 -0
- package/dist/app/lib/hooks/useAppData.d.ts.map +1 -0
- package/dist/app/lib/hooks/useAppData.js +11 -0
- package/dist/app/lib/hooks/useRPC.d.ts +1 -4
- package/dist/app/lib/hooks/useRPC.d.ts.map +1 -0
- package/dist/app/lib/hooks/useRPC.js +0 -8
- package/dist/app/lib/integrations/gravityforms/index.d.ts +3 -0
- package/dist/app/lib/integrations/gravityforms/index.d.ts.map +1 -0
- package/dist/app/lib/integrations/gravityforms/index.js +2 -0
- package/dist/app/lib/integrations/gravityforms/types.d.ts +145 -0
- package/dist/app/lib/integrations/gravityforms/types.d.ts.map +1 -0
- package/dist/app/lib/integrations/gravityforms/types.js +1 -0
- package/dist/app/lib/integrations/gravityforms/useGravityForm.d.ts +31 -0
- package/dist/app/lib/integrations/gravityforms/useGravityForm.d.ts.map +1 -0
- package/dist/app/lib/integrations/gravityforms/useGravityForm.js +295 -0
- package/dist/app/lib/internal/finalize-rpc.d.ts +18 -0
- package/dist/app/lib/internal/finalize-rpc.d.ts.map +1 -0
- package/dist/app/lib/internal/finalize-rpc.js +3 -0
- package/dist/app/lib/internal/index.d.ts +2 -0
- package/dist/app/lib/internal/index.d.ts.map +1 -0
- package/dist/app/lib/internal/index.js +1 -0
- package/dist/app/lib/internal/internal-store.d.ts +1 -0
- package/dist/app/lib/internal/internal-store.d.ts.map +1 -0
- package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -0
- package/dist/app/lib/internal/read-admin-manifest.d.ts.map +1 -0
- package/dist/app/lib/internal/read-block-manifest.d.ts +2 -0
- package/dist/app/lib/internal/read-block-manifest.d.ts.map +1 -0
- package/dist/app/lib/internal/read-block-manifest.js +7 -0
- package/dist/app/lib/internal/read-view-manifest.d.ts +7 -4
- package/dist/app/lib/internal/read-view-manifest.d.ts.map +1 -0
- package/dist/app/lib/internal/read-view-manifest.js +18 -0
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +510 -1
- package/dist/app/lib/legacy-stitches/createStitches.d.ts.map +1 -0
- package/dist/app/lib/legacy-stitches/index.d.ts +1 -0
- package/dist/app/lib/legacy-stitches/index.d.ts.map +1 -0
- package/dist/app/lib/routing/components/BackButton.d.ts +50 -0
- package/dist/app/lib/routing/components/BackButton.d.ts.map +1 -0
- package/dist/app/lib/routing/components/BackButton.js +47 -0
- package/dist/app/lib/routing/components/BrowserRouter.d.ts +10 -1
- package/dist/app/lib/routing/components/BrowserRouter.d.ts.map +1 -0
- package/dist/app/lib/routing/components/BrowserRouter.js +136 -21
- package/dist/app/lib/routing/components/ClientOnly.d.ts +2 -1
- package/dist/app/lib/routing/components/ClientOnly.d.ts.map +1 -0
- package/dist/app/lib/routing/components/ClientOnly.js +1 -1
- package/dist/app/lib/routing/components/Link.d.ts +19 -2
- package/dist/app/lib/routing/components/Link.d.ts.map +1 -0
- package/dist/app/lib/routing/components/Link.js +43 -23
- package/dist/app/lib/routing/components/NativeLinkHandler.d.ts +10 -0
- package/dist/app/lib/routing/components/NativeLinkHandler.d.ts.map +1 -0
- package/dist/app/lib/routing/components/NativeLinkHandler.js +23 -0
- package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -0
- package/dist/app/lib/routing/components/RouteRenderer.d.ts.map +1 -0
- package/dist/app/lib/routing/components/RouteRenderer.js +17 -3
- package/dist/app/lib/routing/components/SSRRouter.d.ts +3 -0
- package/dist/app/lib/routing/components/SSRRouter.d.ts.map +1 -0
- package/dist/app/lib/routing/components/SSRRouter.js +3 -2
- package/dist/app/lib/routing/components/ScrollRestoration.d.ts +1 -0
- package/dist/app/lib/routing/components/ScrollRestoration.d.ts.map +1 -0
- package/dist/app/lib/routing/components/ScrollRestoration.js +4 -1
- package/dist/app/lib/routing/context.d.ts +9 -5
- package/dist/app/lib/routing/context.d.ts.map +1 -0
- package/dist/app/lib/routing/context.js +12 -95
- package/dist/app/lib/routing/hooks/useIsSSR.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useIsSSR.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRestorableState.d.ts +3 -1
- package/dist/app/lib/routing/hooks/useRestorableState.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -0
- package/dist/app/lib/routing/hooks/useRoute.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRoute.js +21 -0
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +6 -0
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRouter.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRouterState.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useSearchParams.d.ts +78 -6
- package/dist/app/lib/routing/hooks/useSearchParams.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useSearchParams.js +75 -15
- package/dist/app/lib/routing/index.d.ts +3 -0
- package/dist/app/lib/routing/index.d.ts.map +1 -0
- package/dist/app/lib/routing/index.js +2 -0
- package/dist/app/lib/routing/loader.d.ts +1 -0
- package/dist/app/lib/routing/loader.d.ts.map +1 -0
- package/dist/app/lib/routing/loader.js +19 -10
- package/dist/app/lib/routing/types.d.ts +60 -12
- package/dist/app/lib/routing/types.d.ts.map +1 -0
- package/dist/app/lib/routing/utils.d.ts +7 -2
- package/dist/app/lib/routing/utils.d.ts.map +1 -0
- package/dist/app/lib/routing/utils.js +41 -4
- package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +11 -2
- package/dist/app/lib/runtime/apiConfig.d.ts.map +1 -0
- package/dist/app/lib/runtime/apiConfig.js +6 -0
- package/dist/app/lib/runtime/errorHandling.d.ts +40 -0
- package/dist/app/lib/runtime/errorHandling.d.ts.map +1 -0
- package/dist/app/lib/runtime/errorHandling.js +6 -0
- package/dist/app/lib/runtime/index.d.ts +3 -0
- package/dist/app/lib/runtime/index.d.ts.map +1 -0
- package/dist/app/lib/runtime/index.js +2 -0
- package/dist/app/lib/views/defineView.d.ts +2 -1
- package/dist/app/lib/views/defineView.d.ts.map +1 -0
- package/dist/app/lib/views/index.d.ts +1 -0
- package/dist/app/lib/views/index.d.ts.map +1 -0
- package/dist/app/server/index.d.ts +4 -1
- package/dist/app/server/index.d.ts.map +1 -0
- package/dist/app/server/index.js +3 -1
- package/dist/app/server/proxy-wp-admin.d.ts +2 -2
- package/dist/app/server/proxy-wp-admin.d.ts.map +1 -0
- package/dist/app/server/proxy-wp-admin.js +46 -13
- package/dist/app/server/render-ai-page.d.ts +13 -0
- package/dist/app/server/render-ai-page.d.ts.map +1 -0
- package/dist/app/server/render-ai-page.js +100 -0
- package/dist/app/server/render-ssr-page.d.ts +31 -3
- package/dist/app/server/render-ssr-page.d.ts.map +1 -0
- package/dist/app/server/render-ssr-page.js +226 -10
- package/dist/app/server/rpc.d.ts +60 -0
- package/dist/app/server/rpc.d.ts.map +1 -0
- package/dist/app/server/rpc.js +18 -0
- package/dist/app/server/server-context.d.ts +44 -6
- package/dist/app/server/server-context.d.ts.map +1 -0
- package/dist/app/server/server-context.js +334 -37
- package/dist/app/server/server-custom-config.d.ts +3 -0
- package/dist/app/server/server-custom-config.d.ts.map +1 -0
- package/dist/app/server/server-custom-config.js +1 -0
- package/dist/app/server/utils/content-security.d.ts +26 -0
- package/dist/app/server/utils/content-security.d.ts.map +1 -0
- package/dist/app/server/utils/content-security.js +124 -0
- package/dist/app/server/utils/headers.d.ts +1 -0
- package/dist/app/server/utils/headers.d.ts.map +1 -0
- package/dist/app/server/utils/replace-host.d.ts +2 -1
- package/dist/app/server/utils/replace-host.d.ts.map +1 -0
- package/dist/app/server/utils/replace-host.js +10 -2
- package/dist/app/server/utils/swr-cache.d.ts +5 -0
- package/dist/app/server/utils/swr-cache.d.ts.map +1 -0
- package/dist/app/server/utils/swr-cache.js +31 -0
- package/dist/app/utils/APIProvider.d.ts +3 -0
- package/dist/app/utils/APIProvider.d.ts.map +1 -0
- package/dist/app/utils/APIProvider.js +5 -0
- package/dist/app/utils/BlockErrorBoundary.d.ts +20 -0
- package/dist/app/utils/BlockErrorBoundary.d.ts.map +1 -0
- package/dist/app/utils/BlockErrorBoundary.js +38 -0
- package/dist/app/utils/ErrorMessage.d.ts +6 -0
- package/dist/app/utils/ErrorMessage.d.ts.map +1 -0
- package/dist/app/utils/ErrorMessage.js +14 -0
- package/dist/app/utils/RouteErrorBoundary.d.ts +20 -0
- package/dist/app/utils/RouteErrorBoundary.d.ts.map +1 -0
- package/dist/app/utils/RouteErrorBoundary.js +41 -0
- package/dist/app/utils/asset-capture.d.ts +3 -0
- package/dist/app/utils/asset-capture.d.ts.map +1 -0
- package/dist/app/utils/asset-capture.js +5 -0
- package/dist/app/utils/hydration-debugger.d.ts +14 -0
- package/dist/app/utils/hydration-debugger.d.ts.map +1 -0
- package/dist/app/utils/hydration-debugger.js +11 -0
- package/dist/app/utils/query-client.d.ts +3 -0
- package/dist/app/utils/query-client.d.ts.map +1 -0
- package/dist/app/utils/query-client.js +5 -1
- package/dist/app/utils/query-monitor.d.ts +27 -0
- package/dist/app/utils/query-monitor.d.ts.map +1 -0
- package/dist/app/utils/query-monitor.js +7 -0
- package/dist/app/utils/trpc-client.d.ts +3 -0
- package/dist/app/utils/trpc-client.d.ts.map +1 -0
- package/dist/app/utils/trpc-client.js +39 -0
- package/dist/app/utils/wp.d.ts +11 -10
- package/dist/app/utils/wp.d.ts.map +1 -0
- package/dist/node/cli/cli-mode.d.ts +1 -0
- package/dist/node/cli/cli-mode.d.ts.map +1 -0
- package/dist/node/cli/cli-worker.d.ts +1 -0
- package/dist/node/cli/cli-worker.d.ts.map +1 -0
- package/dist/node/cli/cli-worker.js +7 -3
- package/dist/node/cli/cli.d.ts +1 -0
- package/dist/node/cli/cli.d.ts.map +1 -0
- package/dist/node/cli/cli.js +120 -7
- package/dist/node/cli/display/CLIApp.d.ts +1 -0
- package/dist/node/cli/display/CLIApp.d.ts.map +1 -0
- package/dist/node/cli/display/CLIApp.js +1 -1
- package/dist/node/cli/display/boot-cli-app.d.ts +1 -0
- package/dist/node/cli/display/boot-cli-app.d.ts.map +1 -0
- package/dist/node/cli/display/boot-cli-app.js +1 -1
- package/dist/node/cli/display/components/Fullscreen.d.ts +1 -0
- package/dist/node/cli/display/components/Fullscreen.d.ts.map +1 -0
- package/dist/node/cli/display/components/LogEntries.d.ts +1 -0
- package/dist/node/cli/display/components/LogEntries.d.ts.map +1 -0
- package/dist/node/cli/display/components/MenuItem.d.ts +1 -0
- package/dist/node/cli/display/components/MenuItem.d.ts.map +1 -0
- package/dist/node/cli/display/components/TextInput.d.ts +1 -0
- package/dist/node/cli/display/components/TextInput.d.ts.map +1 -0
- package/dist/node/cli/display/hooks/useManifest.d.ts +1 -0
- package/dist/node/cli/display/hooks/useManifest.d.ts.map +1 -0
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -0
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts.map +1 -0
- package/dist/node/cli/display/tools/BlockList.d.ts +1 -0
- package/dist/node/cli/display/tools/BlockList.d.ts.map +1 -0
- package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -0
- package/dist/node/cli/display/tools/CreateBlock.d.ts.map +1 -0
- package/dist/node/cli/display/tools/cli-tool-list.d.ts +1 -0
- package/dist/node/cli/display/tools/cli-tool-list.d.ts.map +1 -0
- package/dist/node/cli/display/tools/cli-tools.d.ts +1 -0
- package/dist/node/cli/display/tools/cli-tools.d.ts.map +1 -0
- package/dist/node/cli/display/util/colors.d.ts +1 -0
- package/dist/node/cli/display/util/colors.d.ts.map +1 -0
- package/dist/node/cli/version.d.ts +2 -1
- package/dist/node/cli/version.d.ts.map +1 -0
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/build-vinxi.d.ts +1 -0
- package/dist/node/compiler/build-vinxi.d.ts.map +1 -0
- package/dist/node/compiler/build-vinxi.js +2 -1
- package/dist/node/compiler/bundler.admin.d.ts +1 -0
- package/dist/node/compiler/bundler.admin.d.ts.map +1 -0
- package/dist/node/compiler/bundler.admin.js +1 -0
- package/dist/node/compiler/bundler.frontend.d.ts +2 -0
- package/dist/node/compiler/bundler.frontend.d.ts.map +1 -0
- package/dist/node/compiler/bundler.frontend.js +26 -11
- package/dist/node/compiler/dev-server.d.ts +1 -0
- package/dist/node/compiler/dev-server.d.ts.map +1 -0
- package/dist/node/compiler/dev-server.js +17 -1
- package/dist/node/compiler/get-vite-config.d.ts +12 -1
- package/dist/node/compiler/get-vite-config.d.ts.map +1 -0
- package/dist/node/compiler/get-vite-config.js +173 -42
- package/dist/node/compiler/vinxi-app.d.ts +13 -0
- package/dist/node/compiler/vinxi-app.d.ts.map +1 -0
- package/dist/node/compiler/vinxi-app.js +142 -32
- package/dist/node/compiler/vinxi-codegen.d.ts +1 -0
- package/dist/node/compiler/vinxi-codegen.d.ts.map +1 -0
- package/dist/node/compiler/vinxi-codegen.js +371 -108
- package/dist/node/graphql/graphql-codegen.d.ts +12 -1
- package/dist/node/graphql/graphql-codegen.d.ts.map +1 -0
- package/dist/node/graphql/graphql-codegen.js +239 -37
- package/dist/node/graphql/graphql-schema-loader.d.ts +3 -1
- package/dist/node/graphql/graphql-schema-loader.d.ts.map +1 -0
- package/dist/node/graphql/graphql-schema-loader.js +5 -16
- package/dist/node/graphql/plugins/gql-plugin-files.d.ts +3 -1
- package/dist/node/graphql/plugins/gql-plugin-files.d.ts.map +1 -0
- package/dist/node/graphql/plugins/gql-plugin-files.js +3 -2
- package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts +1 -0
- package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts.map +1 -0
- package/dist/node/graphql/plugins/gql-plugin-queries.d.ts +1 -0
- package/dist/node/graphql/plugins/gql-plugin-queries.d.ts.map +1 -0
- package/dist/node/graphql/plugins/gql-plugin-queries.js +2 -2
- package/dist/node/graphql/query-files-loader.d.ts +4 -0
- package/dist/node/graphql/query-files-loader.d.ts.map +1 -0
- package/dist/node/graphql/query-files-loader.js +5 -0
- package/dist/node/graphql/wp-info-query.d.ts +1 -0
- package/dist/node/graphql/wp-info-query.d.ts.map +1 -0
- package/dist/node/project/config.d.ts +207 -73
- package/dist/node/project/config.d.ts.map +1 -0
- package/dist/node/project/config.js +94 -20
- package/dist/node/project/eddev-build-file.d.ts +1 -0
- package/dist/node/project/eddev-build-file.d.ts.map +1 -0
- package/dist/node/project/eddev-build-file.js +4 -2
- package/dist/node/project/env.d.ts +5 -0
- package/dist/node/project/env.d.ts.map +1 -0
- package/dist/node/project/env.js +1 -0
- package/dist/node/project/favicons.d.ts +1 -1
- package/dist/node/project/favicons.d.ts.map +1 -0
- package/dist/node/project/favicons.js +1 -1
- package/dist/node/project/manifest/block-manifest.d.ts +1 -0
- package/dist/node/project/manifest/block-manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/block-manifest.js +6 -2
- package/dist/node/project/manifest/field-manifest.d.ts +1 -0
- package/dist/node/project/manifest/field-manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/manifest.d.ts +2 -0
- package/dist/node/project/manifest/manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/manifest.js +14 -10
- package/dist/node/project/manifest/routes-manifest.d.ts +21 -0
- package/dist/node/project/manifest/routes-manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/routes-manifest.js +74 -0
- package/dist/node/project/manifest/view-manifest.d.ts +1 -0
- package/dist/node/project/manifest/view-manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/widget-manifest.d.ts +1 -0
- package/dist/node/project/manifest/widget-manifest.d.ts.map +1 -0
- package/dist/node/project/project.d.ts +12 -0
- package/dist/node/project/project.d.ts.map +1 -0
- package/dist/node/project/project.js +57 -3
- package/dist/node/project/wp-info.d.ts +3 -0
- package/dist/node/project/wp-info.d.ts.map +1 -0
- package/dist/node/project/wp-info.js +13 -1
- package/dist/node/storybook/index.d.ts +3 -0
- package/dist/node/storybook/index.d.ts.map +1 -0
- package/dist/node/storybook/index.js +13 -0
- package/dist/node/types/block-type.d.ts +57 -25
- package/dist/node/types/block-type.d.ts.map +1 -0
- package/dist/node/types/block-type.js +4 -1
- package/dist/node/types/view-type.d.ts +8 -7
- package/dist/node/types/view-type.d.ts.map +1 -0
- package/dist/node/utils/fetch-wp.d.ts +2 -0
- package/dist/node/utils/fetch-wp.d.ts.map +1 -0
- package/dist/node/utils/fetch-wp.js +28 -0
- package/dist/node/utils/format-zod-error.d.ts +1 -0
- package/dist/node/utils/format-zod-error.d.ts.map +1 -0
- package/dist/node/utils/fs-codegen.d.ts +4 -0
- package/dist/node/utils/fs-codegen.d.ts.map +1 -0
- package/dist/node/utils/fs-codegen.js +10 -2
- package/dist/node/utils/fs.d.ts +5 -0
- package/dist/node/utils/fs.d.ts.map +1 -0
- package/dist/node/utils/get-repo-info.d.ts +1 -0
- package/dist/node/utils/get-repo-info.d.ts.map +1 -0
- package/dist/node/utils/helpers.d.ts +1 -0
- package/dist/node/utils/helpers.d.ts.map +1 -0
- package/dist/node/utils/highlight-code.d.ts +1 -0
- package/dist/node/utils/highlight-code.d.ts.map +1 -0
- package/dist/node/utils/is-deploying.d.ts +1 -0
- package/dist/node/utils/is-deploying.d.ts.map +1 -0
- package/dist/node/utils/is-deploying.js +1 -1
- package/dist/node/utils/report-builder.d.ts +1 -0
- package/dist/node/utils/report-builder.d.ts.map +1 -0
- package/dist/node/utils/self-signed-cert.d.ts +5 -0
- package/dist/node/utils/self-signed-cert.d.ts.map +1 -0
- package/dist/node/utils/self-signed-cert.js +28 -4
- package/dist/node/utils/stateful-log.d.ts +1 -0
- package/dist/node/utils/stateful-log.d.ts.map +1 -0
- package/dist/node/utils/stateful-log.js +2 -0
- package/dist/node/utils/ts-export-extractor.d.ts +1 -0
- package/dist/node/utils/ts-export-extractor.d.ts.map +1 -0
- package/dist/node/utils/watch-file-tree.d.ts +18 -3
- package/dist/node/utils/watch-file-tree.d.ts.map +1 -0
- package/dist/node/utils/watch-file-tree.js +12 -5
- package/package.json +42 -25
- package/tsconfig.app.json +10 -5
- package/tsconfig.node.json +3 -2
- package/types.app.d.ts +2 -0
- package/types.meta.d.ts +449 -136
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
- package/dist/app/lib/hooks/apiConfig.js +0 -4
- package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
- package/dist/app/lib/hooks/usePageLoad.js +0 -5
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { parseURL, stringifyParsedURL, withQuery } from "ufo";
|
|
1
|
+
import { parseURL, stringifyParsedURL, withQuery, withTrailingSlash } from "ufo";
|
|
2
|
+
import { fetchWP } from "../../node/utils/fetch-wp.js";
|
|
2
3
|
import { filterHeader } from "./utils/headers.js";
|
|
3
4
|
import { createUrlReplacer } from "./utils/replace-host.js";
|
|
4
|
-
|
|
5
|
+
import { pageCache, queryCache, swr } from "./utils/swr-cache.js";
|
|
6
|
+
import { QueryMonitor } from "../utils/query-monitor.js";
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
import { inspect } from "node:util";
|
|
9
|
+
const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control", /woocommerce/, "location"];
|
|
5
10
|
const PROXY_REQUEST_HEADERS = [
|
|
6
11
|
"content-type",
|
|
7
12
|
"accept",
|
|
@@ -11,19 +16,38 @@ const PROXY_REQUEST_HEADERS = [
|
|
|
11
16
|
"referer",
|
|
12
17
|
"user-agent",
|
|
13
18
|
"authorization",
|
|
19
|
+
"woocommerce-session",
|
|
14
20
|
];
|
|
21
|
+
const VARIES_HEADERS = ["Authorization", "woocommerce-session"];
|
|
22
|
+
let runtime;
|
|
15
23
|
export class ServerContext {
|
|
16
24
|
dev;
|
|
17
25
|
origin;
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
_urlReplacer;
|
|
27
|
+
rpcBases = [];
|
|
28
|
+
config;
|
|
29
|
+
static main;
|
|
20
30
|
constructor(conf) {
|
|
21
31
|
this.dev = conf.dev;
|
|
22
32
|
this.origin = conf.origin;
|
|
23
|
-
this.
|
|
33
|
+
this.rpcBases = conf.rpcBases ?? [];
|
|
34
|
+
this.config = conf.config;
|
|
24
35
|
if (conf.replaceUrls) {
|
|
25
|
-
this.
|
|
36
|
+
this._urlReplacer = createUrlReplacer(conf.replaceUrls);
|
|
26
37
|
}
|
|
38
|
+
ServerContext.main = this;
|
|
39
|
+
}
|
|
40
|
+
replaceUrls(text, origin) {
|
|
41
|
+
if (this._urlReplacer) {
|
|
42
|
+
return this._urlReplacer(text, origin);
|
|
43
|
+
}
|
|
44
|
+
return text;
|
|
45
|
+
}
|
|
46
|
+
get runtime() {
|
|
47
|
+
return runtime;
|
|
48
|
+
}
|
|
49
|
+
static setRuntime(rt) {
|
|
50
|
+
runtime = rt;
|
|
27
51
|
}
|
|
28
52
|
getOriginUrl(url) {
|
|
29
53
|
const parsed = parseURL(url);
|
|
@@ -34,13 +58,11 @@ export class ServerContext {
|
|
|
34
58
|
}
|
|
35
59
|
async fetchOrigin(url, opts) {
|
|
36
60
|
url = this.getOriginUrl(url);
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
...opts?.headers,
|
|
43
|
-
},
|
|
61
|
+
const fetchOps = { ...opts };
|
|
62
|
+
delete fetchOps.replaceUrls;
|
|
63
|
+
delete fetchOps.newOrigin;
|
|
64
|
+
const response = await fetchWP(url, {
|
|
65
|
+
...fetchOps,
|
|
44
66
|
});
|
|
45
67
|
if (!response.ok) {
|
|
46
68
|
return response;
|
|
@@ -52,8 +74,8 @@ export class ServerContext {
|
|
|
52
74
|
}
|
|
53
75
|
});
|
|
54
76
|
let text = await response.text();
|
|
55
|
-
if (opts?.replaceUrls
|
|
56
|
-
text = this.replaceUrls(text);
|
|
77
|
+
if (opts?.replaceUrls) {
|
|
78
|
+
text = this.replaceUrls(text, opts.newOrigin);
|
|
57
79
|
}
|
|
58
80
|
return new Response(text, {
|
|
59
81
|
status: response.status,
|
|
@@ -61,22 +83,209 @@ export class ServerContext {
|
|
|
61
83
|
headers,
|
|
62
84
|
});
|
|
63
85
|
}
|
|
86
|
+
debugLogQueryMonitor(kind, uri, monitor) {
|
|
87
|
+
if (!QueryMonitor.hasLogEntries(monitor))
|
|
88
|
+
return;
|
|
89
|
+
let indentLevel = 2;
|
|
90
|
+
const finalOutput = [];
|
|
91
|
+
let label = "";
|
|
92
|
+
if (kind === "props") {
|
|
93
|
+
label = "While fetching props for route '" + uri + "'";
|
|
94
|
+
}
|
|
95
|
+
else if (kind === "query") {
|
|
96
|
+
label = "While querying " + uri + " via REST API";
|
|
97
|
+
}
|
|
98
|
+
else if (kind === "mutation") {
|
|
99
|
+
label = "While mutating " + uri + " via REST API";
|
|
100
|
+
}
|
|
101
|
+
else if (kind === "app") {
|
|
102
|
+
label = "While fetching app data";
|
|
103
|
+
}
|
|
104
|
+
finalOutput.push(chalk.whiteBright("➜ " + label));
|
|
105
|
+
function printEntry(entry) {
|
|
106
|
+
finalOutput.push(indent(indentLevel, chalk.whiteBright("➜ " + entry.file) + " " + chalk.gray(entry.label ? `(${entry.label})` : "")));
|
|
107
|
+
indentLevel += 2;
|
|
108
|
+
if (entry.log && entry.log.length) {
|
|
109
|
+
for (let item of entry.log) {
|
|
110
|
+
let output = "";
|
|
111
|
+
let prefix = "";
|
|
112
|
+
let message = item.message;
|
|
113
|
+
let stack = [];
|
|
114
|
+
if (item.type === "php_error") {
|
|
115
|
+
prefix = chalk.red("PHP Error:");
|
|
116
|
+
}
|
|
117
|
+
else if (item.type === "php_warning") {
|
|
118
|
+
prefix = chalk.yellow("PHP Warning:");
|
|
119
|
+
}
|
|
120
|
+
else if (item.type === "php_notice") {
|
|
121
|
+
prefix = chalk.yellow("PHP Notice:");
|
|
122
|
+
}
|
|
123
|
+
else if (item.type === "GRAPHQL_DEBUG") {
|
|
124
|
+
prefix = chalk.cyan("debug:");
|
|
125
|
+
}
|
|
126
|
+
else if (item.type === "error" && item.extensions?.category === "user") {
|
|
127
|
+
prefix = chalk.red("UserError:");
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
prefix = chalk.gray((item.type || "Log") + ":");
|
|
131
|
+
}
|
|
132
|
+
if (typeof message !== "string") {
|
|
133
|
+
message = inspect(message, { depth: 4 });
|
|
134
|
+
}
|
|
135
|
+
if (item.debugMessage) {
|
|
136
|
+
message += "\n" + chalk.gray(item.debugMessage);
|
|
137
|
+
}
|
|
138
|
+
output += prefix + " " + message;
|
|
139
|
+
if (item.path) {
|
|
140
|
+
stack.push(chalk.gray(" at path " + JSON.stringify(item.path)));
|
|
141
|
+
}
|
|
142
|
+
if (item.file) {
|
|
143
|
+
stack.push(chalk.gray(`at ${chalk.white(item.file)} line ${item.line || "??"}`));
|
|
144
|
+
}
|
|
145
|
+
if (item.stack?.length) {
|
|
146
|
+
stack.push(item.stack
|
|
147
|
+
.filter((line) => {
|
|
148
|
+
return line !== item.file + ":" + item.line;
|
|
149
|
+
})
|
|
150
|
+
.slice(0, 4)
|
|
151
|
+
.map((line) => " " + chalk.gray(line))
|
|
152
|
+
.join("\n"));
|
|
153
|
+
}
|
|
154
|
+
if (stack.length > 0) {
|
|
155
|
+
output += indent(2, "\n" + stack.join("\n"));
|
|
156
|
+
}
|
|
157
|
+
finalOutput.push(indent(indentLevel, "➜ " + output));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
for (let child of entry.children ?? []) {
|
|
161
|
+
printEntry(child);
|
|
162
|
+
}
|
|
163
|
+
indentLevel -= 2;
|
|
164
|
+
}
|
|
165
|
+
for (let entry of monitor) {
|
|
166
|
+
printEntry(entry);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
64
169
|
async fetchRouteData(req) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Calculcate the cache key.
|
|
172
|
+
* For route data, the cache key is the pathname.
|
|
173
|
+
* TODO: Potential support for Vercel draft mode.
|
|
174
|
+
*/
|
|
175
|
+
let cacheKey = "fetchRouteData:" + req.pathname;
|
|
176
|
+
const result = await swr({
|
|
177
|
+
key: cacheKey,
|
|
178
|
+
cache: pageCache,
|
|
179
|
+
forceFresh: this.dev,
|
|
180
|
+
getFreshValue: async (ctx) => {
|
|
181
|
+
ctx.metadata.createdTime;
|
|
182
|
+
const fetchUrl = withQuery(withTrailingSlash(req.pathname), {
|
|
183
|
+
_props: "1",
|
|
184
|
+
_ssr: "1",
|
|
185
|
+
_debug: this.dev ? "1" : undefined,
|
|
186
|
+
});
|
|
187
|
+
const result = await this.fetchOrigin(fetchUrl, {
|
|
188
|
+
cache: "no-cache",
|
|
189
|
+
replaceUrls: true,
|
|
190
|
+
newOrigin: req.newOrigin,
|
|
191
|
+
headers: {
|
|
192
|
+
"Content-Type": "application/json",
|
|
193
|
+
Accept: "application/json",
|
|
194
|
+
},
|
|
195
|
+
redirect: "manual",
|
|
196
|
+
});
|
|
197
|
+
const preferredCacheDuration = parseInt(result.headers.get("x-ed-cache-duration") ?? "");
|
|
198
|
+
if (isFinite(preferredCacheDuration)) {
|
|
199
|
+
ctx.metadata.ttl = preferredCacheDuration * 1000;
|
|
200
|
+
}
|
|
201
|
+
let resultStatus = result.status;
|
|
202
|
+
let resultHeaders = new Headers(result.headers);
|
|
203
|
+
let resultData = {};
|
|
204
|
+
// Special case for redirects
|
|
205
|
+
if (result.headers.has("location")) {
|
|
206
|
+
let location = result.headers.get("location");
|
|
207
|
+
let status = result.status;
|
|
208
|
+
if (this.replaceUrls) {
|
|
209
|
+
location = this.replaceUrls(location);
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
status: 200,
|
|
213
|
+
headers: new Headers({
|
|
214
|
+
"Content-Type": "application/json",
|
|
215
|
+
}),
|
|
216
|
+
data: JSON.stringify({ redirect: location, status: status }),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
resultData = await result.json();
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
console.error(`Invalid JSON response from '${fetchUrl}'. An error page will be displayed.`);
|
|
224
|
+
ctx.metadata.ttl = 0;
|
|
225
|
+
return {
|
|
226
|
+
status: 500,
|
|
227
|
+
headers: resultHeaders,
|
|
228
|
+
data: JSON.stringify({
|
|
229
|
+
view: "_error",
|
|
230
|
+
viewData: {
|
|
231
|
+
data: {
|
|
232
|
+
statusCode: 500,
|
|
233
|
+
title: "Internal Server Error",
|
|
234
|
+
userMessage: "An internal server error occurred.",
|
|
235
|
+
report: {
|
|
236
|
+
details: "A JSON parsing error occurred while fetching route data.",
|
|
237
|
+
message: err.message,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
}),
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (resultData && typeof resultData === "object") {
|
|
245
|
+
resultData.__generated = new Date().toISOString();
|
|
246
|
+
}
|
|
247
|
+
if (resultData.queryMonitor) {
|
|
248
|
+
this.debugLogQueryMonitor("props", req.pathname, resultData.queryMonitor);
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
status: resultStatus,
|
|
252
|
+
headers: resultHeaders,
|
|
253
|
+
data: JSON.stringify(resultData),
|
|
254
|
+
};
|
|
255
|
+
},
|
|
70
256
|
});
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
257
|
+
return new Response(result.data, {
|
|
258
|
+
status: result.status,
|
|
259
|
+
headers: result.headers,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
async fetchAppData() {
|
|
263
|
+
const data = await swr({
|
|
264
|
+
key: "fetchAppData",
|
|
265
|
+
cache: pageCache,
|
|
266
|
+
getFreshValue: async (ctx) => {
|
|
267
|
+
const response = await this.fetchOrigin("/_appdata", {
|
|
268
|
+
cache: "no-cache",
|
|
269
|
+
replaceUrls: true,
|
|
270
|
+
headers: {
|
|
271
|
+
"Content-Type": "application/json",
|
|
272
|
+
Accept: "application/json",
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
const result = await response.json();
|
|
276
|
+
const preferredCacheDuration = parseInt(response.headers.get("x-ed-cache-duration") ?? "");
|
|
277
|
+
if (isFinite(preferredCacheDuration)) {
|
|
278
|
+
ctx.metadata.ttl = preferredCacheDuration * 1000;
|
|
279
|
+
}
|
|
280
|
+
if (result.queryMonitor) {
|
|
281
|
+
this.debugLogQueryMonitor("app", "", result.queryMonitor);
|
|
282
|
+
}
|
|
283
|
+
result.__generated = new Date().toISOString();
|
|
284
|
+
return result;
|
|
78
285
|
},
|
|
286
|
+
forceFresh: this.dev,
|
|
79
287
|
});
|
|
288
|
+
return data;
|
|
80
289
|
}
|
|
81
290
|
extractRequestHeaders(req) {
|
|
82
291
|
const headers = {};
|
|
@@ -90,19 +299,57 @@ export class ServerContext {
|
|
|
90
299
|
return headers;
|
|
91
300
|
}
|
|
92
301
|
async fetchNamedQuery(req) {
|
|
93
|
-
const url = `/wp-json/ed/v1/query/${req.name}?params=${encodeURIComponent(JSON.stringify(req.params))}`;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
302
|
+
const url = `/wp-json/ed/v1/query/${req.name.replace(/^\//, "")}?params=${encodeURIComponent(JSON.stringify(req.params))}`;
|
|
303
|
+
const key = `fetchNamedQuery:${req.name}:${JSON.stringify(req.params)}`;
|
|
304
|
+
const fetch = async () => {
|
|
305
|
+
const result = await this.fetchOrigin(url, {
|
|
306
|
+
cache: "no-cache",
|
|
307
|
+
replaceUrls: true,
|
|
308
|
+
headers: {
|
|
309
|
+
...this.extractRequestHeaders(req.headers),
|
|
310
|
+
"Content-Type": "application/json",
|
|
311
|
+
Accept: "application/json",
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
const preferredCacheDuration = parseInt(result.headers.get("x-ed-cache-duration") ?? "");
|
|
315
|
+
let resultStatus = result.status;
|
|
316
|
+
let resultHeaders = result.headers;
|
|
317
|
+
let resultData = await result.json();
|
|
318
|
+
if (resultData && typeof resultData === "object") {
|
|
319
|
+
resultData.__generated = new Date().toISOString();
|
|
320
|
+
}
|
|
321
|
+
if (resultData.queryMonitor) {
|
|
322
|
+
this.debugLogQueryMonitor("query", req.name, resultData.queryMonitor);
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
status: resultStatus,
|
|
326
|
+
headers: resultHeaders,
|
|
327
|
+
data: JSON.stringify(resultData),
|
|
328
|
+
cacheTime: isFinite(preferredCacheDuration) ? preferredCacheDuration * 1000 : undefined,
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
// If headers like 'Authorization' are set, then we shouldn't cache.
|
|
332
|
+
const hasVariedHeaders = VARIES_HEADERS.some((key) => !!req.headers[key]);
|
|
333
|
+
// Get the result, either from cache or by fetching.
|
|
334
|
+
const result = hasVariedHeaders
|
|
335
|
+
? await fetch()
|
|
336
|
+
: await swr({
|
|
337
|
+
key,
|
|
338
|
+
cache: queryCache,
|
|
339
|
+
forceFresh: this.dev,
|
|
340
|
+
getFreshValue: async (ctx) => {
|
|
341
|
+
const result = await fetch();
|
|
342
|
+
ctx.metadata.ttl = result.cacheTime;
|
|
343
|
+
return result;
|
|
344
|
+
},
|
|
345
|
+
});
|
|
346
|
+
return new Response(result.data, {
|
|
347
|
+
status: result.status,
|
|
348
|
+
headers: result.headers,
|
|
102
349
|
});
|
|
103
350
|
}
|
|
104
351
|
async fetchMutation(req) {
|
|
105
|
-
const url = `/wp-json/ed/v1/mutation/${req.name}`;
|
|
352
|
+
const url = `/wp-json/ed/v1/mutation/${req.name.replace(/^\//, "")}`;
|
|
106
353
|
return this.fetchOrigin(url, {
|
|
107
354
|
method: "POST",
|
|
108
355
|
cache: "no-cache",
|
|
@@ -115,4 +362,54 @@ export class ServerContext {
|
|
|
115
362
|
body: JSON.stringify(req.body),
|
|
116
363
|
});
|
|
117
364
|
}
|
|
365
|
+
get allowedCorsOrigins() {
|
|
366
|
+
let result = [];
|
|
367
|
+
if (this.config.serverless.endpoints) {
|
|
368
|
+
result.push(...Object.keys(this.config.serverless.endpoints));
|
|
369
|
+
result.push(...Object.values(this.config.serverless.endpoints));
|
|
370
|
+
result = result.filter((origin) => origin !== "*");
|
|
371
|
+
}
|
|
372
|
+
if (this.config.serverless.cors?.origins) {
|
|
373
|
+
result.push(...this.config.serverless.cors.origins.map((origin) => origin.replace(/(https?:\/\/|\/$)/, "")));
|
|
374
|
+
}
|
|
375
|
+
return result;
|
|
376
|
+
}
|
|
377
|
+
getCorsOrigin(originHeader) {
|
|
378
|
+
const parsed = parseURL(originHeader);
|
|
379
|
+
if (this.allowedCorsOrigins.includes(parsed.host)) {
|
|
380
|
+
return originHeader;
|
|
381
|
+
}
|
|
382
|
+
if (this.allowedCorsOrigins.includes("*")) {
|
|
383
|
+
return "*";
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
getCorsHeaders(origin) {
|
|
387
|
+
if (!origin)
|
|
388
|
+
return {};
|
|
389
|
+
const allowedOrigin = this.getCorsOrigin(origin);
|
|
390
|
+
if (allowedOrigin) {
|
|
391
|
+
return {
|
|
392
|
+
"Access-Control-Allow-Methods": "OPTIONS,GET,HEAD,PUT,PATCH,POST,DELETE",
|
|
393
|
+
"Access-Control-Allow-Origin": allowedOrigin,
|
|
394
|
+
"Access-Control-Allow-Credentials": "true",
|
|
395
|
+
"Access-Control-Allow-Headers": "*",
|
|
396
|
+
"Access-Control-Expose-Headers": "*",
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
return {};
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function indent(count, str) {
|
|
403
|
+
const indent = " ".repeat(count);
|
|
404
|
+
return str
|
|
405
|
+
.split("\n")
|
|
406
|
+
.map((line) => indent + line)
|
|
407
|
+
.join("\n");
|
|
408
|
+
}
|
|
409
|
+
function indentAllButFirst(count, str) {
|
|
410
|
+
const indent = " ".repeat(count);
|
|
411
|
+
return str
|
|
412
|
+
.split("\n")
|
|
413
|
+
.map((line, i) => (i === 0 ? line : indent + line))
|
|
414
|
+
.join("\n");
|
|
118
415
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-custom-config.d.ts","sourceRoot":"","sources":["../../../src/app/server/server-custom-config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,EAAE,CAAA;AAE7B,wBAAgB,kBAAkB,SAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function defineServerConfig() { }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EDConfig } from "../../../node/project/config";
|
|
2
|
+
import { RouteMetaTag, TrackerTags } from "../../lib/routing";
|
|
3
|
+
declare const CSP_KEYS: readonly ["childSrc", "connectSrc", "defaultSrc", "fencedFrameSrc", "fontSrc", "frameSrc", "imgSrc", "manifestSrc", "mediaSrc", "objectSrc", "scriptSrc", "scriptSrcElem", "scriptSrcAttr", "styleSrc", "styleSrcElem", "styleSrcAttr", "workerSrc", "baseUri", "formAction", "frameAncestors", "reportTo", "requireTrustedTypesFor", "trustedTypes", "upgradeInsecureRequests"];
|
|
4
|
+
export type CSPKey = (typeof CSP_KEYS)[number];
|
|
5
|
+
export type CSPParams = Record<CSPKey, Set<string>>;
|
|
6
|
+
export type ContentSecurityPolicyRequestContext = {
|
|
7
|
+
url: string;
|
|
8
|
+
type: "page";
|
|
9
|
+
tags: RouteMetaTag[];
|
|
10
|
+
};
|
|
11
|
+
export declare class SecureHeaderBuilder {
|
|
12
|
+
protected csp: CSPParams;
|
|
13
|
+
protected headers: Headers;
|
|
14
|
+
private cspEnabled;
|
|
15
|
+
private autodetectCspOrigins;
|
|
16
|
+
private useNonce;
|
|
17
|
+
private commonCspOrigins;
|
|
18
|
+
readonly nonce: string | undefined;
|
|
19
|
+
constructor(config: EDConfig);
|
|
20
|
+
addTrackingTags(tags: TrackerTags): TrackerTags;
|
|
21
|
+
addMetaTags(tags: RouteMetaTag[]): RouteMetaTag[];
|
|
22
|
+
getHeaders(): Headers;
|
|
23
|
+
getCSPHeaderValue(): string | undefined;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=content-security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-security.d.ts","sourceRoot":"","sources":["../../../../src/app/server/utils/content-security.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAG7D,QAAA,MAAM,QAAQ,kXAyBJ,CAAA;AAEV,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAA;AAE9C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AAEnD,MAAM,MAAM,mCAAmC,GAAG;IAChD,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,YAAY,EAAE,CAAA;CACrB,CAAA;AAED,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,GAAG,EAAE,SAAS,CAAA;IACxB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAgB;IAE1C,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,oBAAoB,CAAO;IACnC,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,gBAAgB,CAAe;IAEvC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;gBAEtB,MAAM,EAAE,QAAQ;IAgC5B,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IAkB/C,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE;IAkBhC,UAAU,IAAI,OAAO;IAWrB,iBAAiB,IAAI,MAAM,GAAG,SAAS;CAexC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import buildCsp from "content-security-policy-builder";
|
|
2
|
+
const CSP_KEYS = [
|
|
3
|
+
"childSrc",
|
|
4
|
+
"connectSrc",
|
|
5
|
+
"defaultSrc",
|
|
6
|
+
"fencedFrameSrc",
|
|
7
|
+
"fontSrc",
|
|
8
|
+
"frameSrc",
|
|
9
|
+
"imgSrc",
|
|
10
|
+
"manifestSrc",
|
|
11
|
+
"mediaSrc",
|
|
12
|
+
"objectSrc",
|
|
13
|
+
"scriptSrc",
|
|
14
|
+
"scriptSrcElem",
|
|
15
|
+
"scriptSrcAttr",
|
|
16
|
+
"styleSrc",
|
|
17
|
+
"styleSrcElem",
|
|
18
|
+
"styleSrcAttr",
|
|
19
|
+
"workerSrc",
|
|
20
|
+
"baseUri",
|
|
21
|
+
"formAction",
|
|
22
|
+
"frameAncestors",
|
|
23
|
+
"reportTo",
|
|
24
|
+
"requireTrustedTypesFor",
|
|
25
|
+
"trustedTypes",
|
|
26
|
+
"upgradeInsecureRequests",
|
|
27
|
+
];
|
|
28
|
+
export class SecureHeaderBuilder {
|
|
29
|
+
csp;
|
|
30
|
+
headers = new Headers();
|
|
31
|
+
cspEnabled = false;
|
|
32
|
+
autodetectCspOrigins = true;
|
|
33
|
+
useNonce = false;
|
|
34
|
+
commonCspOrigins = [];
|
|
35
|
+
nonce;
|
|
36
|
+
constructor(config) {
|
|
37
|
+
this.cspEnabled = config.serverless.csp.enabled;
|
|
38
|
+
this.autodetectCspOrigins = config.serverless.csp.autoDetect;
|
|
39
|
+
this.useNonce = config.serverless.csp.nonce;
|
|
40
|
+
this.commonCspOrigins = config.serverless.csp.commonOrigins ?? [];
|
|
41
|
+
if (this.useNonce) {
|
|
42
|
+
this.nonce = crypto.randomUUID();
|
|
43
|
+
}
|
|
44
|
+
// Default CSP header parameters
|
|
45
|
+
this.csp = {};
|
|
46
|
+
for (let key of CSP_KEYS) {
|
|
47
|
+
const defaults = [];
|
|
48
|
+
if (key.match(/Src$/i)) {
|
|
49
|
+
defaults.push("'self'");
|
|
50
|
+
if (this.commonCspOrigins.length) {
|
|
51
|
+
defaults.push(...this.commonCspOrigins);
|
|
52
|
+
}
|
|
53
|
+
if (config.serverless.csp.values) {
|
|
54
|
+
const value = config.serverless.csp.values[key];
|
|
55
|
+
if (value) {
|
|
56
|
+
defaults.push(...value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (this.useNonce && !defaults.includes("'unsafe-inline'")) {
|
|
60
|
+
defaults.push(`'nonce-${this.nonce}'`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this.csp[key] = new Set(defaults);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
addTrackingTags(tags) {
|
|
67
|
+
if (!this.autodetectCspOrigins || !this.cspEnabled)
|
|
68
|
+
return tags;
|
|
69
|
+
const handle = (value) => {
|
|
70
|
+
if (value) {
|
|
71
|
+
return value.replaceAll(/<(script|style)/g, (tag) => {
|
|
72
|
+
return tag + ` nonce="${this.nonce}"`;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
head: handle(tags.head),
|
|
78
|
+
body: handle(tags.body),
|
|
79
|
+
footer: handle(tags.footer),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
addMetaTags(tags) {
|
|
83
|
+
if (!this.autodetectCspOrigins || !this.cspEnabled)
|
|
84
|
+
return tags;
|
|
85
|
+
return tags.map((tag) => {
|
|
86
|
+
if (this.nonce) {
|
|
87
|
+
if (tag.tagName === "script" || tag.tagName === "style") {
|
|
88
|
+
return {
|
|
89
|
+
...tag,
|
|
90
|
+
attributes: {
|
|
91
|
+
...tag.attributes,
|
|
92
|
+
nonce: this.nonce,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return tag;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
getHeaders() {
|
|
101
|
+
const result = new Headers(this.headers);
|
|
102
|
+
const cspHeaderValue = this.getCSPHeaderValue();
|
|
103
|
+
if (cspHeaderValue) {
|
|
104
|
+
result.set("Content-Security-Policy", cspHeaderValue);
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
getCSPHeaderValue() {
|
|
109
|
+
if (!this.cspEnabled)
|
|
110
|
+
return undefined;
|
|
111
|
+
const directives = [];
|
|
112
|
+
for (let key of CSP_KEYS) {
|
|
113
|
+
if (this.csp[key].size > 0) {
|
|
114
|
+
directives.push([key, Array.from(this.csp[key])]);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (directives.length) {
|
|
118
|
+
return buildCsp({
|
|
119
|
+
directives: Object.fromEntries(directives),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../../src/app/server/utils/headers.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,WAOrE;AAED,eAAO,MAAM,eAAe;;CAE3B,CAAA;AAYD,wBAAgB,cAAc,CAAC,UAAU,EAAE,OAAO,0BAOjD"}
|
|
@@ -7,4 +7,5 @@ export type UrlReplacerConf = {
|
|
|
7
7
|
replace: boolean;
|
|
8
8
|
}[];
|
|
9
9
|
};
|
|
10
|
-
export declare function createUrlReplacer(conf: UrlReplacerConf): (text: string) => string;
|
|
10
|
+
export declare function createUrlReplacer(conf: UrlReplacerConf): (text: string, newOrigin?: string) => string;
|
|
11
|
+
//# sourceMappingURL=replace-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-host.d.ts","sourceRoot":"","sources":["../../../../src/app/server/utils/replace-host.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,0FAA0F;IAC1F,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CACjD,CAAA;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,UAIvC,MAAM,cAAc,MAAM,YAiEzC"}
|
|
@@ -2,7 +2,7 @@ export function createUrlReplacer(conf) {
|
|
|
2
2
|
// Create a regular expression to match the URL
|
|
3
3
|
// Note that that the regex doesn't necessarily match the entire URL
|
|
4
4
|
const lookup = new RegExp(conf.from.replace(/https?[:\\\/]+/, "https?[:\\/\\\\]+") + "([a-z0-9\\-_/\\\\]+)", "ig");
|
|
5
|
-
return (text) => {
|
|
5
|
+
return (text, newOrigin) => {
|
|
6
6
|
return text.replace(lookup, (url) => {
|
|
7
7
|
// Strip out the origin, to create a relative path
|
|
8
8
|
const path = url.replace(/https?:[\/\\]+[^\/\\]+/, "");
|
|
@@ -18,10 +18,18 @@ export function createUrlReplacer(conf) {
|
|
|
18
18
|
return url;
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
|
|
21
|
+
break;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
if (newOrigin) {
|
|
26
|
+
if (isEscaped) {
|
|
27
|
+
return newOrigin.replace(/\//g, "\\/") + path;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return newOrigin + path;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
25
33
|
return path;
|
|
26
34
|
// if (path.startsWith("/wp-content/uploads/")) {
|
|
27
35
|
// if (!conf.ignoreUploads) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swr-cache.d.ts","sourceRoot":"","sources":["../../../../src/app/server/utils/swr-cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,EAAY,gBAAgB,EAAmB,MAAM,qBAAqB,CAAA;AAuB/G,eAAO,MAAM,SAAS,YAAgB,CAAA;AACtC,eAAO,MAAM,UAAU,YAAgB,CAAA;AAEvC,wBAAgB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,cAO/C"}
|