eddev 2.0.0-beta.76 → 2.0.0-beta.77
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.
|
@@ -94,6 +94,7 @@ export class ServerContext {
|
|
|
94
94
|
const result = await swr({
|
|
95
95
|
key: cacheKey,
|
|
96
96
|
cache: pageCache,
|
|
97
|
+
forceFresh: this.dev,
|
|
97
98
|
getFreshValue: async (ctx) => {
|
|
98
99
|
ctx.metadata.createdTime;
|
|
99
100
|
const fetchUrl = withQuery(withTrailingSlash(req.pathname), {
|
|
@@ -167,6 +168,7 @@ export class ServerContext {
|
|
|
167
168
|
result.__generated = new Date().toISOString();
|
|
168
169
|
return result;
|
|
169
170
|
},
|
|
171
|
+
forceFresh: this.dev,
|
|
170
172
|
});
|
|
171
173
|
return data;
|
|
172
174
|
}
|
|
@@ -216,6 +218,7 @@ export class ServerContext {
|
|
|
216
218
|
: await swr({
|
|
217
219
|
key,
|
|
218
220
|
cache: queryCache,
|
|
221
|
+
forceFresh: this.dev,
|
|
219
222
|
getFreshValue: async (ctx) => {
|
|
220
223
|
const result = await fetch();
|
|
221
224
|
ctx.metadata.ttl = result.cacheTime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.0.0-beta.
|
|
1
|
+
export declare const VERSION = "2.0.0-beta.77";
|
package/dist/node/cli/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "2.0.0-beta.
|
|
1
|
+
export const VERSION = "2.0.0-beta.77";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { joinURL } from "ufo";
|
|
2
2
|
import { createApp } from "vinxi";
|
|
3
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
|
4
3
|
import { StatefulLog } from "../utils/stateful-log.js";
|
|
5
|
-
import { corePlugins
|
|
4
|
+
import { corePlugins } from "./get-vite-config.js";
|
|
6
5
|
import { getVinxiFolder } from "./vinxi-codegen.js";
|
|
7
6
|
export function createVinxiApp(args) {
|
|
8
7
|
const log = args.log ?? new StatefulLog({ label: "Build" });
|
|
@@ -92,6 +91,11 @@ export function createVinxiApp(args) {
|
|
|
92
91
|
},
|
|
93
92
|
},
|
|
94
93
|
},
|
|
94
|
+
vercel: {
|
|
95
|
+
config: {
|
|
96
|
+
bypassToken: process.env.VERCEL_BYPASS_TOKEN,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
95
99
|
},
|
|
96
100
|
routers: [
|
|
97
101
|
...args.config.serverless.themeAssets.map((folder) => {
|
|
@@ -106,41 +110,41 @@ export function createVinxiApp(args) {
|
|
|
106
110
|
base: joinURL(args.publicUrl, folderName),
|
|
107
111
|
};
|
|
108
112
|
}),
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
},
|
|
113
|
+
// {
|
|
114
|
+
// name: "data-api",
|
|
115
|
+
// type: "http",
|
|
116
|
+
// base: "/_data/",
|
|
117
|
+
// handler: `${folder}/handler.data-api.ts`,
|
|
118
|
+
// target: "server",
|
|
119
|
+
// plugins: () => [
|
|
120
|
+
// tsconfigPaths(),
|
|
121
|
+
// envPlugin({
|
|
122
|
+
// rootDir: args.rootDir,
|
|
123
|
+
// console: log,
|
|
124
|
+
// mode: args.mode,
|
|
125
|
+
// publicUrl: args.publicUrl,
|
|
126
|
+
// serverless: true,
|
|
127
|
+
// target: "frontend",
|
|
128
|
+
// }),
|
|
129
|
+
// ],
|
|
130
|
+
// },
|
|
131
|
+
// {
|
|
132
|
+
// name: "wp-proxy",
|
|
133
|
+
// type: "http",
|
|
134
|
+
// base: "/wp-",
|
|
135
|
+
// handler: `${folder}/handler.wp-proxy.ts`,
|
|
136
|
+
// target: "server",
|
|
137
|
+
// plugins: () => [
|
|
138
|
+
// ...corePlugins({
|
|
139
|
+
// rootDir: args.rootDir,
|
|
140
|
+
// console: log,
|
|
141
|
+
// mode: args.mode,
|
|
142
|
+
// publicUrl: args.publicUrl,
|
|
143
|
+
// serverless: true,
|
|
144
|
+
// target: "frontend",
|
|
145
|
+
// }),
|
|
146
|
+
// ],
|
|
147
|
+
// },
|
|
144
148
|
{
|
|
145
149
|
name: "client",
|
|
146
150
|
type: "client",
|
|
@@ -176,120 +176,168 @@ export function createVinxiCodegen(opts) {
|
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
});
|
|
179
|
+
if (opts.serverless) {
|
|
180
|
+
// codegen.registerFile({
|
|
181
|
+
// name: "handler.data-api.ts",
|
|
182
|
+
// generate: code/* tsx */ `
|
|
183
|
+
// /// <reference types="vinxi/types/server" />
|
|
184
|
+
// import { createRouter, eventHandler, getRouterParam, getQuery, getWebRequest, getRequestHeaders, getRequestURL } from "vinxi/http"
|
|
185
|
+
// import { serverContext } from "./context.js"
|
|
186
|
+
// const router = createRouter()
|
|
187
|
+
// .get(
|
|
188
|
+
// "/route/",
|
|
189
|
+
// eventHandler(async (event) => {
|
|
190
|
+
// const id = "/"
|
|
191
|
+
// const url = getRequestURL(event);
|
|
192
|
+
// return await serverContext.fetchRouteData({
|
|
193
|
+
// pathname: id,
|
|
194
|
+
// newOrigin: url.origin,
|
|
195
|
+
// })
|
|
196
|
+
// }),
|
|
197
|
+
// )
|
|
198
|
+
// .get(
|
|
199
|
+
// "/route/**:name",
|
|
200
|
+
// eventHandler(async (event) => {
|
|
201
|
+
// const id = "/" + getRouterParam(event, "name")
|
|
202
|
+
// const url = getRequestURL(event);
|
|
203
|
+
// return await serverContext.fetchRouteData({
|
|
204
|
+
// pathname: id,
|
|
205
|
+
// newOrigin: url.origin,
|
|
206
|
+
// })
|
|
207
|
+
// }),
|
|
208
|
+
// )
|
|
209
|
+
// .get(
|
|
210
|
+
// "/query/**:name",
|
|
211
|
+
// eventHandler(async (event) => {
|
|
212
|
+
// const id = "/" + getRouterParam(event, "name")
|
|
213
|
+
// const paramString = getQuery(event).params
|
|
214
|
+
// const params = typeof paramString === "string" && paramString.length ? JSON.parse(paramString) : {}
|
|
215
|
+
// return await serverContext.fetchNamedQuery({
|
|
216
|
+
// name: id,
|
|
217
|
+
// params: params,
|
|
218
|
+
// headers: getRequestHeaders(event),
|
|
219
|
+
// })
|
|
220
|
+
// }),
|
|
221
|
+
// )
|
|
222
|
+
// .post(
|
|
223
|
+
// "/mutation/**:name",
|
|
224
|
+
// eventHandler(async (event) => {
|
|
225
|
+
// const id = "/" + getRouterParam(event, "name")
|
|
226
|
+
// const body = await getWebRequest(event).json()
|
|
227
|
+
// return await serverContext.fetchMutation({
|
|
228
|
+
// name: id,
|
|
229
|
+
// body,
|
|
230
|
+
// headers: getRequestHeaders(event),
|
|
231
|
+
// })
|
|
232
|
+
// }),
|
|
233
|
+
// )
|
|
234
|
+
// export default router.handler
|
|
235
|
+
// `,
|
|
236
|
+
// })
|
|
237
|
+
}
|
|
179
238
|
if (opts.serverless) {
|
|
180
239
|
codegen.registerFile({
|
|
181
|
-
name: "handler.
|
|
240
|
+
name: "handler.ssr-page.ts",
|
|
182
241
|
generate: code /* tsx */ `
|
|
183
242
|
/// <reference types="vinxi/types/server" />
|
|
184
|
-
import
|
|
243
|
+
import "../../views/index.css"
|
|
244
|
+
import "./manifest/blocks.js"
|
|
245
|
+
import "./manifest/styles.js"
|
|
246
|
+
import "./manifest/views.js"
|
|
247
|
+
import "./context.js"
|
|
248
|
+
import { proxyWpAdmin, renderPage, ServerContext } from "eddev/server"
|
|
249
|
+
import {
|
|
250
|
+
createRouter,
|
|
251
|
+
eventHandler,
|
|
252
|
+
getQuery,
|
|
253
|
+
getRequestHeaders,
|
|
254
|
+
getRequestURL,
|
|
255
|
+
getRouterParam,
|
|
256
|
+
getWebRequest,
|
|
257
|
+
} from "vinxi/http"
|
|
258
|
+
import { handleRPC } from "./rpc.js"
|
|
185
259
|
import { serverContext } from "./context.js"
|
|
186
260
|
|
|
187
261
|
const router = createRouter()
|
|
188
262
|
.get(
|
|
189
|
-
"/route/",
|
|
263
|
+
"/_data/route/",
|
|
190
264
|
eventHandler(async (event) => {
|
|
191
265
|
const id = "/"
|
|
192
|
-
const url = getRequestURL(event)
|
|
266
|
+
const url = getRequestURL(event)
|
|
193
267
|
|
|
194
|
-
return await serverContext.fetchRouteData({
|
|
195
|
-
pathname: id,
|
|
196
|
-
newOrigin: url.origin,
|
|
197
|
-
})
|
|
268
|
+
return await serverContext.fetchRouteData({ pathname: id, newOrigin: url.origin })
|
|
198
269
|
}),
|
|
199
270
|
)
|
|
200
271
|
.get(
|
|
201
|
-
"/route/**:name",
|
|
272
|
+
"/_data/route/**:name",
|
|
202
273
|
eventHandler(async (event) => {
|
|
203
274
|
const id = "/" + getRouterParam(event, "name")
|
|
204
|
-
const url = getRequestURL(event)
|
|
275
|
+
const url = getRequestURL(event)
|
|
205
276
|
|
|
206
|
-
return await serverContext.fetchRouteData({
|
|
207
|
-
pathname: id,
|
|
208
|
-
newOrigin: url.origin,
|
|
209
|
-
})
|
|
277
|
+
return await serverContext.fetchRouteData({ pathname: id, newOrigin: url.origin })
|
|
210
278
|
}),
|
|
211
279
|
)
|
|
212
280
|
.get(
|
|
213
|
-
"/query/**:name",
|
|
281
|
+
"/_data/query/**:name",
|
|
214
282
|
eventHandler(async (event) => {
|
|
215
283
|
const id = "/" + getRouterParam(event, "name")
|
|
216
284
|
const paramString = getQuery(event).params
|
|
217
285
|
|
|
218
286
|
const params = typeof paramString === "string" && paramString.length ? JSON.parse(paramString) : {}
|
|
219
287
|
|
|
220
|
-
return await serverContext.fetchNamedQuery({
|
|
221
|
-
name: id,
|
|
222
|
-
params: params,
|
|
223
|
-
headers: getRequestHeaders(event),
|
|
224
|
-
})
|
|
288
|
+
return await serverContext.fetchNamedQuery({ name: id, params: params, headers: getRequestHeaders(event) })
|
|
225
289
|
}),
|
|
226
290
|
)
|
|
227
291
|
.post(
|
|
228
|
-
"/mutation/**:name",
|
|
292
|
+
"/_data/mutation/**:name",
|
|
229
293
|
eventHandler(async (event) => {
|
|
230
294
|
const id = "/" + getRouterParam(event, "name")
|
|
231
295
|
const body = await getWebRequest(event).json()
|
|
232
|
-
return await serverContext.fetchMutation({
|
|
233
|
-
name: id,
|
|
234
|
-
body,
|
|
235
|
-
headers: getRequestHeaders(event),
|
|
236
|
-
})
|
|
296
|
+
return await serverContext.fetchMutation({ name: id, body, headers: getRequestHeaders(event) })
|
|
237
297
|
}),
|
|
238
298
|
)
|
|
239
299
|
|
|
240
|
-
export default router.handler
|
|
241
|
-
|
|
242
|
-
`,
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
if (opts.serverless) {
|
|
246
|
-
codegen.registerFile({
|
|
247
|
-
name: "handler.ssr-page.ts",
|
|
248
|
-
generate: code /* tsx */ `
|
|
249
|
-
/// <reference types="vinxi/types/server" />
|
|
250
|
-
import "../../views/index.css"
|
|
251
|
-
import "./manifest/blocks.js"
|
|
252
|
-
import "./manifest/styles.js"
|
|
253
|
-
import "./manifest/views.js"
|
|
254
|
-
import "./context.js"
|
|
255
|
-
import { handleRPC } from "./rpc.js"
|
|
256
|
-
import { proxyWpAdmin, ServerContext, renderPage } from "eddev/server"
|
|
257
|
-
import { eventHandler, getRequestURL } from "vinxi/http"
|
|
258
|
-
|
|
259
300
|
export default eventHandler({
|
|
260
301
|
handler: async (event) => {
|
|
261
302
|
const serverContext = ServerContext.main
|
|
262
303
|
const url = getRequestURL(event)
|
|
263
304
|
|
|
305
|
+
// RPC
|
|
264
306
|
const isRPC = serverContext.rpcBases.some((base) => url.pathname.startsWith(base))
|
|
265
307
|
if (isRPC) {
|
|
266
308
|
return handleRPC(event)
|
|
267
309
|
}
|
|
268
310
|
|
|
269
|
-
|
|
311
|
+
// Data API
|
|
312
|
+
if (url.pathname.startsWith("/_data/")) {
|
|
313
|
+
return router.handler(event)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Proxy WordPress
|
|
317
|
+
if (url.pathname.includes(".") || url.pathname.startsWith("/graphql") || url.pathname.startsWith("/wp-")) {
|
|
270
318
|
return proxyWpAdmin(event)
|
|
271
319
|
}
|
|
272
320
|
|
|
321
|
+
// SSR
|
|
273
322
|
return renderPage({ pathname: url.pathname, newOrigin: url.origin })
|
|
274
|
-
}
|
|
323
|
+
},
|
|
275
324
|
})
|
|
276
325
|
`,
|
|
277
326
|
});
|
|
278
327
|
}
|
|
279
328
|
if (opts.serverless) {
|
|
280
|
-
codegen.registerFile({
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
});
|
|
329
|
+
// codegen.registerFile({
|
|
330
|
+
// name: "handler.wp-proxy.ts",
|
|
331
|
+
// generate: code/* tsx */ `
|
|
332
|
+
// /// <reference types="vinxi/types/server" />
|
|
333
|
+
// import { proxyWpAdmin } from "eddev/server"
|
|
334
|
+
// import { eventHandler } from "vinxi/http"
|
|
335
|
+
// import "./context.js"
|
|
336
|
+
// export default eventHandler(async (event) => {
|
|
337
|
+
// return proxyWpAdmin(event)
|
|
338
|
+
// })
|
|
339
|
+
// `,
|
|
340
|
+
// })
|
|
293
341
|
}
|
|
294
342
|
codegen.registerFile({
|
|
295
343
|
name: "manifest/blocks.ts",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eddev",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.77",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -76,19 +76,16 @@
|
|
|
76
76
|
"license": "ISC",
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@babel/types": "^7.25.2",
|
|
79
|
-
"@clack/prompts": "^0.7.0",
|
|
80
79
|
"@epic-web/cachified": "^5.2.0",
|
|
81
80
|
"@graphql-codegen/core": "^4.0.0",
|
|
82
81
|
"@graphql-codegen/typescript": "^4.0.1",
|
|
83
82
|
"@graphql-codegen/typescript-operations": "^4.0.1",
|
|
84
83
|
"@graphql-tools/load": "^8.0.0",
|
|
85
84
|
"@graphql-tools/url-loader": "^8.0.0",
|
|
86
|
-
"@inquirer/prompts": "^5.0.6",
|
|
87
85
|
"@nozbe/microfuzz": "^1.0.0",
|
|
88
86
|
"@rollup/plugin-replace": "^5.0.5",
|
|
89
87
|
"@tanstack/react-query": "^5.51.23",
|
|
90
88
|
"@trpc/client": "^11.0.0-rc.608",
|
|
91
|
-
"@trpc/react-query": "^11.0.0-rc.608",
|
|
92
89
|
"@trpc/server": "^11.0.0-rc.608",
|
|
93
90
|
"@types/qs": "^6.9.15",
|
|
94
91
|
"@vinxi/react": "^0.2.5",
|
|
@@ -104,15 +101,11 @@
|
|
|
104
101
|
"hono": "^4.6.2",
|
|
105
102
|
"ink": "^5.0.1",
|
|
106
103
|
"ink-spinner": "^5.0.0",
|
|
107
|
-
"ink-text-input": "^6.0.0",
|
|
108
|
-
"listhen": "^1.6.0",
|
|
109
104
|
"lru-cache": "10.4.1",
|
|
110
105
|
"mkcert": "^3.2.0",
|
|
111
|
-
"mnemonist": "^0.39.8",
|
|
112
106
|
"obj-console": "^1.0.2",
|
|
113
107
|
"object-code": "^1.3.3",
|
|
114
108
|
"qs": "^6.13.0",
|
|
115
|
-
"react-super-seo": "^1.1.9",
|
|
116
109
|
"superjson": "^2.2.1",
|
|
117
110
|
"ts-poet": "^6.6.0",
|
|
118
111
|
"ufo": "^1.3.1",
|
|
@@ -126,8 +119,6 @@
|
|
|
126
119
|
"zod-validation-error": "^2.1.0"
|
|
127
120
|
},
|
|
128
121
|
"devDependencies": {
|
|
129
|
-
"@types/express": "^4.17.21",
|
|
130
|
-
"@types/express-http-proxy": "^1.6.6",
|
|
131
122
|
"@types/node": "^20.9.0",
|
|
132
123
|
"@types/react": "^18.3.3",
|
|
133
124
|
"@types/react-dom": "^18.3.0",
|