eddev 2.0.0-beta.25 → 2.0.0-beta.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/app/lib/blocks/EditableText.js +1 -1
  2. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +1 -0
  3. package/dist/app/lib/blocks/InnerBlocks.d.ts +11 -1
  4. package/dist/app/lib/blocks/InnerBlocks.js +9 -1
  5. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  6. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  7. package/dist/app/lib/hooks/apiConfig.d.ts +3 -1
  8. package/dist/app/lib/hooks/apiConfig.js +9 -4
  9. package/dist/app/lib/hooks/index.d.ts +0 -1
  10. package/dist/app/lib/hooks/index.js +0 -1
  11. package/dist/app/lib/hooks/queryUtils.d.ts +1 -1
  12. package/dist/app/lib/hooks/queryUtils.js +10 -8
  13. package/dist/app/lib/routing/components/BrowserRouter.js +12 -2
  14. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  15. package/dist/app/lib/routing/components/Link.js +4 -5
  16. package/dist/app/lib/routing/components/RouteRenderer.js +2 -1
  17. package/dist/app/lib/routing/context.js +3 -0
  18. package/dist/app/lib/routing/hooks/useRoute.d.ts +15 -0
  19. package/dist/app/lib/routing/hooks/useRoute.js +21 -0
  20. package/dist/app/lib/routing/types.d.ts +3 -1
  21. package/dist/app/server/defineRouter.d.ts +2 -0
  22. package/dist/app/server/defineRouter.js +4 -0
  23. package/dist/app/server/index.d.ts +1 -0
  24. package/dist/app/server/index.js +1 -0
  25. package/dist/app/server/server-context.js +6 -1
  26. package/dist/node/cli/version.d.ts +1 -1
  27. package/dist/node/cli/version.js +1 -1
  28. package/dist/node/compiler/get-vite-config.js +0 -1
  29. package/dist/node/compiler/vinxi-app.js +19 -5
  30. package/dist/node/compiler/vinxi-codegen.js +1 -1
  31. package/dist/node/graphql/graphql-codegen.js +4 -1
  32. package/package.json +2 -3
  33. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  34. package/dist/app/lib/hooks/usePageLoad.js +0 -5
