eddev 2.0.0-beta.25 → 2.0.0-beta.26

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.
@@ -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
  }
@@ -15,4 +15,5 @@ export type APIConfigStore = {
15
15
  */
16
16
  set: (config: Partial<APIConfigStore>) => void;
17
17
  };
18
- export declare const useAPIConfig: import("zustand").UseBoundStore<import("zustand").StoreApi<APIConfigStore>>;
18
+ export declare const apiConfig: APIConfigStore;
19
+ 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,7 +26,6 @@ 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
  }
@@ -39,7 +38,7 @@ const fetchGETQuery = async (name, params, opts) => {
39
38
  };
40
39
  export function createUseQuery(init) {
41
40
  const hook = (args, options) => {
42
- const customKey = useAPIConfig((state) => state.customQueryKey);
41
+ const customKey = apiConfig.customQueryKey;
43
42
  return useQuery({
44
43
  queryKey: [init.name, args, options?.headers, options?.headers, customKey],
45
44
  queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
@@ -49,7 +48,7 @@ export function createUseQuery(init) {
49
48
  });
50
49
  };
51
50
  hook.fetch = async (args, options) => {
52
- const customKey = useAPIConfig.getState().customQueryKey;
51
+ const customKey = apiConfig.customQueryKey;
53
52
  return getQueryClient().fetchQuery({
54
53
  queryKey: [init.name, args, options?.headers, options?.headers, customKey],
55
54
  queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
@@ -65,7 +64,7 @@ function selectByPath(data, path) {
65
64
  }
66
65
  export function createUseInfiniteQuery(init) {
67
66
  const hook = (args, options) => {
68
- const customKey = useAPIConfig((state) => state.customQueryKey);
67
+ const customKey = apiConfig.customQueryKey;
69
68
  const [initial, setInitial] = useState(() => {
70
69
  if (options?.initialData) {
71
70
  const data = options?.initialData;
@@ -150,7 +149,6 @@ const fetchMutation = async (name, params, opts) => {
150
149
  url = `/wp-json/ed/v1/mutation/${name}`;
151
150
  }
152
151
  // Apply API configuration
153
- const apiConfig = useAPIConfig.getState();
154
152
  if (apiConfig.customQueryFetchOptions) {
155
153
  options = await apiConfig.customQueryFetchOptions?.("mutation", name, params, url, options);
156
154
  }
@@ -1 +1 @@
1
- export declare const VERSION = "2.0.0-beta.25";
1
+ export declare const VERSION = "2.0.0-beta.26";
@@ -1 +1 @@
1
- export const VERSION = "2.0.0-beta.25";
1
+ export const VERSION = "2.0.0-beta.26";
@@ -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
  },
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.26",
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
- }));