eddev 2.0.0-beta.2 → 2.0.0-beta.21
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/entry/boot-admin.d.ts +1 -0
- package/dist/app/entry/{main.admin.js → boot-admin.js} +3 -5
- package/dist/app/entry/spa-root.d.ts +1 -0
- package/dist/app/entry/{Root.js → spa-root.js} +4 -4
- package/dist/app/entry/ssr-root-client.d.ts +4 -0
- package/dist/app/entry/ssr-root-client.js +9 -0
- package/dist/app/entry/ssr-root.d.ts +9 -0
- package/dist/app/entry/ssr-root.js +21 -0
- package/dist/app/lib/admin/index.d.ts +2 -2
- package/dist/app/lib/admin/index.js +2 -2
- package/dist/app/lib/admin/installFieldTypes.js +1 -1
- package/dist/app/lib/admin/runWidgets.js +1 -1
- package/dist/app/lib/blocks/ContentBlocks.js +4 -4
- package/dist/app/lib/blocks/EditableText.d.ts +1 -1
- package/dist/app/lib/blocks/EditableText.js +2 -2
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +1 -1
- package/dist/app/lib/blocks/InnerBlocks.d.ts +2 -2
- package/dist/app/lib/blocks/InnerBlocks.js +4 -4
- package/dist/app/lib/blocks/block-utils.d.ts +1 -1
- package/dist/app/lib/blocks/block-utils.js +1 -1
- package/dist/app/lib/blocks/editor/EditorSupport.js +3 -3
- package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +1 -1
- package/dist/app/lib/blocks/editor/editor-config.d.ts +1 -1
- package/dist/app/lib/blocks/editor/editor-config.js +1 -1
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +5 -5
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
- package/dist/app/lib/blocks/index.d.ts +9 -9
- package/dist/app/lib/blocks/index.js +9 -9
- package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
- package/dist/app/lib/blocks/inline-editing.js +3 -3
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +5 -3
- package/dist/app/lib/devtools/components/DevUI.js +1 -1
- package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
- package/dist/app/lib/devtools/dev-tools-store.js +8 -0
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1078 -1079
- package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
- package/dist/app/lib/devtools/index.d.ts +1 -0
- package/dist/app/lib/devtools/index.js +1 -1
- package/dist/app/lib/devtools/loader.js +4 -4
- package/dist/app/lib/dynamic/index.d.ts +1 -1
- package/dist/app/lib/dynamic/index.js +1 -1
- package/dist/app/lib/hooks/index.d.ts +5 -5
- package/dist/app/lib/hooks/index.js +5 -5
- package/dist/app/lib/hooks/queryUtils.d.ts +4 -1
- package/dist/app/lib/hooks/queryUtils.js +10 -13
- package/dist/app/lib/hooks/useAppData.js +1 -1
- package/dist/app/lib/internal/index.d.ts +4 -4
- package/dist/app/lib/internal/index.js +4 -4
- package/dist/app/lib/internal/internal-store.d.ts +0 -2
- package/dist/app/lib/internal/internal-store.js +1 -3
- package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +3 -511
- package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
- package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/index.js +1 -1
- package/dist/app/lib/routing/components/BrowserRouter.js +4 -4
- package/dist/app/lib/routing/components/ClientOnly.d.ts +1 -1
- package/dist/app/lib/routing/components/ClientOnly.js +1 -1
- package/dist/app/lib/routing/components/Link.js +5 -5
- package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
- package/dist/app/lib/routing/components/RouteRenderer.js +3 -3
- package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
- package/dist/app/lib/routing/components/SSRRouter.js +4 -4
- package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
- package/dist/app/lib/routing/context.d.ts +2 -2
- package/dist/app/lib/routing/context.js +1 -1
- package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
- package/dist/app/lib/routing/hooks/useRoute.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRoute.js +1 -1
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
- package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouter.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
- package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
- package/dist/app/lib/routing/index.d.ts +13 -13
- package/dist/app/lib/routing/index.js +13 -13
- package/dist/app/lib/routing/loader.d.ts +2 -2
- package/dist/app/lib/routing/loader.js +7 -5
- package/dist/app/lib/routing/types.d.ts +2 -2
- package/dist/app/lib/routing/utils.d.ts +1 -1
- package/dist/app/lib/views/index.d.ts +1 -1
- package/dist/app/lib/views/index.js +1 -1
- package/dist/app/server/index.d.ts +3 -0
- package/dist/app/server/index.js +3 -0
- package/dist/app/server/proxy-wp-admin.d.ts +3 -0
- package/dist/app/server/proxy-wp-admin.js +105 -0
- package/dist/app/server/render-ssr-page.d.ts +3 -0
- package/dist/app/server/render-ssr-page.js +21 -0
- package/dist/app/server/server-context.d.ts +37 -0
- package/dist/app/server/server-context.js +118 -0
- package/dist/app/server/utils/headers.d.ts +1 -0
- package/dist/app/server/utils/headers.js +17 -0
- package/dist/app/server/utils/replace-host.d.ts +6 -4
- package/dist/app/server/utils/replace-host.js +58 -11
- package/dist/node/cli/cli-worker.d.ts +1 -1
- package/dist/node/cli/cli-worker.js +7 -2
- package/dist/node/cli/cli.js +83 -12
- package/dist/node/cli/display/CLIApp.d.ts +1 -1
- package/dist/node/cli/display/CLIApp.js +3 -6
- package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
- package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
- package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
- package/dist/node/cli/display/tools/cli-tools.js +9 -9
- package/dist/node/cli/display/util/colors.d.ts +2 -2
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/build-vinxi.d.ts +8 -0
- package/dist/node/compiler/build-vinxi.js +37 -0
- package/dist/node/compiler/bundler.admin.d.ts +2 -2
- package/dist/node/compiler/bundler.admin.js +3 -4
- package/dist/node/compiler/bundler.frontend.d.ts +1 -1
- package/dist/node/compiler/bundler.frontend.js +3 -4
- package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
- package/dist/node/compiler/dev-server.js +97 -0
- package/dist/node/compiler/get-vite-config.d.ts +19 -0
- package/dist/node/compiler/get-vite-config.js +201 -0
- package/dist/node/compiler/vinxi-app.d.ts +10 -0
- package/dist/node/compiler/vinxi-app.js +121 -0
- package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
- package/dist/node/compiler/vinxi-codegen.js +417 -0
- package/dist/node/graphql/graphql-codegen.d.ts +1 -1
- package/dist/node/graphql/graphql-codegen.js +3 -3
- package/dist/node/graphql/graphql-schema-loader.js +15 -18
- package/dist/node/project/config.js +1 -1
- package/dist/node/project/env.d.ts +1 -1
- package/dist/node/project/env.js +1 -1
- package/dist/node/project/favicons.d.ts +1 -0
- package/dist/node/project/favicons.js +1 -1
- package/dist/node/project/manifest/block-manifest.js +2 -2
- package/dist/node/project/manifest/manifest.d.ts +1 -1
- package/dist/node/project/manifest/manifest.js +1 -1
- package/dist/node/project/manifest/view-manifest.js +2 -2
- package/dist/node/project/project.d.ts +3 -2
- package/dist/node/project/project.js +17 -19
- package/dist/node/project/wp-info.js +0 -2
- package/dist/node/types/block-type.d.ts +2 -2
- package/dist/node/types/view-type.js +3 -4
- package/dist/node/utils/fs-codegen.d.ts +40 -0
- package/dist/node/utils/fs-codegen.js +97 -0
- package/dist/node/utils/fs.js +2 -0
- package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
- package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
- package/package.json +29 -31
- package/tsconfig.app.json +2 -2
- package/tsconfig.node.json +2 -2
- package/types.app.d.ts +2 -2
- package/types.app.internal.d.ts +2 -2
- package/types.node.d.ts +3 -3
- package/dist/app/entry/Root.d.ts +0 -1
- package/dist/app/entry/main.admin.d.ts +0 -3
- package/dist/app/entry/main.frontend.spa.d.ts +0 -3
- package/dist/app/entry/main.frontend.spa.js +0 -13
- package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
- package/dist/app/entry/main.frontend.ssr.js +0 -79
- package/dist/app/entry/main.serverless.dev.d.ts +0 -4
- package/dist/app/entry/main.serverless.dev.js +0 -21
- package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
- package/dist/app/server/create-api-builtin-hono.js +0 -80
- package/dist/app/server/create-ssr-hono.d.ts +0 -18
- package/dist/app/server/create-ssr-hono.js +0 -104
- package/dist/app/server/utils/index.html.d.ts +0 -2
- package/dist/app/server/utils/index.html.js +0 -14
- package/dist/node/compiler/index.html.d.ts +0 -2
- package/dist/node/compiler/index.html.js +0 -15
- package/dist/node/compiler/serverless.dev.js +0 -215
- package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
- package/dist/node/compiler/vite/get-vite-config.js +0 -315
- package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-admin.js +0 -67
- package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-blocks.js +0 -73
- package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
- package/dist/node/compiler/vite/plugin-entry.js +0 -16
- package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
- package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-theme.js +0 -40
- package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-views.js +0 -51
- package/dist/node/utils/console.d.ts +0 -21
- package/dist/node/utils/console.js +0 -28
- package/dist/node/utils/unsafe-fetch.d.ts +0 -2
- package/dist/node/utils/unsafe-fetch.js +0 -19
- package/tsup.config.ts +0 -40
- package/types.manifests.d.ts +0 -22
- /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
- /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
- /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
- /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
- /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
- /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
- /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
- /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
- /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
- /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
- /package/dist/node/utils/{watchFileTree.d.ts → watch-file-tree.d.ts} +0 -0
- /package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +0 -0
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { Hono } from "hono";
|
|
2
|
-
import ReactDOMServer from "react-dom/server";
|
|
3
|
-
import { stream } from "hono/streaming";
|
|
4
|
-
export function createSSRHono(conf) {
|
|
5
|
-
const app = new Hono();
|
|
6
|
-
app.get("*", async (c) => {
|
|
7
|
-
const isPropsRequest = c.req.query("_props");
|
|
8
|
-
const result = await conf.render({ pathname: c.req.path });
|
|
9
|
-
let didError = false;
|
|
10
|
-
async function propsResponse() {
|
|
11
|
-
c.status(200);
|
|
12
|
-
c.header("Content-Type", "application/json");
|
|
13
|
-
return c.json(result.data);
|
|
14
|
-
}
|
|
15
|
-
const getTemplateParts = () => {
|
|
16
|
-
const collected = result.getCollectedOutput();
|
|
17
|
-
let [head, foot] = result.indexTemplate.split("<!--ssr-outlet-->");
|
|
18
|
-
head = head.replace("<!--ssr-meta-->", collected.head);
|
|
19
|
-
const dataPayload = `\n<script type="text/javascript">window._PAGE_DATA = ${JSON.stringify(result.data, null, 2)}</script>\n`;
|
|
20
|
-
foot = foot.replace("<!--ssr-meta-->", dataPayload + collected.foot);
|
|
21
|
-
return [head, foot];
|
|
22
|
-
};
|
|
23
|
-
// For Web Stream environments, and when react-dom/server exports renderToReadableStream for Node.js
|
|
24
|
-
// (Even though Node 20+ supports Web Streams, ReactDOM doesn't yet export it for Node)
|
|
25
|
-
if (ReactDOMServer.renderToReadableStream) {
|
|
26
|
-
const reactStream = await ReactDOMServer.renderToReadableStream(result.jsx, {
|
|
27
|
-
onError: (err) => {
|
|
28
|
-
didError = true;
|
|
29
|
-
console.warn("Failed to server-render React frontend");
|
|
30
|
-
console.error(err);
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
await reactStream.allReady;
|
|
34
|
-
if (isPropsRequest) {
|
|
35
|
-
return propsResponse();
|
|
36
|
-
}
|
|
37
|
-
const [head, foot] = getTemplateParts();
|
|
38
|
-
return stream(c, async (stream) => {
|
|
39
|
-
await stream.write(head);
|
|
40
|
-
await stream.pipe(reactStream);
|
|
41
|
-
await stream.write(foot);
|
|
42
|
-
stream.close();
|
|
43
|
-
});
|
|
44
|
-
// const result = await stream.getReader().read()
|
|
45
|
-
// const result = { value: "test" }
|
|
46
|
-
// return finalize(result.value)
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
const reactStream = ReactDOMServer.renderToPipeableStream(result.jsx, {
|
|
51
|
-
onError: (err) => {
|
|
52
|
-
didError = true;
|
|
53
|
-
console.warn("Failed to server-render React frontend");
|
|
54
|
-
console.error(err);
|
|
55
|
-
// setModuleCollector(() => {})
|
|
56
|
-
},
|
|
57
|
-
onShellError: (err) => {
|
|
58
|
-
console.warn("Shell");
|
|
59
|
-
console.error(err);
|
|
60
|
-
},
|
|
61
|
-
onAllReady: async () => {
|
|
62
|
-
if (isPropsRequest) {
|
|
63
|
-
resolve(propsResponse());
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
c.status(200);
|
|
67
|
-
c.header("Content-Type", "text/html");
|
|
68
|
-
resolve(stream(c, async (stream) => {
|
|
69
|
-
const [head, foot] = getTemplateParts();
|
|
70
|
-
stream.write(head);
|
|
71
|
-
reactStream.pipe({
|
|
72
|
-
write(chunk) {
|
|
73
|
-
stream.write(chunk);
|
|
74
|
-
},
|
|
75
|
-
close() {
|
|
76
|
-
// stream.close()
|
|
77
|
-
},
|
|
78
|
-
destroy() { },
|
|
79
|
-
on(event, cb) { },
|
|
80
|
-
async end() {
|
|
81
|
-
stream.write(foot);
|
|
82
|
-
stream.close();
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
}));
|
|
86
|
-
// reac.pipe(new WritableStream((chunk) => {
|
|
87
|
-
// chunk
|
|
88
|
-
// }))
|
|
89
|
-
// resolve(stream())
|
|
90
|
-
// const collected = getCollectedOutput()
|
|
91
|
-
// res.status(200).set({ "Content-Type": "text/html" })
|
|
92
|
-
// res.write(htmlParts[0].replace("<!--ssr-meta-->", collected.head ?? ""))
|
|
93
|
-
// stream.pipe(res)
|
|
94
|
-
// res.write(htmlParts[1].replace("<!--ssr-meta-->", collected.footer ?? ""))
|
|
95
|
-
// res.end()
|
|
96
|
-
}
|
|
97
|
-
// setModuleCollector(() => {})
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
return app;
|
|
104
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const _default: "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" type=\"image/svg+xml\" href=\"/vite.svg\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <!--ssr-meta-->\n </head>\n <body>\n <div id=\"root\"><!--ssr-outlet--></div>\n <!--ssr-meta-->\n <script type=\"module\" src=\"/_boot.js\"></script>\n </body>\n</html>";
|
|
2
|
-
export default _default;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default `<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<!--ssr-meta-->
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root"><!--ssr-outlet--></div>
|
|
11
|
-
<!--ssr-meta-->
|
|
12
|
-
<script type="module" src="/_boot.js"></script>
|
|
13
|
-
</body>
|
|
14
|
-
</html>`;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const _default: "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" type=\"image/svg+xml\" href=\"/vite.svg\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <link rel=\"stylesheet\" href=\"/views/index.css\" />\n <!--ssr-meta-->\n </head>\n <body>\n <div id=\"root\"><!--ssr-outlet--></div>\n <!--ssr-meta-->\n <script type=\"module\" src=\"/_boot.js\"></script>\n </body>\n</html>";
|
|
2
|
-
export default _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export default `<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<link rel="stylesheet" href="/views/index.css" />
|
|
8
|
-
<!--ssr-meta-->
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<div id="root"><!--ssr-outlet--></div>
|
|
12
|
-
<!--ssr-meta-->
|
|
13
|
-
<script type="module" src="/_boot.js"></script>
|
|
14
|
-
</body>
|
|
15
|
-
</html>`;
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { getRequestListener } from "@hono/node-server";
|
|
2
|
-
import express from "express";
|
|
3
|
-
import expressProxy from "express-http-proxy";
|
|
4
|
-
import { Agent as HttpAgent } from "http";
|
|
5
|
-
import { Agent as HttpsAgent } from "https";
|
|
6
|
-
import { listen } from "listhen";
|
|
7
|
-
import fetch from "node-fetch";
|
|
8
|
-
import { relative } from "path";
|
|
9
|
-
import { parseURL } from "ufo";
|
|
10
|
-
import { createServer as createViteServer, defineConfig, mergeConfig } from "vite";
|
|
11
|
-
import { ProjectEnvUtils } from "../project/env.js";
|
|
12
|
-
import { ensureSelfSignedCert } from "../utils/selfSignedCert.js";
|
|
13
|
-
import { createConsole } from "../utils/statefulLog.js";
|
|
14
|
-
import indexHtml from "./index.html.js";
|
|
15
|
-
import { getViteConfig } from "./vite/get-vite-config.js";
|
|
16
|
-
const console = createConsole("Dev Server", "dev");
|
|
17
|
-
export const serverlessLog = console;
|
|
18
|
-
export class ServerlessDevServer {
|
|
19
|
-
project;
|
|
20
|
-
opts;
|
|
21
|
-
constructor(project, opts) {
|
|
22
|
-
this.project = project;
|
|
23
|
-
this.opts = opts;
|
|
24
|
-
this.start();
|
|
25
|
-
}
|
|
26
|
-
async start() {
|
|
27
|
-
console.setWorking(true);
|
|
28
|
-
const siteURL = ProjectEnvUtils.get("SITE_URL");
|
|
29
|
-
const parsedSiteURL = parseURL(siteURL);
|
|
30
|
-
let serverlessPort = 8080;
|
|
31
|
-
let hmrPort = serverlessPort + 5;
|
|
32
|
-
const serverlessHost = parsedSiteURL.host?.endsWith(".local") ? parsedSiteURL.host : "localhost";
|
|
33
|
-
console.info(`Starting dev server...`);
|
|
34
|
-
const keys = await ensureSelfSignedCert(serverlessHost, this.project.rootDir);
|
|
35
|
-
const app = express();
|
|
36
|
-
const hotServer = await listen(() => { }, {
|
|
37
|
-
port: hmrPort,
|
|
38
|
-
hostname: serverlessHost,
|
|
39
|
-
qr: false,
|
|
40
|
-
showURL: false,
|
|
41
|
-
https: {
|
|
42
|
-
cert: keys.certFile,
|
|
43
|
-
key: keys.keyFile,
|
|
44
|
-
domains: [serverlessHost],
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
hmrPort = hotServer.address.port;
|
|
48
|
-
const mainServer = await listen(app, {
|
|
49
|
-
port: serverlessPort,
|
|
50
|
-
hostname: serverlessHost,
|
|
51
|
-
qr: false,
|
|
52
|
-
showURL: false,
|
|
53
|
-
https: {
|
|
54
|
-
cert: keys.certFile,
|
|
55
|
-
key: keys.keyFile,
|
|
56
|
-
domains: [serverlessHost],
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
const vite = await createViteServer(mergeConfig(getViteConfig({
|
|
60
|
-
console,
|
|
61
|
-
mode: this.opts.mode,
|
|
62
|
-
project: this.project,
|
|
63
|
-
rootDir: this.project.rootDir,
|
|
64
|
-
outDir: relative(this.project.rootDir, "./dist/ssr/"),
|
|
65
|
-
serverless: true,
|
|
66
|
-
target: "frontend",
|
|
67
|
-
}), defineConfig({
|
|
68
|
-
mode: "development",
|
|
69
|
-
base: "/",
|
|
70
|
-
server: {
|
|
71
|
-
middlewareMode: true,
|
|
72
|
-
hmr: {
|
|
73
|
-
server: hotServer.server,
|
|
74
|
-
port: hmrPort,
|
|
75
|
-
path: "/_hmr",
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
build: {
|
|
79
|
-
ssr: true,
|
|
80
|
-
sourcemap: true,
|
|
81
|
-
watch: {
|
|
82
|
-
clearScreen: true,
|
|
83
|
-
},
|
|
84
|
-
rollupOptions: {
|
|
85
|
-
onwarn(warning, warn) {
|
|
86
|
-
if (warning.code === "SOURCEMAP_ERROR") {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
warn(warning);
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
appType: "custom",
|
|
94
|
-
})));
|
|
95
|
-
vite.watcher.on("change", (file) => {
|
|
96
|
-
console.resetLog();
|
|
97
|
-
});
|
|
98
|
-
console.setWorking(false);
|
|
99
|
-
const proxyTarget = "https://" + serverlessHost + ":" + serverlessPort + "/";
|
|
100
|
-
const proxyDest = parsedSiteURL.protocol + "//" + parsedSiteURL.host + "/";
|
|
101
|
-
console.info("Proxying WordPress from", proxyDest);
|
|
102
|
-
const replaceTargetString = proxyDest.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\/");
|
|
103
|
-
const replaceTargetEscapedString = proxyDest.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\\\/");
|
|
104
|
-
const replaceTarget = new RegExp(replaceTargetString, "g");
|
|
105
|
-
const replaceTargetEscaped = new RegExp(replaceTargetEscapedString, "g");
|
|
106
|
-
const replaceHost = (value) => {
|
|
107
|
-
return value.replace(replaceTarget, proxyTarget).replace(replaceTargetEscaped, proxyTarget.replaceAll("/", "\\/"));
|
|
108
|
-
};
|
|
109
|
-
const proxy = expressProxy(parsedSiteURL.protocol + "//" + parsedSiteURL.host, {
|
|
110
|
-
proxyReqOptDecorator: function (proxyReqOpts, originalReq) {
|
|
111
|
-
// @ts-ignore
|
|
112
|
-
proxyReqOpts.rejectUnauthorized = false;
|
|
113
|
-
// @ts-ignore
|
|
114
|
-
proxyReqOpts.headers["X-ED-Dev-Proxy"] = "true";
|
|
115
|
-
return proxyReqOpts;
|
|
116
|
-
},
|
|
117
|
-
userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) {
|
|
118
|
-
for (let [key, value] of Object.entries(headers)) {
|
|
119
|
-
if (typeof value === "string") {
|
|
120
|
-
headers[key] = replaceHost(value);
|
|
121
|
-
}
|
|
122
|
-
else if (Array.isArray(value)) {
|
|
123
|
-
headers[key] = value.map((v) => {
|
|
124
|
-
return replaceHost(v);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return headers;
|
|
129
|
-
},
|
|
130
|
-
userResDecorator(proxyRes, proxyResData, userReq, userRes) {
|
|
131
|
-
if (userReq.path.includes(".php") || !userReq.path.includes(".") || userReq.path.startsWith("/wp-json")) {
|
|
132
|
-
proxyResData = replaceHost(proxyResData.toString("utf8"));
|
|
133
|
-
}
|
|
134
|
-
return proxyResData;
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
app.use(async (req, res, next) => {
|
|
138
|
-
if (!req.originalUrl.includes(".php") && !req.originalUrl.includes("/?")) {
|
|
139
|
-
vite.middlewares.handle(req, res, next);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
next();
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
/**
|
|
146
|
-
* Allow https access from self-signed certificates, when working locally during development
|
|
147
|
-
*/
|
|
148
|
-
const httpsAgent = new HttpsAgent({
|
|
149
|
-
rejectUnauthorized: false,
|
|
150
|
-
});
|
|
151
|
-
const httpAgent = new HttpAgent({});
|
|
152
|
-
const fetchImpl = (...args) => {
|
|
153
|
-
return fetch(args[0], {
|
|
154
|
-
...(args[1] ?? {}),
|
|
155
|
-
agent: function (_parsedURL) {
|
|
156
|
-
if (_parsedURL.protocol == "http:") {
|
|
157
|
-
return httpAgent;
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
return httpsAgent;
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
app.use(async (req, res, next) => {
|
|
166
|
-
if (!req.path.startsWith("/api"))
|
|
167
|
-
return next();
|
|
168
|
-
const { getHonoAPI, patchConsole } = await vite.ssrLoadModule("/_ssr.js", {
|
|
169
|
-
fixStacktrace: true,
|
|
170
|
-
});
|
|
171
|
-
patchConsole(console);
|
|
172
|
-
const hono = getHonoAPI({
|
|
173
|
-
fetchImpl,
|
|
174
|
-
replaceUrls: {
|
|
175
|
-
from: proxyDest,
|
|
176
|
-
to: "/",
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
const handler = getRequestListener(hono.fetch, {
|
|
180
|
-
errorHandler: (err) => {
|
|
181
|
-
console.error(err);
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
await handler(req, res);
|
|
185
|
-
});
|
|
186
|
-
app.use(async (req, res, next) => {
|
|
187
|
-
const url = req.originalUrl;
|
|
188
|
-
if (url.includes(".") || url.startsWith("/wp-") || url.startsWith("/graphql"))
|
|
189
|
-
return next();
|
|
190
|
-
const { patchConsole, setFetchImpl, getHonoSSR, setIndexTransformer } = await vite.ssrLoadModule("/_ssr.js", {
|
|
191
|
-
fixStacktrace: true,
|
|
192
|
-
});
|
|
193
|
-
patchConsole(console);
|
|
194
|
-
const hono = getHonoSSR({
|
|
195
|
-
fetchImpl,
|
|
196
|
-
indexTransformer: async (index) => await vite.transformIndexHtml(url, indexHtml),
|
|
197
|
-
replaceUrls: {
|
|
198
|
-
from: proxyDest,
|
|
199
|
-
to: "/",
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
const handler = getRequestListener(hono.fetch, {
|
|
203
|
-
errorHandler: (err) => {
|
|
204
|
-
console.error(err);
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
await handler(req, res);
|
|
208
|
-
});
|
|
209
|
-
app.use(proxy);
|
|
210
|
-
console.setState({
|
|
211
|
-
serverlessUrl: "https://" + serverlessHost + ":" + mainServer.address.port + "/",
|
|
212
|
-
wordpressUrl: proxyDest,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { InlineConfig } from "vite";
|
|
2
|
-
import { Project } from "../../project/project.js";
|
|
3
|
-
import { StatefulLog } from "../../utils/statefulLog.js";
|
|
4
|
-
export type Args = {
|
|
5
|
-
mode: "development" | "production";
|
|
6
|
-
serverless: boolean;
|
|
7
|
-
target: "frontend" | "cms";
|
|
8
|
-
rootDir: string;
|
|
9
|
-
outDir: string;
|
|
10
|
-
project: Project;
|
|
11
|
-
console: StatefulLog<any>;
|
|
12
|
-
};
|
|
13
|
-
export declare function getViteConfig(args: Args): InlineConfig;
|