@@ -7,7 +7,7 @@ export function EditableText({ id, as, appendOnEnter, store, ...props }) {
7
7
  if (!readOnly) {
8
8
  const [value, setValue] = useValueStore(store ?? id);
9
9
  const appendBlocks = useBlockAppender();
10
- return (_jsx(wp.blockEditor.RichText, { ...props, tagName: as, value: value || "", onChange: setValue, disableLineBreaks: props.disableLineBreaks, onKeyDownCapture: (e) => {
10
+ return (_jsx(wp.blockEditor.RichText, { ...props, tagName: as, value: value || "", onChange: setValue, inlineToolbar: props.inlineToolbar, disableLineBreaks: props.disableLineBreaks, onKeyDownCapture: (e) => {
11
11
  if (e.key === "Enter" && appendOnEnter && appendBlocks) {
12
12
  appendBlocks([
13
13
  wp.blocks.createBlock(typeof appendOnEnter === "string" ? appendOnEnter : "core/paragraph"),
@@ -9,6 +9,7 @@ export class ErrorBoundaryFrontend extends Component {
9
9
  return { hasError: true, error: err };
10
10
  }
11
11
  componentDidCatch(error, errorInfo) {
12
+ console.log("Caught error:", error, errorInfo);
12
13
  console.error("Uncaught error:", error, errorInfo);
13
14
  }
14
15
  render() {
@@ -2,9 +2,19 @@ import { FunctionComponent } from "react";
2
2
  import { ContentBlockLayoutProps } from "./ContentBlocks.js";
3
3
  import { BlockTemplate } from "./editor/block-templates.js";
4
4
  type AppenderConfig = {
5
- type: "default" | "button" | FunctionComponent<any>;
5
+ type: "default" | "button" | CustomBlockAppender;
6
6
  className?: string;
7
7
  };
8
+ export type CustomBlockAppender = FunctionComponent<{
9
+ onToggle: () => void;
10
+ disabled: boolean;
11
+ isOpen: boolean;
12
+ blockTitle: string;
13
+ hasSingleBlockType: boolean;
14
+ }>;
15
+ export declare function createAppender(comp: CustomBlockAppender): {
16
+ type: CustomBlockAppender;
17
+ };
8
18
  type InnerBlocksProps = {
9
19
  /** A list of allowed blocks, and/or block tags. */
10
20
  allowedBlocks?: (ChildBlockTypeName | BlockTagName)[];
@@ -9,7 +9,10 @@ const Appender = (props) => {
9
9
  return _jsx(wp.blockEditor.ButtonBlockAppender, { className: props.className, rootClientId: clientId });
10
10
  }
11
11
  else if (typeof props.type === "function") {
12
- return props.type({});
12
+ const Type = props.type;
13
+ return (_jsx(wp.blockEditor.Inserter, { renderToggle: (p) => {
14
+ return _jsx(Type, { ...p });
15
+ }, rootClientId: clientId }));
13
16
  }
14
17
  else {
15
18
  return (_jsx(wp.blockEditor.DefaultBlockAppender
@@ -19,6 +22,11 @@ const Appender = (props) => {
19
22
  className: props.className, rootClientId: clientId, lastBlockClientId: clientId }));
20
23
  }
21
24
  };
25
+ export function createAppender(comp) {
26
+ return {
27
+ type: comp,
28
+ };
29
+ }
22
30
  /**
23
31
  * Allows child blocks to be added to the current block context.
24
32
  */
@@ -6,4 +6,10 @@ export type QueryDebugItem = {
6
6
  children: QueryDebugItem[];
7
7
  };
8
8
  export declare function setQueryDebug(value: QueryDebugItem | undefined): void;
9
- export declare function useQueryDebugData(): QueryDebugItem | undefined;
9
+ export declare function useQueryDebugData(): {
10
+ readonly file: string;
11
+ readonly errors: readonly string[];
12
+ readonly duration: number;
13
+ readonly label: string;
14
+ readonly children: readonly any[];
15
+ } | undefined;
@@ -1,13 +1,10 @@
1
- import { create } from "zustand";
2
- const useQueryDebug = create((set) => ({
1
+ import { proxy, useSnapshot } from "valtio";
2
+ const store = proxy({
3
3
  value: undefined,
4
- set: (value) => {
5
- set({ value });
6
- },
7
- }));
4
+ });
8
5
  export function setQueryDebug(value) {
9
- useQueryDebug.setState({ value });
6
+ store.value = value;
10
7
  }
11
8
  export function useQueryDebugData() {
12
- return useQueryDebug((store) => store.value);
9
+ return useSnapshot(store).value;
13
10
  }
@@ -13,6 +13,8 @@ export type APIConfigStore = {
13
13
  /**
14
14
  * Update aspects of the API client
15
15
  */
16
+ onResponse?: (response: Response) => void;
16
17
  set: (config: Partial<APIConfigStore>) => void;
17
18
  };
18
- export declare const useAPIConfig: import("zustand").UseBoundStore<import("zustand").StoreApi<APIConfigStore>>;
19
+ export declare const apiConfig: APIConfigStore;
20
+ export declare function useAPIConfig(): APIConfigStore;
@@ -1,4 +1,9 @@
1
- import { create } from "zustand";
2
- export const useAPIConfig = create((set, get) => ({
3
- set: (config) => set(config),
4
- }));
1
+ import { proxy } from "valtio";
2
+ export const apiConfig = proxy({
3
+ set: (config) => {
4
+ Object.assign(apiConfig, config);
5
+ },
6
+ });
7
+ export function useAPIConfig() {
8
+ return apiConfig;
9
+ }
@@ -1,4 +1,3 @@
1
- export * from "./usePageLoad.js";
2
1
  export * from "./useAppData.js";
3
2
  export * from "./useRPC.js";
4
3
  export * from "./queryUtils.js";
@@ -1,4 +1,3 @@
1
- export * from "./usePageLoad.js";
2
1
  export * from "./useAppData.js";
3
2
  export * from "./useRPC.js";
4
3
  export * from "./queryUtils.js";
@@ -1,4 +1,4 @@
1
- import { FetchQueryOptions, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryResult, UseInfiniteQueryResult, UndefinedInitialDataInfiniteOptions } from "@tanstack/react-query";
1
+ import { FetchQueryOptions, UndefinedInitialDataInfiniteOptions, UndefinedInitialDataOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryResult } from "@tanstack/react-query";
2
2
  type OptionalMaybes<T> = T extends any[] ? T : T extends {
3
3
  [key: string]: any;
4
4
  } ? {
@@ -1,8 +1,8 @@
1
- import { useMutation, useQuery, useInfiniteQuery, } from "@tanstack/react-query";
1
+ import { useInfiniteQuery, useMutation, useQuery, } from "@tanstack/react-query";
2
+ import { useEffect, useState } from "react";
2
3
  import { joinURL } from "ufo";
3
4
  import { getQueryClient } from "../../utils/query-client.js";
4
- import { useAPIConfig } from "./apiConfig.js";
5
- import { useEffect, useState } from "react";
5
+ import { apiConfig } from "./apiConfig.js";
6
6
  function createQueryError(messages, statusCode) {
7
7
  const error = new Error(messages.join(", "));
8
8
  error.statusCode = statusCode;
@@ -26,11 +26,12 @@ const fetchGETQuery = async (name, params, opts) => {
26
26
  if (params)
27
27
  url += "?params=" + encodeURIComponent(params);
28
28
  // Apply API configuration
29
- const apiConfig = useAPIConfig.getState();
30
29
  if (apiConfig.customQueryFetchOptions) {
31
30
  options = await apiConfig.customQueryFetchOptions?.("query", name, params, url, options);
32
31
  }
33
32
  const response = await fetch(url, options);
33
+ if (apiConfig.onResponse)
34
+ apiConfig.onResponse(response);
34
35
  const payload = await response.json();
35
36
  if (payload.errors?.length > 0) {
36
37
  throw createQueryError(payload.errors.map((e) => e.message), response.status);
@@ -39,7 +40,7 @@ const fetchGETQuery = async (name, params, opts) => {
39
40
  };
40
41
  export function createUseQuery(init) {
41
42
  const hook = (args, options) => {
42
- const customKey = useAPIConfig((state) => state.customQueryKey);
43
+ const customKey = apiConfig.customQueryKey;
43
44
  return useQuery({
44
45
  queryKey: [init.name, args, options?.headers, options?.headers, customKey],
45
46
  queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
@@ -49,7 +50,7 @@ export function createUseQuery(init) {
49
50
  });
50
51
  };
51
52
  hook.fetch = async (args, options) => {
52
- const customKey = useAPIConfig.getState().customQueryKey;
53
+ const customKey = apiConfig.customQueryKey;
53
54
  return getQueryClient().fetchQuery({
54
55
  queryKey: [init.name, args, options?.headers, options?.headers, customKey],
55
56
  queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
@@ -65,7 +66,7 @@ function selectByPath(data, path) {
65
66
  }
66
67
  export function createUseInfiniteQuery(init) {
67
68
  const hook = (args, options) => {
68
- const customKey = useAPIConfig((state) => state.customQueryKey);
69
+ const customKey = apiConfig.customQueryKey;
69
70
  const [initial, setInitial] = useState(() => {
70
71
  if (options?.initialData) {
71
72
  const data = options?.initialData;
@@ -150,11 +151,12 @@ const fetchMutation = async (name, params, opts) => {
150
151
  url = `/wp-json/ed/v1/mutation/${name}`;
151
152
  }
152
153
  // Apply API configuration
153
- const apiConfig = useAPIConfig.getState();
154
154
  if (apiConfig.customQueryFetchOptions) {
155
155
  options = await apiConfig.customQueryFetchOptions?.("mutation", name, params, url, options);
156
156
  }
157
157
  const response = await fetch(url, options);
158
+ if (apiConfig.onResponse)
159
+ apiConfig.onResponse(response);
158
160
  const payload = await response.json();
159
161
  if (payload.errors?.length > 0) {
160
162
  throw createQueryError(payload.errors.map((e) => e.message), response.status);
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useRef, useState, useTransition } from "react";
3
- import { isRelative, parseURL, resolveURL } from "ufo";
3
+ import { isEqual, isRelative, parseURL, resolveURL } from "ufo";
4
4
  import { RouterContext, RouterStateContext } from "../context.js";
5
5
  import { RouteLoader } from "../loader.js";
6
6
  import { getLinkHandlerMode, getRouteMeta, normalizeRoute, parseQuery, stringifyRouteLink } from "../utils.js";
@@ -255,6 +255,9 @@ export function BrowserRouter(props) {
255
255
  goingBack: false,
256
256
  });
257
257
  },
258
+ getState() {
259
+ return state;
260
+ },
258
261
  replaceHash(hash) {
259
262
  replaceRoute({
260
263
  ...getActiveRoute(),
@@ -305,7 +308,7 @@ export function BrowserRouter(props) {
305
308
  subscribers.delete(fn);
306
309
  };
307
310
  },
308
- handleClickEvent(e, originalHref) {
311
+ handleClickEvent(e, originalHref, preferBack) {
309
312
  const { mode, href } = getLinkHandlerMode(e, originalHref);
310
313
  if (mode === "ignore") {
311
314
  e.preventDefault();
@@ -316,6 +319,13 @@ export function BrowserRouter(props) {
316
319
  }
317
320
  else if (mode === "navigate" && href) {
318
321
  e.preventDefault();
322
+ if (preferBack) {
323
+ const lastState = state.history.length > 1 && state.history[state.history.length - 2];
324
+ if (lastState && isEqual(href, lastState.uri)) {
325
+ history.back();
326
+ return;
327
+ }
328
+ }
319
329
  api.navigate(href);
320
330
  }
321
331
  },
@@ -3,6 +3,7 @@ type Props<T extends ElementType = "a"> = NoInfer<Omit<ComponentPropsWithRef<T>,
3
3
  href?: string | null;
4
4
  target?: string | null;
5
5
  as?: T;
6
+ preferBack?: boolean;
6
7
  };
7
8
  export declare const Link: <T extends ElementType = "a">(props: Props<T>) => ReactElement;
8
9
  /**
@@ -6,7 +6,7 @@ import { useRouter } from "../hooks/useRouter.js";
6
6
  import { isSameOrigin } from "../utils.js";
7
7
  import { useRoute } from "../hooks/useRoute.js";
8
8
  import { useRouterState } from "../hooks/useRouterState.js";
9
- export const Link = forwardRef((props, ref) => {
9
+ export const Link = forwardRef(({ preferBack, ...props }, ref) => {
10
10
  const Comp = props.as || "a";
11
11
  if (env.admin) {
12
12
  return (_jsx(Comp, { ref: ref, ...props, href: props.href ?? undefined, onClick: (e) => {
@@ -15,17 +15,16 @@ export const Link = forwardRef((props, ref) => {
15
15
  } }));
16
16
  }
17
17
  else {
18
- const preload = useRouter((r) => r.preload);
19
- const handleClickEvent = useRouter((r) => r.handleClickEvent);
18
+ const router = useRouter();
20
19
  const state = useLinkState(props.href ?? "");
21
20
  return (_jsx(Comp, { ref: ref, "data-active": state.active ?? undefined, "data-child-active": state.childActive ?? undefined, "data-pending": state.pending ?? undefined, ...props, href: props.href ?? undefined, onMouseEnter: (e) => {
22
21
  if (props.onMouseEnter) {
23
22
  props.onMouseEnter(e);
24
23
  }
25
- preload(props.href);
24
+ router.preload(props.href);
26
25
  }, onClick: (e) => {
27
26
  props.onClick?.(e);
28
- handleClickEvent(e, props.href ?? undefined);
27
+ router.handleClickEvent(e, props.href ?? undefined, preferBack);
29
28
  } }));
30
29
  }
31
30
  });
@@ -3,6 +3,7 @@ import { memo, useMemo } from "react";
3
3
  import { RouteItemContext } from "../context.js";
4
4
  import { useRouter } from "../hooks/useRouter.js";
5
5
  import { useRouterState } from "../hooks/useRouterState.js";
6
+ import { ErrorBoundaryFrontend } from "../../blocks/ErrorBoundaryFrontend.js";
6
7
  export const AppRenderer = memo(() => {
7
8
  const { appData, appComponent: AppComponent } = useRouter().loader;
8
9
  const { activeRoute } = useRouterState();
@@ -22,7 +23,7 @@ export function RouteDisplay(props) {
22
23
  }
23
24
  return useMemo(() => {
24
25
  let child = !!Component && _jsx(Component, { ...props.route.props });
25
- return _jsx(RouteItemContext.Provider, { value: props.route, children: child });
26
+ return (_jsx(ErrorBoundaryFrontend, { children: _jsx(RouteItemContext.Provider, { value: props.route, children: child }) }));
26
27
  }, [Component, props.route, props.route]);
27
28
  }
28
29
  RouteDisplay.displayName = "RouteDisplay";
@@ -26,6 +26,9 @@ export const RouterContext = createContext({
26
26
  replaceQuery(query) { },
27
27
  handleClickEvent(e, originalHref) { },
28
28
  emitEvent(event) { },
29
+ getState() {
30
+ return null;
31
+ },
29
32
  });
30
33
  export const RouterStateContext = createContext({
31
34
  history: [NOOP_ROUTE],
@@ -1,2 +1,17 @@
1
1
  import type { RouteState } from "../types.js";
2
+ /**
3
+ * Returns the current route object.
4
+ *
5
+ * In most circumstances, this will be the active top-level route.
6
+ *
7
+ * In cases where manual rendering of routes is taking place, such as during page transitions or in some modal cases.
8
+ *
9
+ * @returns The current route
10
+ */
2
11
  export declare function useRoute(): RouteState;
12
+ /**
13
+ * Returns the current route, if it matches the specified view, otherwise null.
14
+ */
15
+ export declare function useViewRoute<V extends keyof ViewProps>(view: V): Extract<RouteState, {
16
+ view: V;
17
+ }> | null;
@@ -1,5 +1,26 @@
1
1
  import { useContext } from "react";
2
2
  import { RouteItemContext } from "../context.js";
3
+ /**
4
+ * Returns the current route object.
5
+ *
6
+ * In most circumstances, this will be the active top-level route.
7
+ *
8
+ * In cases where manual rendering of routes is taking place, such as during page transitions or in some modal cases.
9
+ *
10
+ * @returns The current route
11
+ */
3
12
  export function useRoute() {
4
13
  return useContext(RouteItemContext);
5
14
  }
15
+ /**
16
+ * Returns the current route, if it matches the specified view, otherwise null.
17
+ */
18
+ export function useViewRoute(view) {
19
+ const route = useContext(RouteItemContext);
20
+ if (route.view === view) {
21
+ return route;
22
+ }
23
+ else {
24
+ return null;
25
+ }
26
+ }
@@ -102,13 +102,15 @@ export type RouterAPI = {
102
102
  /** Replace the hash */
103
103
  replaceHash: (hash: string) => void;
104
104
  /** Handle link clicking events */
105
- handleClickEvent(e: PointerOrMouseEvent, href?: string): void;
105
+ handleClickEvent(e: PointerOrMouseEvent, href?: string, preferBack?: boolean): void;
106
106
  /** A reference to the route loader (mostly for internal use) */
107
107
  loader: RouteLoader;
108
108
  /** Subscribe to events */
109
109
  subscribe: (subscribe: RouterSubscriber) => () => void;
110
110
  /** This function is used by the routing system automatically */
111
111
  emitEvent: (event: RouterEvent) => void;
112
+ /** Returns the current RouterState */
113
+ getState: () => RouterAPIState | null;
112
114
  };
113
115
  export type TypedRouteState<T, TProps> = {
114
116
  /** A unique ID, representing this history item. */
@@ -0,0 +1,2 @@
1
+ import { Hono } from "hono";
2
+ export declare function defineRouter(): Hono;
@@ -0,0 +1,4 @@
1
+ import { Hono } from "hono";
2
+ export function defineRouter() {
3
+ return new Hono();
4
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./render-ssr-page.js";
2
2
  export * from "./server-context.js";
3
3
  export * from "./proxy-wp-admin.js";
4
+ export * from "./defineRouter.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./render-ssr-page.js";
2
2
  export * from "./server-context.js";
3
3
  export * from "./proxy-wp-admin.js";
4
+ export * from "./defineRouter.js";
@@ -1,7 +1,7 @@
1
1
  import { parseURL, stringifyParsedURL, withQuery } from "ufo";
2
2
  import { filterHeader } from "./utils/headers.js";
3
3
  import { createUrlReplacer } from "./utils/replace-host.js";
4
- const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control"];
4
+ const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control", /woocommerce/];
5
5
  const PROXY_REQUEST_HEADERS = [
6
6
  "content-type",
7
7
  "accept",
@@ -11,6 +11,7 @@ const PROXY_REQUEST_HEADERS = [
11
11
  "referer",
12
12
  "user-agent",
13
13
  "authorization",
14
+ "woocommerce-session",
14
15
  ];
15
16
  let runtime;
16
17
  export class ServerContext {
@@ -50,12 +51,14 @@ export class ServerContext {
50
51
  if (!response.ok) {
51
52
  return response;
52
53
  }
54
+ // console.log("Response headers", response.headers)
53
55
  const headers = {};
54
56
  response.headers.forEach((value, key) => {
55
57
  if (filterHeader(key, PROXY_RESPONSE_HEADERS)) {
56
58
  headers[key] = value;
57
59
  }
58
60
  });
61
+ // console.log("Returning headers", headers)
59
62
  let text = await response.text();
60
63
  if (opts?.replaceUrls && this.replaceUrls) {
61
64
  text = this.replaceUrls(text);
@@ -116,6 +119,7 @@ export class ServerContext {
116
119
  "Content-Type": "application/json",
117
120
  Accept: "application/json",
118
121
  },
122
+ redirect: "manual",
119
123
  });
120
124
  }
121
125
  async fetchMutation(req) {
@@ -130,6 +134,7 @@ export class ServerContext {
130
134
  Accept: "application/json",
131
135
  },
132
136
  body: JSON.stringify(req.body),
137
+ redirect: "manual",
133
138
  });
134
139
  }
135
140
  }
@@ -1 +1 @@
1
- export declare const VERSION = "2.0.0-beta.25";
1
+ export declare const VERSION = "2.0.0-beta.27";
@@ -1 +1 @@
1
- export const VERSION = "2.0.0-beta.25";
1
+ export const VERSION = "2.0.0-beta.27";
@@ -100,7 +100,6 @@ export function ssrPlugin() {
100
100
  ...config.optimizeDeps,
101
101
  include: [
102
102
  "valtio",
103
- "zustand",
104
103
  "@tanstack/react-query",
105
104
  "qs",
106
105
  "react",
@@ -20,10 +20,9 @@ export function createVinxiApp(args) {
20
20
  routeRules: {
21
21
  "/wp-content/uploads/**": {
22
22
  proxy: joinURL(args.origin, "wp-content/uploads/**"),
23
- headers: {
24
- "Cache-Control": "max-age=86400",
25
- "CDN-Cache-Control": "max-age=86400",
26
- "Vercel-CDN-Cache-Control": "max-age=86400",
23
+ cache: {
24
+ maxAge: 86400,
25
+ varies: [],
27
26
  },
28
27
  },
29
28
  "/wp-content/plugins/**": {
@@ -36,8 +35,23 @@ export function createVinxiApp(args) {
36
35
  },
37
36
  "/wp-content/**": { proxy: joinURL(args.origin, "wp-content/**") },
38
37
  "/wp-includes/**": { proxy: joinURL(args.origin, "wp-includes/**") },
39
- "/*": {
38
+ "/_data/**": {
40
39
  isr: 300,
40
+ swr: true,
41
+ cache: {
42
+ maxAge: 300,
43
+ swr: true,
44
+ varies: ["Authorization"],
45
+ },
46
+ },
47
+ "/**/*": {
48
+ isr: 300,
49
+ swr: true,
50
+ cache: {
51
+ maxAge: 300,
52
+ swr: true,
53
+ varies: ["Authorization"],
54
+ },
41
55
  },
42
56
  },
43
57
  },
@@ -227,7 +227,7 @@ export function createVinxiCodegen(opts) {
227
227
  return await serverContext.fetchMutation({
228
228
  name: id,
229
229
  body,
230
- headers: {},
230
+ headers: getRequestHeaders(event),
231
231
  })
232
232
  }),
233
233
  )
@@ -227,6 +227,9 @@ export class GraphQLGenerator {
227
227
  documents: getDocuments(["queries", "views", "blocks", "fragments"]),
228
228
  hasDocuments: true,
229
229
  banner: `import { ContentBlock } from "eddev/blocks"`,
230
+ footer: Object.keys(wp.scalarTypes)
231
+ .map((name) => `export type ${name}Scalar = Scalars["${name}"]["output"]`)
232
+ .join("\n"),
230
233
  plugins: {
231
234
  typescript: [typescriptPlugin, {}],
232
235
  typescriptOperations: [typescriptOperationsPlugin, {}],
@@ -400,7 +403,7 @@ export class GraphQLGenerator {
400
403
  errors.push(String(err));
401
404
  }
402
405
  if (args.banner) {
403
- output = args.banner + "\n\n" + output;
406
+ output = args.banner + "\n\n" + output + "\n" + (args.footer ?? "");
404
407
  }
405
408
  if (errors.length === 0) {
406
409
  const didWrite = await fs.writeIfUnchanged(config.filename, output);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "2.0.0-beta.25",
3
+ "version": "2.0.0-beta.27",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -110,8 +110,7 @@
110
110
  "vite-tsconfig-paths": "^4.2.1",
111
111
  "zod": "^3.22.4",
112
112
  "zod-to-json-schema": "^3.21.4",
113
- "zod-validation-error": "^2.1.0",
114
- "zustand": "^4.5.5"
113
+ "zod-validation-error": "^2.1.0"
115
114
  },
116
115
  "devDependencies": {
117
116
  "@types/express": "^4.17.21",
@@ -1,6 +0,0 @@
1
- interface PageLoadStore {
2
- loading: boolean;
3
- setIsLoading(loading: boolean): void;
4
- }
5
- export declare const usePageLoad: import("zustand").UseBoundStore<import("zustand").StoreApi<PageLoadStore>>;
6
- export {};
@@ -1,5 +0,0 @@
1
- import { create } from "zustand";
2
- export const usePageLoad = create((set) => ({
3
- loading: false,
4
- setIsLoading: (loading) => set({ loading: loading }),
5
- }));