eddev 2.0.0-beta.2 → 2.0.0-beta.21
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/app/entry/boot-admin.d.ts +1 -0
- package/dist/app/entry/{main.admin.js → boot-admin.js} +3 -5
- package/dist/app/entry/spa-root.d.ts +1 -0
- package/dist/app/entry/{Root.js → spa-root.js} +4 -4
- package/dist/app/entry/ssr-root-client.d.ts +4 -0
- package/dist/app/entry/ssr-root-client.js +9 -0
- package/dist/app/entry/ssr-root.d.ts +9 -0
- package/dist/app/entry/ssr-root.js +21 -0
- package/dist/app/lib/admin/index.d.ts +2 -2
- package/dist/app/lib/admin/index.js +2 -2
- package/dist/app/lib/admin/installFieldTypes.js +1 -1
- package/dist/app/lib/admin/runWidgets.js +1 -1
- package/dist/app/lib/blocks/ContentBlocks.js +4 -4
- package/dist/app/lib/blocks/EditableText.d.ts +1 -1
- package/dist/app/lib/blocks/EditableText.js +2 -2
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +1 -1
- package/dist/app/lib/blocks/InnerBlocks.d.ts +2 -2
- package/dist/app/lib/blocks/InnerBlocks.js +4 -4
- package/dist/app/lib/blocks/block-utils.d.ts +1 -1
- package/dist/app/lib/blocks/block-utils.js +1 -1
- package/dist/app/lib/blocks/editor/EditorSupport.js +3 -3
- package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +1 -1
- package/dist/app/lib/blocks/editor/editor-config.d.ts +1 -1
- package/dist/app/lib/blocks/editor/editor-config.js +1 -1
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +5 -5
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
- package/dist/app/lib/blocks/index.d.ts +9 -9
- package/dist/app/lib/blocks/index.js +9 -9
- package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
- package/dist/app/lib/blocks/inline-editing.js +3 -3
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +5 -3
- package/dist/app/lib/devtools/components/DevUI.js +1 -1
- package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
- package/dist/app/lib/devtools/dev-tools-store.js +8 -0
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1078 -1079
- package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
- package/dist/app/lib/devtools/index.d.ts +1 -0
- package/dist/app/lib/devtools/index.js +1 -1
- package/dist/app/lib/devtools/loader.js +4 -4
- package/dist/app/lib/dynamic/index.d.ts +1 -1
- package/dist/app/lib/dynamic/index.js +1 -1
- package/dist/app/lib/hooks/index.d.ts +5 -5
- package/dist/app/lib/hooks/index.js +5 -5
- package/dist/app/lib/hooks/queryUtils.d.ts +4 -1
- package/dist/app/lib/hooks/queryUtils.js +10 -13
- package/dist/app/lib/hooks/useAppData.js +1 -1
- package/dist/app/lib/internal/index.d.ts +4 -4
- package/dist/app/lib/internal/index.js +4 -4
- package/dist/app/lib/internal/internal-store.d.ts +0 -2
- package/dist/app/lib/internal/internal-store.js +1 -3
- package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +3 -511
- package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
- package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/index.js +1 -1
- package/dist/app/lib/routing/components/BrowserRouter.js +4 -4
- package/dist/app/lib/routing/components/ClientOnly.d.ts +1 -1
- package/dist/app/lib/routing/components/ClientOnly.js +1 -1
- package/dist/app/lib/routing/components/Link.js +5 -5
- package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
- package/dist/app/lib/routing/components/RouteRenderer.js +3 -3
- package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
- package/dist/app/lib/routing/components/SSRRouter.js +4 -4
- package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
- package/dist/app/lib/routing/context.d.ts +2 -2
- package/dist/app/lib/routing/context.js +1 -1
- package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
- package/dist/app/lib/routing/hooks/useRoute.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRoute.js +1 -1
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
- package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouter.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
- package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
- package/dist/app/lib/routing/index.d.ts +13 -13
- package/dist/app/lib/routing/index.js +13 -13
- package/dist/app/lib/routing/loader.d.ts +2 -2
- package/dist/app/lib/routing/loader.js +7 -5
- package/dist/app/lib/routing/types.d.ts +2 -2
- package/dist/app/lib/routing/utils.d.ts +1 -1
- package/dist/app/lib/views/index.d.ts +1 -1
- package/dist/app/lib/views/index.js +1 -1
- package/dist/app/server/index.d.ts +3 -0
- package/dist/app/server/index.js +3 -0
- package/dist/app/server/proxy-wp-admin.d.ts +3 -0
- package/dist/app/server/proxy-wp-admin.js +105 -0
- package/dist/app/server/render-ssr-page.d.ts +3 -0
- package/dist/app/server/render-ssr-page.js +21 -0
- package/dist/app/server/server-context.d.ts +37 -0
- package/dist/app/server/server-context.js +118 -0
- package/dist/app/server/utils/headers.d.ts +1 -0
- package/dist/app/server/utils/headers.js +17 -0
- package/dist/app/server/utils/replace-host.d.ts +6 -4
- package/dist/app/server/utils/replace-host.js +58 -11
- package/dist/node/cli/cli-worker.d.ts +1 -1
- package/dist/node/cli/cli-worker.js +7 -2
- package/dist/node/cli/cli.js +83 -12
- package/dist/node/cli/display/CLIApp.d.ts +1 -1
- package/dist/node/cli/display/CLIApp.js +3 -6
- package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
- package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
- package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
- package/dist/node/cli/display/tools/cli-tools.js +9 -9
- package/dist/node/cli/display/util/colors.d.ts +2 -2
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/build-vinxi.d.ts +8 -0
- package/dist/node/compiler/build-vinxi.js +37 -0
- package/dist/node/compiler/bundler.admin.d.ts +2 -2
- package/dist/node/compiler/bundler.admin.js +3 -4
- package/dist/node/compiler/bundler.frontend.d.ts +1 -1
- package/dist/node/compiler/bundler.frontend.js +3 -4
- package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
- package/dist/node/compiler/dev-server.js +97 -0
- package/dist/node/compiler/get-vite-config.d.ts +19 -0
- package/dist/node/compiler/get-vite-config.js +201 -0
- package/dist/node/compiler/vinxi-app.d.ts +10 -0
- package/dist/node/compiler/vinxi-app.js +121 -0
- package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
- package/dist/node/compiler/vinxi-codegen.js +417 -0
- package/dist/node/graphql/graphql-codegen.d.ts +1 -1
- package/dist/node/graphql/graphql-codegen.js +3 -3
- package/dist/node/graphql/graphql-schema-loader.js +15 -18
- package/dist/node/project/config.js +1 -1
- package/dist/node/project/env.d.ts +1 -1
- package/dist/node/project/env.js +1 -1
- package/dist/node/project/favicons.d.ts +1 -0
- package/dist/node/project/favicons.js +1 -1
- package/dist/node/project/manifest/block-manifest.js +2 -2
- package/dist/node/project/manifest/manifest.d.ts +1 -1
- package/dist/node/project/manifest/manifest.js +1 -1
- package/dist/node/project/manifest/view-manifest.js +2 -2
- package/dist/node/project/project.d.ts +3 -2
- package/dist/node/project/project.js +17 -19
- package/dist/node/project/wp-info.js +0 -2
- package/dist/node/types/block-type.d.ts +2 -2
- package/dist/node/types/view-type.js +3 -4
- package/dist/node/utils/fs-codegen.d.ts +40 -0
- package/dist/node/utils/fs-codegen.js +97 -0
- package/dist/node/utils/fs.js +2 -0
- package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
- package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
- package/package.json +29 -31
- package/tsconfig.app.json +2 -2
- package/tsconfig.node.json +2 -2
- package/types.app.d.ts +2 -2
- package/types.app.internal.d.ts +2 -2
- package/types.node.d.ts +3 -3
- package/dist/app/entry/Root.d.ts +0 -1
- package/dist/app/entry/main.admin.d.ts +0 -3
- package/dist/app/entry/main.frontend.spa.d.ts +0 -3
- package/dist/app/entry/main.frontend.spa.js +0 -13
- package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
- package/dist/app/entry/main.frontend.ssr.js +0 -79
- package/dist/app/entry/main.serverless.dev.d.ts +0 -4
- package/dist/app/entry/main.serverless.dev.js +0 -21
- package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
- package/dist/app/server/create-api-builtin-hono.js +0 -80
- package/dist/app/server/create-ssr-hono.d.ts +0 -18
- package/dist/app/server/create-ssr-hono.js +0 -104
- package/dist/app/server/utils/index.html.d.ts +0 -2
- package/dist/app/server/utils/index.html.js +0 -14
- package/dist/node/compiler/index.html.d.ts +0 -2
- package/dist/node/compiler/index.html.js +0 -15
- package/dist/node/compiler/serverless.dev.js +0 -215
- package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
- package/dist/node/compiler/vite/get-vite-config.js +0 -315
- package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-admin.js +0 -67
- package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-blocks.js +0 -73
- package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
- package/dist/node/compiler/vite/plugin-entry.js +0 -16
- package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
- package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-theme.js +0 -40
- package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-views.js +0 -51
- package/dist/node/utils/console.d.ts +0 -21
- package/dist/node/utils/console.js +0 -28
- package/dist/node/utils/unsafe-fetch.d.ts +0 -2
- package/dist/node/utils/unsafe-fetch.js +0 -19
- package/tsup.config.ts +0 -40
- package/types.manifests.d.ts +0 -22
- /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
- /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
- /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
- /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
- /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
- /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
- /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
- /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
- /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
- /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
- /package/dist/node/utils/{watchFileTree.d.ts → watch-file-tree.d.ts} +0 -0
- /package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Suspense } from "react";
|
|
3
|
-
import { RouterContext, RouterStateContext } from "../context";
|
|
4
|
-
import { useRouter } from "../hooks/useRouter";
|
|
5
|
-
import { useRouterState } from "../hooks/useRouterState";
|
|
6
|
-
import { AppRenderer } from "./RouteRenderer";
|
|
3
|
+
import { RouterContext, RouterStateContext } from "../context.js";
|
|
4
|
+
import { useRouter } from "../hooks/useRouter.js";
|
|
5
|
+
import { useRouterState } from "../hooks/useRouterState.js";
|
|
6
|
+
import { AppRenderer } from "./RouteRenderer.js";
|
|
7
7
|
export function SSRRouter(props) {
|
|
8
8
|
const router = useRouter();
|
|
9
9
|
const routerState = useRouterState();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from "react";
|
|
2
|
-
import { RouterAPI, RouterAPIState } from "./types";
|
|
2
|
+
import { RouterAPI, RouterAPIState } from "./types.js";
|
|
3
3
|
export declare const RouterContext: Context<RouterAPI>;
|
|
4
4
|
export declare const RouterStateContext: Context<RouterAPIState>;
|
|
5
|
-
export declare const RouteItemContext: Context<import("./types").TypedRouteState<"_unknown", {}>>;
|
|
5
|
+
export declare const RouteItemContext: Context<import("./types.js").TypedRouteState<"_unknown", {}>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useRouterEvents } from "./useRouterEvents.js";
|
|
3
|
+
import { useRoute } from "./useRoute.js";
|
|
3
4
|
/**
|
|
4
5
|
* Works exactly like useState, but allows back and forward navigation to restore the previous state.
|
|
5
6
|
* You must pass a unique ID as an additional first parameter to ensure the state is restored correctly.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RouteState } from "../types";
|
|
1
|
+
import type { RouteState } from "../types.js";
|
|
2
2
|
export declare function useRoute(): RouteState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RouteState } from "../types";
|
|
1
|
+
import type { RouteState } from "../types.js";
|
|
2
2
|
type TransitionFunction = (currentRoute: RouteState, nextRoute: RouteState) => void | Promise<any | void>;
|
|
3
3
|
export declare function useRouteTransition(func: TransitionFunction): void;
|
|
4
4
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RouterAPI } from "../types";
|
|
1
|
+
import { RouterAPI } from "../types.js";
|
|
2
2
|
export declare function useRouter<T = RouterAPI>(selector?: (r: RouterAPI) => T): T;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RouterEvent } from "../types";
|
|
1
|
+
import type { RouterEvent } from "../types.js";
|
|
2
2
|
export declare function useRouterEvents(handler: (event: RouterEvent) => void): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RouterAPIState } from "../types";
|
|
1
|
+
import { RouterAPIState } from "../types.js";
|
|
2
2
|
export declare function useRouterState<T = RouterAPIState>(selector?: (state: RouterAPIState) => T): T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { useRoute } from "./useRoute";
|
|
3
|
-
import { useRouter } from "./useRouter";
|
|
2
|
+
import { useRoute } from "./useRoute.js";
|
|
3
|
+
import { useRouter } from "./useRouter.js";
|
|
4
4
|
export function useSearchParams(defaultValue) {
|
|
5
5
|
const route = useRoute();
|
|
6
6
|
const replaceQuery = useRouter((r) => r.replaceQuery);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
|
-
export * from "./components/Link";
|
|
3
|
-
export * from "./components/ScrollRestoration";
|
|
4
|
-
export * from "./components/RouteRenderer";
|
|
5
|
-
export * from "./components/ClientOnly";
|
|
6
|
-
export * from "./hooks/useRoute";
|
|
7
|
-
export * from "./hooks/useRouteTransition";
|
|
8
|
-
export * from "./hooks/useRouter";
|
|
9
|
-
export * from "./hooks/useRouterEvents";
|
|
10
|
-
export * from "./hooks/useRouterState";
|
|
11
|
-
export * from "./hooks/useRestorableState";
|
|
12
|
-
export * from "./hooks/useIsSSR";
|
|
13
|
-
export * from "./hooks/useSearchParams";
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./components/Link.js";
|
|
3
|
+
export * from "./components/ScrollRestoration.js";
|
|
4
|
+
export * from "./components/RouteRenderer.js";
|
|
5
|
+
export * from "./components/ClientOnly.js";
|
|
6
|
+
export * from "./hooks/useRoute.js";
|
|
7
|
+
export * from "./hooks/useRouteTransition.js";
|
|
8
|
+
export * from "./hooks/useRouter.js";
|
|
9
|
+
export * from "./hooks/useRouterEvents.js";
|
|
10
|
+
export * from "./hooks/useRouterState.js";
|
|
11
|
+
export * from "./hooks/useRestorableState.js";
|
|
12
|
+
export * from "./hooks/useIsSSR.js";
|
|
13
|
+
export * from "./hooks/useSearchParams.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
|
-
export * from "./components/Link";
|
|
3
|
-
export * from "./components/ScrollRestoration";
|
|
4
|
-
export * from "./components/RouteRenderer";
|
|
5
|
-
export * from "./components/ClientOnly";
|
|
6
|
-
export * from "./hooks/useRoute";
|
|
7
|
-
export * from "./hooks/useRouteTransition";
|
|
8
|
-
export * from "./hooks/useRouter";
|
|
9
|
-
export * from "./hooks/useRouterEvents";
|
|
10
|
-
export * from "./hooks/useRouterState";
|
|
11
|
-
export * from "./hooks/useRestorableState";
|
|
12
|
-
export * from "./hooks/useIsSSR";
|
|
13
|
-
export * from "./hooks/useSearchParams";
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./components/Link.js";
|
|
3
|
+
export * from "./components/ScrollRestoration.js";
|
|
4
|
+
export * from "./components/RouteRenderer.js";
|
|
5
|
+
export * from "./components/ClientOnly.js";
|
|
6
|
+
export * from "./hooks/useRoute.js";
|
|
7
|
+
export * from "./hooks/useRouteTransition.js";
|
|
8
|
+
export * from "./hooks/useRouter.js";
|
|
9
|
+
export * from "./hooks/useRouterEvents.js";
|
|
10
|
+
export * from "./hooks/useRouterState.js";
|
|
11
|
+
export * from "./hooks/useRestorableState.js";
|
|
12
|
+
export * from "./hooks/useIsSSR.js";
|
|
13
|
+
export * from "./hooks/useSearchParams.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent, PropsWithChildren } from "react";
|
|
2
|
-
import { DynamicComponent } from "../dynamic/dynamic";
|
|
3
|
-
import { RouteData } from "./types";
|
|
2
|
+
import { DynamicComponent } from "../dynamic/dynamic.js";
|
|
3
|
+
import { RouteData } from "./types.js";
|
|
4
4
|
export type RouteCacheEntry = {
|
|
5
5
|
data: RouteData;
|
|
6
6
|
component: FunctionComponent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseURL, stringifyParsedURL, stringifyQuery, withTrailingSlash } from "ufo";
|
|
2
|
-
import { viewManifestReader } from "../internal";
|
|
2
|
+
import { viewManifestReader } from "../internal/read-view-manifest.js";
|
|
3
3
|
export class RouteError extends Error {
|
|
4
4
|
message;
|
|
5
5
|
statusCode;
|
|
@@ -31,10 +31,12 @@ export class RouteLoader {
|
|
|
31
31
|
const origin = parseURL(sampleUrl);
|
|
32
32
|
let propsPath = withTrailingSlash(pathname);
|
|
33
33
|
let query = {};
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
query
|
|
37
|
-
query["
|
|
34
|
+
if (env.serverless && env.client) {
|
|
35
|
+
propsPath = "/_data/route" + propsPath;
|
|
36
|
+
query = {};
|
|
37
|
+
// query["_debug"] = opts.debug ? "1" : "0"
|
|
38
|
+
// query["_props"] = opts.appData ? "all" : "1"
|
|
39
|
+
// query["_ssr"] = "1"
|
|
38
40
|
}
|
|
39
41
|
else {
|
|
40
42
|
query["_debug"] = opts.debug ? "1" : "0";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent } from "react";
|
|
2
|
-
import type { RouteLoader } from "./loader";
|
|
3
|
-
import { LinkHandlerMode, PointerOrMouseEvent } from "./utils";
|
|
2
|
+
import type { RouteLoader } from "./loader.js";
|
|
3
|
+
import { LinkHandlerMode, PointerOrMouseEvent } from "./utils.js";
|
|
4
4
|
export type ParsedRouteTags = Record<"title" | "meta" | "script" | "style" | "link", {
|
|
5
5
|
[key: string]: string;
|
|
6
6
|
}[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MouseEvent as ReactMouseEvent, PointerEvent as ReactPointerEvent } from "react";
|
|
2
|
-
import { RouteLink, RouteState } from "./types";
|
|
2
|
+
import { RouteLink, RouteState } from "./types.js";
|
|
3
3
|
export declare function isSameOrigin(url: string): boolean;
|
|
4
4
|
export type PointerOrMouseEvent = MouseEvent | PointerEvent | ReactMouseEvent | ReactPointerEvent;
|
|
5
5
|
export type LinkHandlerMode = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./defineView";
|
|
1
|
+
export * from "./defineView.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./defineView";
|
|
1
|
+
export * from "./defineView.js";
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/// <reference types="vinxi/types/server" />
|
|
2
|
+
import { splitSetCookieString } from "cookie-es";
|
|
3
|
+
import { getProxyRequestHeaders, getRequestURL, getWebRequest } from "vinxi/http";
|
|
4
|
+
export async function proxyWpAdmin(event, serverContext) {
|
|
5
|
+
const replaceUrls = serverContext.replaceUrls;
|
|
6
|
+
const req = getWebRequest(event);
|
|
7
|
+
const proxyUrl = serverContext.getOriginUrl(getRequestURL(event).href);
|
|
8
|
+
// Prepare request headers to be sent to the origin server
|
|
9
|
+
const proxyHeaders = getProxyRequestHeaders(event);
|
|
10
|
+
proxyHeaders["X-ED-Dev-Proxy"] = "true";
|
|
11
|
+
// Forward the request to the origin server
|
|
12
|
+
const response = await fetch(proxyUrl, {
|
|
13
|
+
method: req.method,
|
|
14
|
+
referrer: req.referrer,
|
|
15
|
+
referrerPolicy: req.referrerPolicy,
|
|
16
|
+
headers: proxyHeaders,
|
|
17
|
+
body: req.method.match(/get|head|options/i) ? undefined : await req.blob(),
|
|
18
|
+
redirect: "manual",
|
|
19
|
+
cache: "no-cache",
|
|
20
|
+
});
|
|
21
|
+
const contentType = response.headers.get("content-type");
|
|
22
|
+
let body;
|
|
23
|
+
let res = { status: response.status, statusText: response.statusText, headers: new Headers() };
|
|
24
|
+
const cookies = [];
|
|
25
|
+
response.headers.forEach((value, key) => {
|
|
26
|
+
if (key === "content-encoding" || key === "content-length" || key === "transfer-encoding") {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (key === "set-cookie") {
|
|
30
|
+
cookies.push(...splitSetCookieString(value));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (key === "location" && replaceUrls) {
|
|
34
|
+
value = replaceUrls(value);
|
|
35
|
+
}
|
|
36
|
+
res.headers.set(key, value);
|
|
37
|
+
});
|
|
38
|
+
// Set cookies in the response headers
|
|
39
|
+
// TODO: May need to rewrite cookie domain here before setting.
|
|
40
|
+
if (cookies.length > 0) {
|
|
41
|
+
for (const cookie of cookies) {
|
|
42
|
+
res.headers.append("set-cookie", cookie);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Replace URLs pointing to the origin server from the response itself
|
|
46
|
+
// This is only done for text-based content types, like application/json, text/plain, text/html etc
|
|
47
|
+
if (contentType?.match(/(application|text)\//)) {
|
|
48
|
+
if (replaceUrls) {
|
|
49
|
+
body = replaceUrls((await response.text()) ?? "");
|
|
50
|
+
}
|
|
51
|
+
// If the content type is text/html, inject the Vite assets into the response — assuming the placeholder comments are found
|
|
52
|
+
if (contentType.startsWith("text/html")) {
|
|
53
|
+
const clientManifest = serverContext.getManifest("admin");
|
|
54
|
+
const assets = await clientManifest.inputs[clientManifest.handler].assets();
|
|
55
|
+
body = body.replace("<!---VITE_HEADER--->", () => assets.map((asset) => renderAsset(asset)).join("\n"));
|
|
56
|
+
body = body.replace("<!---VITE_FOOTER--->", () => renderAsset({
|
|
57
|
+
tag: "script",
|
|
58
|
+
attrs: {
|
|
59
|
+
type: "module",
|
|
60
|
+
src: clientManifest.inputs[clientManifest.handler].output.path,
|
|
61
|
+
},
|
|
62
|
+
children: "",
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Otherwise just stream the response as is
|
|
68
|
+
body = response.body;
|
|
69
|
+
}
|
|
70
|
+
return new Response(body, res);
|
|
71
|
+
}
|
|
72
|
+
function printElement(element, props, innerText) {
|
|
73
|
+
if (typeof innerText === "string") {
|
|
74
|
+
return `<${element}${Object.entries(props)
|
|
75
|
+
.map(([key, value]) => ` ${key}="${value}"`)
|
|
76
|
+
.join("")}>${innerText}</${element}>`;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return `<${element}${Object.entries(props)
|
|
80
|
+
.map(([key, value]) => ` ${key}="${value}"`)
|
|
81
|
+
.join("")} />`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function renderAsset({ tag, attrs: { key, ...attrs } = {}, children, }) {
|
|
85
|
+
switch (tag) {
|
|
86
|
+
case "script":
|
|
87
|
+
if (attrs.src) {
|
|
88
|
+
return printElement("script", { ...attrs, key: attrs.src }, "");
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
return printElement("script", {
|
|
92
|
+
...attrs,
|
|
93
|
+
key: key,
|
|
94
|
+
}, children ?? "");
|
|
95
|
+
}
|
|
96
|
+
case "link":
|
|
97
|
+
return printElement("link", { ...attrs, key: key });
|
|
98
|
+
case "style":
|
|
99
|
+
return printElement("style", {
|
|
100
|
+
...attrs,
|
|
101
|
+
key: key,
|
|
102
|
+
}, children ?? "");
|
|
103
|
+
}
|
|
104
|
+
return "";
|
|
105
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { renderAsset } from "@vinxi/react";
|
|
3
|
+
import { Suspense } from "react";
|
|
4
|
+
import { renderToPipeableStream } from "react-dom/server";
|
|
5
|
+
import { SSRRoot } from "../entry/ssr-root.js";
|
|
6
|
+
import { RouteLoader } from "../lib/routing/loader.js";
|
|
7
|
+
export async function renderPageToSSRStream(pathname, initialData, serverContext) {
|
|
8
|
+
const clientManifest = serverContext.getManifest("client");
|
|
9
|
+
const assets = await clientManifest.inputs[clientManifest.handler].assets();
|
|
10
|
+
const jsx = (_jsx(SSRRoot, { assets: _jsx(Suspense, { children: assets.map((m) => renderAsset(m)) }), pathname: pathname, initialData: initialData, loader: new RouteLoader() }));
|
|
11
|
+
const stream = await new Promise(async (resolve) => {
|
|
12
|
+
const stream = renderToPipeableStream(jsx, {
|
|
13
|
+
onShellReady() {
|
|
14
|
+
resolve(stream);
|
|
15
|
+
},
|
|
16
|
+
bootstrapModules: [clientManifest.inputs[clientManifest.handler].output.path],
|
|
17
|
+
bootstrapScriptContent: `window.manifest = ${JSON.stringify(await clientManifest.json())}; window._PAGE_DATA = ${JSON.stringify(initialData)}`,
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
return stream;
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RequestHeaders } from "vinxi/http";
|
|
2
|
+
import { UrlReplacerConf } from "./utils/replace-host.js";
|
|
3
|
+
import { Manifest } from "vinxi/dist/types/types/manifest";
|
|
4
|
+
export type ServerContextArgs = {
|
|
5
|
+
dev: boolean;
|
|
6
|
+
origin: string;
|
|
7
|
+
getManifest: (name: string) => Manifest;
|
|
8
|
+
replaceUrls?: UrlReplacerConf;
|
|
9
|
+
};
|
|
10
|
+
export declare class ServerContext {
|
|
11
|
+
dev: boolean;
|
|
12
|
+
origin: string;
|
|
13
|
+
getManifest: (name: string) => Manifest;
|
|
14
|
+
replaceUrls?: (text: string) => string;
|
|
15
|
+
constructor(conf: ServerContextArgs);
|
|
16
|
+
getOriginUrl(url: string): string;
|
|
17
|
+
fetchOrigin(url: string, opts?: RequestInit & {
|
|
18
|
+
replaceUrls?: boolean;
|
|
19
|
+
}): Promise<Response>;
|
|
20
|
+
fetchRouteData(req: {
|
|
21
|
+
pathname: string;
|
|
22
|
+
query?: Record<string, any>;
|
|
23
|
+
headers?: RequestHeaders;
|
|
24
|
+
withAppData?: boolean;
|
|
25
|
+
}): Promise<Response>;
|
|
26
|
+
extractRequestHeaders(req?: RequestHeaders): Partial<Record<import("vinxi/http").HTTPHeaderName, string | undefined>>;
|
|
27
|
+
fetchNamedQuery(req: {
|
|
28
|
+
name: string;
|
|
29
|
+
params: object;
|
|
30
|
+
headers: RequestHeaders;
|
|
31
|
+
}): Promise<Response>;
|
|
32
|
+
fetchMutation(req: {
|
|
33
|
+
name: string;
|
|
34
|
+
body: object;
|
|
35
|
+
headers: RequestHeaders;
|
|
36
|
+
}): Promise<Response>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { parseURL, stringifyParsedURL, withQuery } from "ufo";
|
|
2
|
+
import { filterHeader } from "./utils/headers.js";
|
|
3
|
+
import { createUrlReplacer } from "./utils/replace-host.js";
|
|
4
|
+
const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control"];
|
|
5
|
+
const PROXY_REQUEST_HEADERS = [
|
|
6
|
+
"content-type",
|
|
7
|
+
"accept",
|
|
8
|
+
"accept-encoding",
|
|
9
|
+
"accept-language",
|
|
10
|
+
"origin",
|
|
11
|
+
"referer",
|
|
12
|
+
"user-agent",
|
|
13
|
+
"authorization",
|
|
14
|
+
];
|
|
15
|
+
export class ServerContext {
|
|
16
|
+
dev;
|
|
17
|
+
origin;
|
|
18
|
+
getManifest;
|
|
19
|
+
replaceUrls;
|
|
20
|
+
constructor(conf) {
|
|
21
|
+
this.dev = conf.dev;
|
|
22
|
+
this.origin = conf.origin;
|
|
23
|
+
this.getManifest = conf.getManifest;
|
|
24
|
+
if (conf.replaceUrls) {
|
|
25
|
+
this.replaceUrls = createUrlReplacer(conf.replaceUrls);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
getOriginUrl(url) {
|
|
29
|
+
const parsed = parseURL(url);
|
|
30
|
+
const parsedOrigin = parseURL(this.origin);
|
|
31
|
+
parsed.host = parsedOrigin.host;
|
|
32
|
+
parsed.protocol = parsedOrigin.protocol;
|
|
33
|
+
return stringifyParsedURL(parsed);
|
|
34
|
+
}
|
|
35
|
+
async fetchOrigin(url, opts) {
|
|
36
|
+
url = this.getOriginUrl(url);
|
|
37
|
+
const response = await fetch(url, {
|
|
38
|
+
...opts,
|
|
39
|
+
headers: {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
Accept: "application/json",
|
|
42
|
+
...opts?.headers,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
return response;
|
|
47
|
+
}
|
|
48
|
+
const headers = {};
|
|
49
|
+
response.headers.forEach((value, key) => {
|
|
50
|
+
if (filterHeader(key, PROXY_RESPONSE_HEADERS)) {
|
|
51
|
+
headers[key] = value;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
let text = await response.text();
|
|
55
|
+
if (opts?.replaceUrls && this.replaceUrls) {
|
|
56
|
+
text = this.replaceUrls(text);
|
|
57
|
+
}
|
|
58
|
+
return new Response(text, {
|
|
59
|
+
status: response.status,
|
|
60
|
+
statusText: response.statusText,
|
|
61
|
+
headers,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async fetchRouteData(req) {
|
|
65
|
+
const fetchUrl = withQuery(req.pathname, {
|
|
66
|
+
...req.query,
|
|
67
|
+
_props: req.withAppData ? "all" : "1",
|
|
68
|
+
_ssr: "1",
|
|
69
|
+
_debug: this.dev ? "1" : undefined,
|
|
70
|
+
});
|
|
71
|
+
return this.fetchOrigin(fetchUrl, {
|
|
72
|
+
cache: "no-cache",
|
|
73
|
+
replaceUrls: true,
|
|
74
|
+
headers: {
|
|
75
|
+
"Content-Type": "application/json",
|
|
76
|
+
Accept: "application/json",
|
|
77
|
+
...this.extractRequestHeaders(req.headers),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
extractRequestHeaders(req) {
|
|
82
|
+
const headers = {};
|
|
83
|
+
if (req) {
|
|
84
|
+
for (let key of PROXY_REQUEST_HEADERS) {
|
|
85
|
+
if (req[key]) {
|
|
86
|
+
headers[key] = req[key];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return headers;
|
|
91
|
+
}
|
|
92
|
+
async fetchNamedQuery(req) {
|
|
93
|
+
const url = `/wp-json/ed/v1/query/${req.name}?params=${encodeURIComponent(JSON.stringify(req.params))}`;
|
|
94
|
+
return this.fetchOrigin(url, {
|
|
95
|
+
cache: "no-cache",
|
|
96
|
+
replaceUrls: true,
|
|
97
|
+
headers: {
|
|
98
|
+
...this.extractRequestHeaders(req.headers),
|
|
99
|
+
"Content-Type": "application/json",
|
|
100
|
+
Accept: "application/json",
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async fetchMutation(req) {
|
|
105
|
+
const url = `/wp-json/ed/v1/mutation/${req.name}`;
|
|
106
|
+
return this.fetchOrigin(url, {
|
|
107
|
+
method: "POST",
|
|
108
|
+
cache: "no-cache",
|
|
109
|
+
replaceUrls: true,
|
|
110
|
+
headers: {
|
|
111
|
+
...this.extractRequestHeaders(req.headers),
|
|
112
|
+
"Content-Type": "application/json",
|
|
113
|
+
Accept: "application/json",
|
|
114
|
+
},
|
|
115
|
+
body: JSON.stringify(req.body),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -9,3 +9,20 @@ export function filterHeader(key, allowed) {
|
|
|
9
9
|
export const BRANDED_HEADERS = {
|
|
10
10
|
"X-Powered-By": "ed.studio",
|
|
11
11
|
};
|
|
12
|
+
const IGNORE_REQUEST_HEADERS = [
|
|
13
|
+
"host",
|
|
14
|
+
"connection",
|
|
15
|
+
"accept-encoding",
|
|
16
|
+
"accept-language",
|
|
17
|
+
"origin",
|
|
18
|
+
"referer",
|
|
19
|
+
"user-agent",
|
|
20
|
+
];
|
|
21
|
+
export function extractHeaders(rawHeaders) {
|
|
22
|
+
const headers = {};
|
|
23
|
+
rawHeaders.forEach((value, key) => {
|
|
24
|
+
headers[key] = value;
|
|
25
|
+
});
|
|
26
|
+
IGNORE_REQUEST_HEADERS.forEach((key) => delete headers[key]);
|
|
27
|
+
return headers;
|
|
28
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export type UrlReplacerConf = {
|
|
2
2
|
from: string;
|
|
3
3
|
to: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/** A dictionary of prefixes (eg /wp-content), and whether to replace them (true/false) */
|
|
5
|
+
prefixes: {
|
|
6
|
+
prefix: string;
|
|
7
|
+
replace: boolean;
|
|
8
|
+
}[];
|
|
7
9
|
};
|
|
8
|
-
export declare function createUrlReplacer(conf: UrlReplacerConf): (
|
|
10
|
+
export declare function createUrlReplacer(conf: UrlReplacerConf): (text: string) => string;
|