eddev 2.0.0-beta.13 → 2.0.0-beta.15
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/lib/admin/index.d.ts +2 -2
- package/dist/app/lib/admin/index.js +2 -2
- package/dist/app/lib/internal/index.d.ts +4 -4
- package/dist/app/lib/internal/index.js +4 -4
- package/dist/app/server/index.js +0 -1
- package/dist/app/server/proxy-wp-admin.js +1 -2
- package/dist/app/server/render-ssr-page.d.ts +2 -1
- package/dist/app/server/render-ssr-page.js +3 -4
- package/dist/app/server/server-context.d.ts +4 -1
- package/dist/app/server/server-context.js +2 -0
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/get-vite-config.js +22 -6
- package/dist/node/compiler/vinxi-codegen.js +25 -17
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./defineField";
|
|
2
|
-
export * from "./defineWidget";
|
|
1
|
+
export * from "./defineField.js";
|
|
2
|
+
export * from "./defineWidget.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./defineField";
|
|
2
|
-
export * from "./defineWidget";
|
|
1
|
+
export * from "./defineField.js";
|
|
2
|
+
export * from "./defineWidget.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./read-block-manifest";
|
|
2
|
-
export * from "./read-view-manifest";
|
|
3
|
-
export * from "./read-admin-manifest";
|
|
4
|
-
export * from "./internal-store";
|
|
1
|
+
export * from "./read-block-manifest.js";
|
|
2
|
+
export * from "./read-view-manifest.js";
|
|
3
|
+
export * from "./read-admin-manifest.js";
|
|
4
|
+
export * from "./internal-store.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./read-block-manifest";
|
|
2
|
-
export * from "./read-view-manifest";
|
|
3
|
-
export * from "./read-admin-manifest";
|
|
4
|
-
export * from "./internal-store";
|
|
1
|
+
export * from "./read-block-manifest.js";
|
|
2
|
+
export * from "./read-view-manifest.js";
|
|
3
|
+
export * from "./read-admin-manifest.js";
|
|
4
|
+
export * from "./internal-store.js";
|
package/dist/app/server/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="vinxi/types/server" />
|
|
2
2
|
import { splitSetCookieString } from "cookie-es";
|
|
3
3
|
import { getProxyRequestHeaders, getRequestURL, getWebRequest } from "vinxi/http";
|
|
4
|
-
import { getManifest } from "vinxi/manifest";
|
|
5
4
|
export async function proxyWpAdmin(event, serverContext) {
|
|
6
5
|
const replaceUrls = serverContext.replaceUrls;
|
|
7
6
|
const req = getWebRequest(event);
|
|
@@ -51,7 +50,7 @@ export async function proxyWpAdmin(event, serverContext) {
|
|
|
51
50
|
}
|
|
52
51
|
// If the content type is text/html, inject the Vite assets into the response — assuming the placeholder comments are found
|
|
53
52
|
if (contentType.startsWith("text/html")) {
|
|
54
|
-
const clientManifest = getManifest("admin");
|
|
53
|
+
const clientManifest = serverContext.getManifest("admin");
|
|
55
54
|
const assets = await clientManifest.inputs[clientManifest.handler].assets();
|
|
56
55
|
body = body.replace("<!---VITE_HEADER--->", () => assets.map((asset) => renderAsset(asset)).join("\n"));
|
|
57
56
|
body = body.replace("<!---VITE_FOOTER--->", () => renderAsset({
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { RouteData } from "../lib/routing/types.js";
|
|
2
|
-
|
|
2
|
+
import { ServerContext } from "./server-context.js";
|
|
3
|
+
export declare function renderPageToSSRStream(pathname: string, initialData: RouteData, serverContext: ServerContext): Promise<unknown>;
|
|
@@ -2,11 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { renderAsset } from "@vinxi/react";
|
|
3
3
|
import { Suspense } from "react";
|
|
4
4
|
import { renderToPipeableStream } from "react-dom/server";
|
|
5
|
-
import { getManifest } from "vinxi/manifest";
|
|
6
5
|
import { SSRRoot } from "../entry/ssr-root.js";
|
|
7
6
|
import { RouteLoader } from "../lib/routing/loader.js";
|
|
8
|
-
export async function renderPageToSSRStream(pathname, initialData) {
|
|
9
|
-
const clientManifest = getManifest("client");
|
|
7
|
+
export async function renderPageToSSRStream(pathname, initialData, serverContext) {
|
|
8
|
+
const clientManifest = serverContext.getManifest("client");
|
|
10
9
|
const assets = await clientManifest.inputs[clientManifest.handler].assets();
|
|
11
10
|
const jsx = (_jsx(SSRRoot, { assets: _jsx(Suspense, { children: assets.map((m) => renderAsset(m)) }), pathname: pathname, initialData: initialData, loader: new RouteLoader() }));
|
|
12
11
|
const stream = await new Promise(async (resolve) => {
|
|
@@ -15,7 +14,7 @@ export async function renderPageToSSRStream(pathname, initialData) {
|
|
|
15
14
|
resolve(stream);
|
|
16
15
|
},
|
|
17
16
|
bootstrapModules: [clientManifest.inputs[clientManifest.handler].output.path],
|
|
18
|
-
bootstrapScriptContent: `window.manifest = ${JSON.stringify(
|
|
17
|
+
bootstrapScriptContent: `window.manifest = ${JSON.stringify(clientManifest.json())}; window._PAGE_DATA = ${JSON.stringify(initialData)}`,
|
|
19
18
|
});
|
|
20
19
|
});
|
|
21
20
|
return stream;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { UrlReplacerConf } from "./utils/replace-host.js";
|
|
2
1
|
import { RequestHeaders } from "vinxi/http";
|
|
2
|
+
import { UrlReplacerConf } from "./utils/replace-host.js";
|
|
3
|
+
import { Manifest } from "vinxi/dist/types/types/manifest";
|
|
3
4
|
export type ServerContextArgs = {
|
|
4
5
|
dev: boolean;
|
|
5
6
|
origin: string;
|
|
7
|
+
getManifest: (name: string) => Manifest;
|
|
6
8
|
replaceUrls?: UrlReplacerConf;
|
|
7
9
|
};
|
|
8
10
|
export declare class ServerContext {
|
|
9
11
|
dev: boolean;
|
|
10
12
|
origin: string;
|
|
13
|
+
getManifest: (name: string) => Manifest;
|
|
11
14
|
replaceUrls?: (text: string) => string;
|
|
12
15
|
constructor(conf: ServerContextArgs);
|
|
13
16
|
getOriginUrl(url: string): string;
|
|
@@ -15,10 +15,12 @@ const PROXY_REQUEST_HEADERS = [
|
|
|
15
15
|
export class ServerContext {
|
|
16
16
|
dev;
|
|
17
17
|
origin;
|
|
18
|
+
getManifest;
|
|
18
19
|
replaceUrls;
|
|
19
20
|
constructor(conf) {
|
|
20
21
|
this.dev = conf.dev;
|
|
21
22
|
this.origin = conf.origin;
|
|
23
|
+
this.getManifest = conf.getManifest;
|
|
22
24
|
if (conf.replaceUrls) {
|
|
23
25
|
this.replaceUrls = createUrlReplacer(conf.replaceUrls);
|
|
24
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.0.0-beta.
|
|
1
|
+
export declare const VERSION = "2.0.0-beta.10";
|
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.10";
|
|
@@ -85,8 +85,29 @@ export function ssrPlugin() {
|
|
|
85
85
|
name: "proxy-external-ssr-modules",
|
|
86
86
|
config(config) {
|
|
87
87
|
config.legacy = {
|
|
88
|
+
...config.legacy,
|
|
88
89
|
proxySsrExternalModules: true,
|
|
89
90
|
};
|
|
91
|
+
// config.ssr = {
|
|
92
|
+
// ...config.ssr,
|
|
93
|
+
// noExternal: ["eddev", ...(config?.optimizeDeps?.noExternal ?? [])],
|
|
94
|
+
// // optimizeDeps: {
|
|
95
|
+
// // include: ["eddev", "vinxi"],
|
|
96
|
+
// // },
|
|
97
|
+
// }
|
|
98
|
+
config.optimizeDeps = {
|
|
99
|
+
...config.optimizeDeps,
|
|
100
|
+
include: [
|
|
101
|
+
"valtio",
|
|
102
|
+
"zustand",
|
|
103
|
+
"@tanstack/react-query",
|
|
104
|
+
"qs",
|
|
105
|
+
"react",
|
|
106
|
+
"react-dom/client",
|
|
107
|
+
...(config?.optimizeDeps?.include ?? []),
|
|
108
|
+
],
|
|
109
|
+
exclude: ["eddev", ...(config?.optimizeDeps?.exclude ?? [])],
|
|
110
|
+
};
|
|
90
111
|
return config;
|
|
91
112
|
},
|
|
92
113
|
};
|
|
@@ -113,12 +134,7 @@ function buildStatusPlugin(console) {
|
|
|
113
134
|
};
|
|
114
135
|
}
|
|
115
136
|
export function corePlugins(args) {
|
|
116
|
-
return [
|
|
117
|
-
tsconfigPaths(),
|
|
118
|
-
reactPlugin(),
|
|
119
|
-
args.mode === "development" && args.serverless && ssrPlugin(),
|
|
120
|
-
envPlugin(args),
|
|
121
|
-
].flat();
|
|
137
|
+
return [tsconfigPaths(), reactPlugin(), args.serverless && ssrPlugin(), envPlugin(args)].flat();
|
|
122
138
|
}
|
|
123
139
|
export function getViteConfig(args) {
|
|
124
140
|
const console = args.console;
|
|
@@ -17,22 +17,30 @@ export function createVinxiCodegen(opts) {
|
|
|
17
17
|
if (opts.serverless) {
|
|
18
18
|
codegen.registerFile({
|
|
19
19
|
name: "context.ts",
|
|
20
|
-
generate:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
generate: () => {
|
|
21
|
+
const args = {
|
|
22
|
+
dev: true,
|
|
23
|
+
origin: project.origin,
|
|
24
|
+
replaceUrls: {
|
|
25
|
+
from: project.origin,
|
|
26
|
+
to: opts.endpoint ?? "",
|
|
27
|
+
prefixes: [
|
|
28
|
+
{ prefix: "/wp-content/uploads", replace: project.config?.serverless.uploads === "proxy" },
|
|
29
|
+
{ prefix: "/wp-content/plugins", replace: project.config?.serverless.plugins === "proxy" },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return code /* tsx */ `
|
|
34
|
+
import { ServerContext } from "eddev/server"
|
|
35
|
+
import { getManifest } from "vinxi/manifest"
|
|
36
|
+
|
|
37
|
+
export const serverContext = new ServerContext({${Object.entries(args)
|
|
38
|
+
.map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
|
|
39
|
+
.join(",\n")},
|
|
40
|
+
getManifest
|
|
41
|
+
})
|
|
42
|
+
`.toString();
|
|
43
|
+
},
|
|
36
44
|
});
|
|
37
45
|
}
|
|
38
46
|
if (opts.serverless) {
|
|
@@ -238,7 +246,7 @@ export function createVinxiCodegen(opts) {
|
|
|
238
246
|
if (response.ok) {
|
|
239
247
|
setResponseStatus(event, response.status)
|
|
240
248
|
setResponseHeader(event, "Content-Type", "text/html; charset=utf-8")
|
|
241
|
-
return renderPageToSSRStream(url.pathname, await response.json())
|
|
249
|
+
return renderPageToSSRStream(url.pathname, await response.json(), serverContext)
|
|
242
250
|
} else {
|
|
243
251
|
return response
|
|
244
252
|
}
|
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.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -118,11 +118,11 @@
|
|
|
118
118
|
"@types/node": "^20.9.0",
|
|
119
119
|
"@types/react": "^18.3.3",
|
|
120
120
|
"@types/react-dom": "^18.3.0",
|
|
121
|
+
"typescript": "^5.5.2",
|
|
121
122
|
"@types/wordpress__blocks": "^12.5.13",
|
|
122
123
|
"@types/wordpress__components": "^23.0.11",
|
|
123
124
|
"@types/wordpress__editor": "^13.6.7",
|
|
124
|
-
"@types/wordpress__hooks": "^2.11.0"
|
|
125
|
-
"typescript": "^5.5.2"
|
|
125
|
+
"@types/wordpress__hooks": "^2.11.0"
|
|
126
126
|
},
|
|
127
127
|
"peerDependencies": {
|
|
128
128
|
"react": "^18.3.1",
|