eddev 2.0.0-beta.36 → 2.0.0-beta.38
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/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/vinxi-app.js +5 -1
- package/package.json +1 -1
- package/dist/app/entry/ssr-root-client.d.ts +0 -6
- package/dist/app/entry/ssr-root.d.ts +0 -10
- package/dist/app/entry/ssr-root.js +0 -24
- package/dist/app/lib/blocks/EditableText.d.ts +0 -41
- package/dist/app/lib/blocks/EditableText.js +0 -50
- package/dist/app/lib/blocks/InnerBlocks.d.ts +0 -52
- package/dist/app/lib/blocks/InnerBlocks.js +0 -63
- package/dist/app/lib/blocks/defineBlock.d.ts +0 -2
- package/dist/app/lib/blocks/defineBlock.js +0 -3
- package/dist/app/lib/blocks/editor/controls.d.ts +0 -10
- package/dist/app/lib/blocks/editor/controls.js +0 -20
- package/dist/app/lib/blocks/index.d.ts +0 -9
- package/dist/app/lib/blocks/index.js +0 -9
- package/dist/app/lib/devtools/index.d.ts +0 -1
- package/dist/app/lib/devtools/index.js +0 -1
- package/dist/app/lib/devtools/tailwind.config.d.ts +0 -23
- package/dist/app/lib/devtools/tailwind.config.js +0 -24
- package/dist/app/lib/devtools/useQueryDebug.d.ts +0 -15
- package/dist/app/lib/devtools/useQueryDebug.js +0 -10
- package/dist/app/lib/dynamic/index.d.ts +0 -1
- package/dist/app/lib/dynamic/index.js +0 -1
- package/dist/app/lib/hooks/apiConfig.d.ts +0 -20
- package/dist/app/lib/hooks/apiConfig.js +0 -9
- package/dist/app/lib/hooks/index.d.ts +0 -4
- package/dist/app/lib/hooks/index.js +0 -4
- package/dist/app/lib/hooks/queryUtils.d.ts +0 -49
- package/dist/app/lib/hooks/queryUtils.js +0 -182
- package/dist/app/lib/hooks/useAppData.d.ts +0 -4
- package/dist/app/lib/hooks/useAppData.js +0 -11
- package/dist/app/lib/hooks/useRPC.d.ts +0 -9
- package/dist/app/lib/hooks/useRPC.js +0 -9
- package/dist/app/lib/internal/index.d.ts +0 -4
- package/dist/app/lib/internal/index.js +0 -4
- package/dist/app/lib/internal/internal-store.d.ts +0 -9
- package/dist/app/lib/internal/internal-store.js +0 -7
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +0 -615
- package/dist/app/lib/legacy-stitches/createStitches.js +0 -439
- package/dist/app/lib/legacy-stitches/index.d.ts +0 -1
- package/dist/app/lib/legacy-stitches/index.js +0 -1
- package/dist/app/lib/routing/components/SSRRouter.d.ts +0 -9
- package/dist/app/lib/routing/components/SSRRouter.js +0 -13
- package/dist/app/lib/views/defineView.d.ts +0 -4
- package/dist/app/lib/views/defineView.js +0 -3
- package/dist/app/lib/views/index.d.ts +0 -1
- package/dist/app/lib/views/index.js +0 -1
- package/dist/app/server/defineRouter.d.ts +0 -2
- package/dist/app/server/defineRouter.js +0 -4
- package/dist/app/server/index.d.ts +0 -4
- package/dist/app/server/index.js +0 -4
- package/dist/app/server/proxy-wp-admin.d.ts +0 -3
- package/dist/app/server/proxy-wp-admin.js +0 -105
- package/dist/app/server/render-ssr-page.d.ts +0 -5
- package/dist/app/server/render-ssr-page.js +0 -31
- package/dist/app/server/server-context.d.ts +0 -50
- package/dist/app/server/server-context.js +0 -145
- package/dist/app/server/utils/headers.d.ts +0 -5
- package/dist/app/server/utils/headers.js +0 -28
- package/dist/app/server/utils/replace-host.d.ts +0 -10
- package/dist/app/server/utils/replace-host.js +0 -61
- package/dist/app/utils/wp.d.ts +0 -26
- package/dist/app/utils/wp.js +0 -1
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { useInfiniteQuery, useMutation, useQuery, } from "@tanstack/react-query";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { joinURL } from "ufo";
|
|
4
|
-
import { getQueryClient } from "../../utils/query-client.js";
|
|
5
|
-
import { apiConfig } from "./apiConfig.js";
|
|
6
|
-
function createQueryError(messages, statusCode) {
|
|
7
|
-
const error = new Error(messages.join(", "));
|
|
8
|
-
error.statusCode = statusCode;
|
|
9
|
-
error.messages = messages;
|
|
10
|
-
return error;
|
|
11
|
-
}
|
|
12
|
-
const fetchGETQuery = async (name, params, opts) => {
|
|
13
|
-
let url;
|
|
14
|
-
let options = {
|
|
15
|
-
headers: opts?.headers,
|
|
16
|
-
};
|
|
17
|
-
if (env.serverless && env.client) {
|
|
18
|
-
url = `/_data/query/${name}`;
|
|
19
|
-
}
|
|
20
|
-
else if (env.serverless) {
|
|
21
|
-
url = joinURL(env.origin ?? "", `/wp-json/ed/v1/query/${name}`);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
url = `/wp-json/ed/v1/query/${name}`;
|
|
25
|
-
}
|
|
26
|
-
if (params)
|
|
27
|
-
url += "?params=" + encodeURIComponent(params);
|
|
28
|
-
// Apply API configuration
|
|
29
|
-
if (apiConfig.customQueryFetchOptions) {
|
|
30
|
-
options = await apiConfig.customQueryFetchOptions?.("query", name, params, url, options);
|
|
31
|
-
}
|
|
32
|
-
const response = await fetch(url, options);
|
|
33
|
-
if (apiConfig.onResponse)
|
|
34
|
-
apiConfig.onResponse(response);
|
|
35
|
-
const payload = await response.json();
|
|
36
|
-
if (payload.errors?.length > 0) {
|
|
37
|
-
throw createQueryError(payload.errors.map((e) => e.message), response.status);
|
|
38
|
-
}
|
|
39
|
-
return payload.data;
|
|
40
|
-
};
|
|
41
|
-
export function createUseQuery(init) {
|
|
42
|
-
const hook = (args, options) => {
|
|
43
|
-
const customKey = apiConfig.customQueryKey;
|
|
44
|
-
return useQuery({
|
|
45
|
-
queryKey: [init.name, args, options?.headers, options?.headers, customKey],
|
|
46
|
-
queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
|
|
47
|
-
headers: options?.headers,
|
|
48
|
-
}),
|
|
49
|
-
...options,
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
hook.fetch = async (args, options) => {
|
|
53
|
-
const customKey = apiConfig.customQueryKey;
|
|
54
|
-
return getQueryClient().fetchQuery({
|
|
55
|
-
queryKey: [init.name, args, options?.headers, options?.headers, customKey],
|
|
56
|
-
queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
|
|
57
|
-
headers: options?.headers,
|
|
58
|
-
}),
|
|
59
|
-
...options,
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
return hook;
|
|
63
|
-
}
|
|
64
|
-
function selectByPath(data, path) {
|
|
65
|
-
return path.reduce((acc, key) => (acc ? acc[key] : null), data);
|
|
66
|
-
}
|
|
67
|
-
export function createUseInfiniteQuery(init) {
|
|
68
|
-
const hook = (args, options) => {
|
|
69
|
-
const customKey = apiConfig.customQueryKey;
|
|
70
|
-
const [initial, setInitial] = useState(() => {
|
|
71
|
-
if (options?.initialData) {
|
|
72
|
-
const data = options?.initialData;
|
|
73
|
-
const endCursor = selectByPath(data, init.paths.endCursorPath);
|
|
74
|
-
const hasNextPage = selectByPath(data, init.paths.hasNextPagePath);
|
|
75
|
-
const nodes = selectByPath(data, init.paths.nodesPath);
|
|
76
|
-
if (!nodes)
|
|
77
|
-
return {};
|
|
78
|
-
return {
|
|
79
|
-
initialData: {
|
|
80
|
-
pages: [{ nodes, endCursor, hasNextPage }],
|
|
81
|
-
pageParams: [],
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
setInitial({
|
|
88
|
-
initialData: undefined,
|
|
89
|
-
});
|
|
90
|
-
}, []);
|
|
91
|
-
return useInfiniteQuery({
|
|
92
|
-
queryKey: [init.name, args, init.defaultLimit, options?.headers, options?.headers, customKey],
|
|
93
|
-
queryFn: async (args) => {
|
|
94
|
-
const finalArgs = {
|
|
95
|
-
limit: args.queryKey[2],
|
|
96
|
-
...(args.queryKey[1] ?? {}),
|
|
97
|
-
cursor: args.pageParam,
|
|
98
|
-
};
|
|
99
|
-
const data = await fetchGETQuery(init.name, JSON.stringify(finalArgs), {
|
|
100
|
-
headers: options?.headers,
|
|
101
|
-
});
|
|
102
|
-
const endCursor = selectByPath(data, init.paths.endCursorPath);
|
|
103
|
-
const hasNextPage = selectByPath(data, init.paths.hasNextPagePath);
|
|
104
|
-
const nodes = selectByPath(data, init.paths.nodesPath);
|
|
105
|
-
const total = selectByPath(data, [...init.paths.pageInfoPath, "total"]);
|
|
106
|
-
return {
|
|
107
|
-
nodes,
|
|
108
|
-
hasNextPage,
|
|
109
|
-
endCursor,
|
|
110
|
-
total,
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
initialPageParam: "",
|
|
114
|
-
getNextPageParam: (lastPage) => {
|
|
115
|
-
// @ts-ignore
|
|
116
|
-
return lastPage.hasNextPage ? lastPage.endCursor : undefined;
|
|
117
|
-
},
|
|
118
|
-
select(data) {
|
|
119
|
-
return {
|
|
120
|
-
nodes: data.pages.flatMap((page) => page.nodes),
|
|
121
|
-
total: data.pages[data.pages.length - 1]?.total,
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
...options,
|
|
125
|
-
...initial,
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
return hook;
|
|
129
|
-
}
|
|
130
|
-
const fetchMutation = async (name, params, opts) => {
|
|
131
|
-
let url;
|
|
132
|
-
let options = {
|
|
133
|
-
method: "POST",
|
|
134
|
-
headers: {
|
|
135
|
-
"Content-Type": "application/json",
|
|
136
|
-
Accept: "application/json",
|
|
137
|
-
...opts?.headers,
|
|
138
|
-
},
|
|
139
|
-
body: JSON.stringify(params),
|
|
140
|
-
};
|
|
141
|
-
if (env.serverless && env.client) {
|
|
142
|
-
// Relative request (in browser)
|
|
143
|
-
url = `/_data/mutation/${name}`;
|
|
144
|
-
}
|
|
145
|
-
else if (env.serverless) {
|
|
146
|
-
// Request to the origin server (server to server)
|
|
147
|
-
url = joinURL(env.origin ?? "", `/wp-json/ed/v1/mutation/${name}`);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
// Request straight to the wordpress route
|
|
151
|
-
url = `/wp-json/ed/v1/mutation/${name}`;
|
|
152
|
-
}
|
|
153
|
-
// Apply API configuration
|
|
154
|
-
if (apiConfig.customQueryFetchOptions) {
|
|
155
|
-
options = await apiConfig.customQueryFetchOptions?.("mutation", name, params, url, options);
|
|
156
|
-
}
|
|
157
|
-
const response = await fetch(url, options);
|
|
158
|
-
if (apiConfig.onResponse)
|
|
159
|
-
apiConfig.onResponse(response);
|
|
160
|
-
const payload = await response.json();
|
|
161
|
-
if (payload.errors?.length > 0) {
|
|
162
|
-
throw createQueryError(payload.errors.map((e) => e.message), response.status);
|
|
163
|
-
}
|
|
164
|
-
return payload.data;
|
|
165
|
-
};
|
|
166
|
-
export function createUseMutation(init) {
|
|
167
|
-
const hook = (options) => {
|
|
168
|
-
return useMutation({
|
|
169
|
-
mutationKey: [init.name],
|
|
170
|
-
mutationFn: (args) => fetchMutation(init.name, args, {
|
|
171
|
-
headers: options?.headers,
|
|
172
|
-
}),
|
|
173
|
-
...options,
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
hook.mutate = async (args, options) => {
|
|
177
|
-
return fetchMutation(init.name, args, {
|
|
178
|
-
headers: options?.headers,
|
|
179
|
-
});
|
|
180
|
-
};
|
|
181
|
-
return hook;
|
|
182
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const useRPCQuery: RPCUseQuery;
|
|
2
|
-
export declare const useRPCMutation: RPCUseMutation;
|
|
3
|
-
export declare const useRPCInfiniteQuery: RPCUseInfiniteQuery;
|
|
4
|
-
export declare const rpcClient: null;
|
|
5
|
-
export type UseRPCMutationResult = any;
|
|
6
|
-
export type UseRPCQueryResult = any;
|
|
7
|
-
export type UseRPCInfiniteQueryResult = any;
|
|
8
|
-
export declare const RPCClientError: null;
|
|
9
|
-
export type RPCClientError = any;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const trpc = {};
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
export const useRPCQuery = trpc.useQuery;
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
export const useRPCMutation = trpc.useMutation;
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
export const useRPCInfiniteQuery = trpc.useInfiniteQuery;
|
|
8
|
-
export const rpcClient = null;
|
|
9
|
-
export const RPCClientError = null;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from "react";
|
|
2
|
-
type BlockManifest = Record<string, FunctionComponent<any>>;
|
|
3
|
-
type Store = {
|
|
4
|
-
blocks: BlockManifest;
|
|
5
|
-
};
|
|
6
|
-
export declare const internalStore: Store & {
|
|
7
|
-
set<K extends keyof Store>(key: K, value: Store[K]): void;
|
|
8
|
-
};
|
|
9
|
-
export {};
|