eddev 2.0.0-beta.6 → 2.0.0-beta.61

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.
Files changed (257) hide show
  1. package/dist/app/entry/MetaTags.d.ts +7 -0
  2. package/dist/app/entry/MetaTags.js +17 -0
  3. package/dist/app/entry/boot-admin.d.ts +1 -0
  4. package/dist/app/entry/boot-admin.js +14 -0
  5. package/dist/app/entry/spa-root.d.ts +1 -0
  6. package/dist/app/entry/spa-root.js +8 -0
  7. package/dist/app/entry/ssr-root-client.d.ts +6 -0
  8. package/dist/app/entry/ssr-root-client.js +26 -0
  9. package/dist/app/entry/ssr-root.d.ts +10 -0
  10. package/dist/app/entry/ssr-root.js +23 -0
  11. package/dist/app/lib/admin/index.d.ts +2 -2
  12. package/dist/app/lib/admin/index.js +2 -2
  13. package/dist/app/lib/admin/installFieldTypes.js +1 -1
  14. package/dist/app/lib/admin/runWidgets.js +1 -1
  15. package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
  16. package/dist/app/lib/blocks/ContentBlocks.js +5 -5
  17. package/dist/app/lib/blocks/EditableText.d.ts +1 -1
  18. package/dist/app/lib/blocks/EditableText.js +3 -3
  19. package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
  20. package/dist/app/lib/blocks/InnerBlocks.js +13 -5
  21. package/dist/app/lib/blocks/block-utils.d.ts +2 -2
  22. package/dist/app/lib/blocks/block-utils.js +2 -2
  23. package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
  24. package/dist/app/lib/blocks/editor/editor-config.d.ts +16 -3
  25. package/dist/app/lib/blocks/editor/editor-config.js +2 -4
  26. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +17 -13
  27. package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
  28. package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
  29. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  30. package/dist/app/lib/blocks/index.d.ts +9 -9
  31. package/dist/app/lib/blocks/index.js +9 -9
  32. package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
  33. package/dist/app/lib/blocks/inline-editing.js +7 -5
  34. package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
  35. package/dist/app/lib/devtools/components/DevUI.js +4 -3
  36. package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
  37. package/dist/app/lib/devtools/components/GridIndicator.js +24 -0
  38. package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
  39. package/dist/app/lib/devtools/dev-tools-store.js +8 -0
  40. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
  41. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  42. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1094 -1095
  43. package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
  44. package/dist/app/lib/devtools/index.d.ts +1 -0
  45. package/dist/app/lib/devtools/index.js +1 -1
  46. package/dist/app/lib/devtools/loader.js +8 -7
  47. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  48. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  49. package/dist/app/lib/dynamic/index.d.ts +1 -1
  50. package/dist/app/lib/dynamic/index.js +1 -1
  51. package/dist/app/lib/hooks/index.d.ts +4 -5
  52. package/dist/app/lib/hooks/index.js +4 -5
  53. package/dist/app/lib/hooks/queryUtils.d.ts +37 -3
  54. package/dist/app/lib/hooks/queryUtils.js +63 -26
  55. package/dist/app/lib/hooks/useAppData.js +1 -1
  56. package/dist/app/lib/hooks/useRPC.d.ts +0 -4
  57. package/dist/app/lib/hooks/useRPC.js +1 -8
  58. package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
  59. package/dist/app/lib/internal/finalize-rpc.js +3 -0
  60. package/dist/app/lib/internal/index.d.ts +5 -4
  61. package/dist/app/lib/internal/index.js +5 -4
  62. package/dist/app/lib/internal/internal-store.d.ts +0 -2
  63. package/dist/app/lib/internal/internal-store.js +1 -3
  64. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  65. package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
  66. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  67. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  68. package/dist/app/lib/legacy-stitches/index.js +1 -1
  69. package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
  70. package/dist/app/lib/routing/components/BackButton.js +47 -0
  71. package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
  72. package/dist/app/lib/routing/components/BrowserRouter.js +79 -11
  73. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  74. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  75. package/dist/app/lib/routing/components/Link.js +9 -10
  76. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  77. package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
  78. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  79. package/dist/app/lib/routing/components/SSRRouter.js +5 -6
  80. package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
  81. package/dist/app/lib/routing/context.d.ts +8 -5
  82. package/dist/app/lib/routing/context.js +13 -96
  83. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
  84. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  85. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
  86. package/dist/app/lib/routing/hooks/useRoute.js +22 -1
  87. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
  88. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  89. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  90. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  91. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  92. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  93. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  94. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  95. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  96. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  97. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  98. package/dist/app/lib/routing/index.d.ts +14 -13
  99. package/dist/app/lib/routing/index.js +14 -13
  100. package/dist/app/lib/routing/loader.d.ts +2 -2
  101. package/dist/app/lib/routing/loader.js +7 -5
  102. package/dist/app/lib/routing/types.d.ts +35 -9
  103. package/dist/app/lib/routing/utils.d.ts +3 -1
  104. package/dist/app/lib/routing/utils.js +12 -1
  105. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
  106. package/dist/app/lib/runtime/apiConfig.js +6 -0
  107. package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
  108. package/dist/app/lib/runtime/errorHandling.js +6 -0
  109. package/dist/app/lib/runtime/index.d.ts +2 -0
  110. package/dist/app/lib/runtime/index.js +2 -0
  111. package/dist/app/lib/views/index.d.ts +1 -1
  112. package/dist/app/lib/views/index.js +1 -1
  113. package/dist/app/server/defineRouter.d.ts +2 -0
  114. package/dist/app/server/defineRouter.js +4 -0
  115. package/dist/app/server/index.d.ts +5 -0
  116. package/dist/app/server/index.js +5 -0
  117. package/dist/app/server/proxy-wp-admin.d.ts +2 -0
  118. package/dist/app/server/proxy-wp-admin.js +112 -0
  119. package/dist/app/server/render-ssr-page.d.ts +11 -0
  120. package/dist/app/server/render-ssr-page.js +100 -0
  121. package/dist/app/server/rpc.d.ts +56 -0
  122. package/dist/app/server/rpc.js +18 -0
  123. package/dist/app/server/server-context.d.ts +53 -0
  124. package/dist/app/server/server-context.js +149 -0
  125. package/dist/app/server/utils/headers.d.ts +1 -0
  126. package/dist/app/server/utils/headers.js +17 -0
  127. package/dist/app/server/utils/replace-host.d.ts +6 -4
  128. package/dist/app/server/utils/replace-host.js +58 -11
  129. package/dist/app/utils/APIProvider.d.ts +2 -0
  130. package/dist/app/utils/APIProvider.js +5 -0
  131. package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
  132. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  133. package/dist/app/utils/ErrorMessage.d.ts +5 -0
  134. package/dist/app/utils/ErrorMessage.js +14 -0
  135. package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
  136. package/dist/app/utils/RouteErrorBoundary.js +38 -0
  137. package/dist/app/utils/query-client.d.ts +2 -0
  138. package/dist/app/utils/query-client.js +5 -1
  139. package/dist/app/utils/trpc-client.d.ts +2 -0
  140. package/dist/app/utils/trpc-client.js +34 -0
  141. package/dist/node/cli/cli-worker.d.ts +1 -1
  142. package/dist/node/cli/cli-worker.js +12 -3
  143. package/dist/node/cli/cli.js +91 -13
  144. package/dist/node/cli/display/CLIApp.d.ts +1 -1
  145. package/dist/node/cli/display/CLIApp.js +4 -7
  146. package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
  147. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
  148. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
  149. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
  150. package/dist/node/cli/display/tools/cli-tools.js +9 -9
  151. package/dist/node/cli/display/util/colors.d.ts +2 -2
  152. package/dist/node/cli/version.d.ts +1 -1
  153. package/dist/node/cli/version.js +1 -1
  154. package/dist/node/compiler/build-vinxi.d.ts +8 -0
  155. package/dist/node/compiler/build-vinxi.js +38 -0
  156. package/dist/node/compiler/bundler.admin.d.ts +2 -2
  157. package/dist/node/compiler/bundler.admin.js +3 -4
  158. package/dist/node/compiler/bundler.frontend.d.ts +1 -1
  159. package/dist/node/compiler/bundler.frontend.js +3 -4
  160. package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
  161. package/dist/node/compiler/dev-server.js +106 -0
  162. package/dist/node/compiler/get-vite-config.d.ts +19 -0
  163. package/dist/node/compiler/get-vite-config.js +200 -0
  164. package/dist/node/compiler/vinxi-app.d.ts +20 -0
  165. package/dist/node/compiler/vinxi-app.js +186 -0
  166. package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
  167. package/dist/node/compiler/vinxi-codegen.js +515 -0
  168. package/dist/node/graphql/graphql-codegen.d.ts +12 -2
  169. package/dist/node/graphql/graphql-codegen.js +213 -36
  170. package/dist/node/graphql/graphql-schema-loader.js +15 -18
  171. package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
  172. package/dist/node/graphql/query-files-loader.d.ts +3 -0
  173. package/dist/node/graphql/query-files-loader.js +5 -0
  174. package/dist/node/project/config.d.ts +31 -37
  175. package/dist/node/project/config.js +13 -11
  176. package/dist/node/project/env.d.ts +1 -1
  177. package/dist/node/project/env.js +1 -1
  178. package/dist/node/project/manifest/block-manifest.js +3 -2
  179. package/dist/node/project/manifest/manifest.d.ts +2 -1
  180. package/dist/node/project/manifest/manifest.js +15 -11
  181. package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
  182. package/dist/node/project/manifest/routes-manifest.js +74 -0
  183. package/dist/node/project/manifest/view-manifest.js +2 -2
  184. package/dist/node/project/project.d.ts +5 -2
  185. package/dist/node/project/project.js +21 -20
  186. package/dist/node/project/wp-info.js +3 -2
  187. package/dist/node/types/block-type.d.ts +5 -0
  188. package/dist/node/types/block-type.js +1 -0
  189. package/dist/node/types/view-type.js +3 -4
  190. package/dist/node/utils/fs-codegen.d.ts +42 -0
  191. package/dist/node/utils/fs-codegen.js +98 -0
  192. package/dist/node/utils/fs.js +2 -0
  193. package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
  194. package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
  195. package/dist/node/utils/watch-file-tree.d.ts +25 -0
  196. package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +12 -5
  197. package/package.json +39 -32
  198. package/types.app.d.ts +4 -2
  199. package/types.app.internal.d.ts +2 -2
  200. package/types.node.d.ts +3 -3
  201. package/dist/app/entry/Root.d.ts +0 -1
  202. package/dist/app/entry/Root.js +0 -9
  203. package/dist/app/entry/main.admin.d.ts +0 -3
  204. package/dist/app/entry/main.admin.js +0 -10
  205. package/dist/app/entry/main.frontend.spa.d.ts +0 -3
  206. package/dist/app/entry/main.frontend.spa.js +0 -13
  207. package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
  208. package/dist/app/entry/main.frontend.ssr.js +0 -79
  209. package/dist/app/entry/main.serverless.dev.d.ts +0 -4
  210. package/dist/app/entry/main.serverless.dev.js +0 -21
  211. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  212. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  213. package/dist/app/lib/hooks/apiConfig.js +0 -4
  214. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  215. package/dist/app/lib/hooks/usePageLoad.js +0 -5
  216. package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
  217. package/dist/app/server/create-api-builtin-hono.js +0 -80
  218. package/dist/app/server/create-ssr-hono.d.ts +0 -18
  219. package/dist/app/server/create-ssr-hono.js +0 -104
  220. package/dist/app/server/utils/index.html.d.ts +0 -2
  221. package/dist/app/server/utils/index.html.js +0 -14
  222. package/dist/node/compiler/index.html.d.ts +0 -2
  223. package/dist/node/compiler/index.html.js +0 -15
  224. package/dist/node/compiler/serverless.dev.js +0 -222
  225. package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
  226. package/dist/node/compiler/vite/get-vite-config.js +0 -315
  227. package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
  228. package/dist/node/compiler/vite/plugin-admin.js +0 -67
  229. package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
  230. package/dist/node/compiler/vite/plugin-blocks.js +0 -73
  231. package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
  232. package/dist/node/compiler/vite/plugin-entry.js +0 -16
  233. package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
  234. package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
  235. package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
  236. package/dist/node/compiler/vite/plugin-theme.js +0 -40
  237. package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
  238. package/dist/node/compiler/vite/plugin-views.js +0 -51
  239. package/dist/node/utils/console.d.ts +0 -21
  240. package/dist/node/utils/console.js +0 -28
  241. package/dist/node/utils/unsafe-fetch.d.ts +0 -2
  242. package/dist/node/utils/unsafe-fetch.js +0 -19
  243. package/dist/node/utils/watchFileTree.d.ts +0 -11
  244. package/tsup.config.ts +0 -40
  245. package/types.manifests.d.ts +0 -22
  246. /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
  247. /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
  248. /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
  249. /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
  250. /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
  251. /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
  252. /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
  253. /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
  254. /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
  255. /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
  256. /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
  257. /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
@@ -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,222 +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
- optimizeDeps: {
79
- include: ["valtio", "zustand", "qs", "react", "react-dom/client"],
80
- exclude: ["eddev"],
81
- },
82
- ssr: {
83
- noExternal: ["eddev"],
84
- },
85
- build: {
86
- ssr: true,
87
- sourcemap: true,
88
- watch: {
89
- clearScreen: true,
90
- },
91
- rollupOptions: {
92
- onwarn(warning, warn) {
93
- if (warning.code === "SOURCEMAP_ERROR") {
94
- return;
95
- }
96
- warn(warning);
97
- },
98
- },
99
- },
100
- appType: "custom",
101
- })));
102
- vite.watcher.on("change", (file) => {
103
- console.resetLog();
104
- });
105
- console.setWorking(false);
106
- const proxyTarget = "https://" + serverlessHost + ":" + serverlessPort + "/";
107
- const proxyDest = parsedSiteURL.protocol + "//" + parsedSiteURL.host + "/";
108
- console.info("Proxying WordPress from", proxyDest);
109
- const replaceTargetString = proxyDest.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\/");
110
- const replaceTargetEscapedString = proxyDest.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\\\/");
111
- const replaceTarget = new RegExp(replaceTargetString, "g");
112
- const replaceTargetEscaped = new RegExp(replaceTargetEscapedString, "g");
113
- const replaceHost = (value) => {
114
- return value.replace(replaceTarget, proxyTarget).replace(replaceTargetEscaped, proxyTarget.replaceAll("/", "\\/"));
115
- };
116
- const proxy = expressProxy(parsedSiteURL.protocol + "//" + parsedSiteURL.host, {
117
- proxyReqOptDecorator: function (proxyReqOpts, originalReq) {
118
- // @ts-ignore
119
- proxyReqOpts.rejectUnauthorized = false;
120
- // @ts-ignore
121
- proxyReqOpts.headers["X-ED-Dev-Proxy"] = "true";
122
- return proxyReqOpts;
123
- },
124
- userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) {
125
- for (let [key, value] of Object.entries(headers)) {
126
- if (typeof value === "string") {
127
- headers[key] = replaceHost(value);
128
- }
129
- else if (Array.isArray(value)) {
130
- headers[key] = value.map((v) => {
131
- return replaceHost(v);
132
- });
133
- }
134
- }
135
- return headers;
136
- },
137
- userResDecorator(proxyRes, proxyResData, userReq, userRes) {
138
- if (userReq.path.includes(".php") || !userReq.path.includes(".") || userReq.path.startsWith("/wp-json")) {
139
- proxyResData = replaceHost(proxyResData.toString("utf8"));
140
- }
141
- return proxyResData;
142
- },
143
- });
144
- app.use(async (req, res, next) => {
145
- if (!req.originalUrl.includes(".php") && !req.originalUrl.includes("/?")) {
146
- vite.middlewares.handle(req, res, next);
147
- }
148
- else {
149
- next();
150
- }
151
- });
152
- /**
153
- * Allow https access from self-signed certificates, when working locally during development
154
- */
155
- const httpsAgent = new HttpsAgent({
156
- rejectUnauthorized: false,
157
- });
158
- const httpAgent = new HttpAgent({});
159
- const fetchImpl = (...args) => {
160
- return fetch(args[0], {
161
- ...(args[1] ?? {}),
162
- agent: function (_parsedURL) {
163
- if (_parsedURL.protocol == "http:") {
164
- return httpAgent;
165
- }
166
- else {
167
- return httpsAgent;
168
- }
169
- },
170
- });
171
- };
172
- app.use(async (req, res, next) => {
173
- if (!req.path.startsWith("/api"))
174
- return next();
175
- const { getHonoAPI, patchConsole } = await vite.ssrLoadModule("/_ssr.js", {
176
- fixStacktrace: true,
177
- });
178
- patchConsole(console);
179
- const hono = getHonoAPI({
180
- fetchImpl,
181
- replaceUrls: {
182
- from: proxyDest,
183
- to: "/",
184
- },
185
- });
186
- const handler = getRequestListener(hono.fetch, {
187
- errorHandler: (err) => {
188
- console.error(err);
189
- },
190
- });
191
- await handler(req, res);
192
- });
193
- app.use(async (req, res, next) => {
194
- const url = req.originalUrl;
195
- if (url.includes(".") || url.startsWith("/wp-") || url.startsWith("/graphql"))
196
- return next();
197
- const { patchConsole, setFetchImpl, getHonoSSR, setIndexTransformer } = await vite.ssrLoadModule("/_ssr.js", {
198
- fixStacktrace: true,
199
- });
200
- patchConsole(console);
201
- const hono = getHonoSSR({
202
- fetchImpl,
203
- indexTransformer: async (index) => await vite.transformIndexHtml(url, indexHtml),
204
- replaceUrls: {
205
- from: proxyDest,
206
- to: "/",
207
- },
208
- });
209
- const handler = getRequestListener(hono.fetch, {
210
- errorHandler: (err) => {
211
- console.error(err);
212
- },
213
- });
214
- await handler(req, res);
215
- });
216
- app.use(proxy);
217
- console.setState({
218
- serverlessUrl: "https://" + serverlessHost + ":" + mainServer.address.port + "/",
219
- wordpressUrl: proxyDest,
220
- });
221
- }
222
- }
@@ -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;
@@ -1,315 +0,0 @@
1
- import * as t from "@babel/types";
2
- import replace from "@rollup/plugin-replace";
3
- import react from "@vitejs/plugin-react";
4
- import { pascalCase } from "change-case-all";
5
- import { join } from "path";
6
- import { withoutTrailingSlash } from "ufo";
7
- import { createLogger } from "vite";
8
- import tsconfigPaths from "vite-tsconfig-paths";
9
- import { cliMode } from "../../cli/cli-mode.js";
10
- import { pluginAdminManifest } from "./plugin-admin.js";
11
- import { pluginBlocks } from "./plugin-blocks.js";
12
- import { pluginEntryFile } from "./plugin-entry.js";
13
- import { pluginResolvedTailwind } from "./plugin-resolved-tailwind.js";
14
- import { pluginThemeManifest } from "./plugin-theme.js";
15
- import { pluginViews } from "./plugin-views.js";
16
- export function getViteConfig(args) {
17
- const console = args.console;
18
- const logger = createLogger();
19
- logger.info = (msg) => args.console.info(msg.replace(/\n/, ""));
20
- logger.warn = (msg) => {
21
- if (typeof msg === "string" && msg.includes("Error when using sourcemap for reporting"))
22
- return;
23
- return args.console.warn(msg.replace(/\n/, ""));
24
- };
25
- logger.error = (msg) => args.console.fail(msg.replace(/\n/, ""));
26
- logger.warnOnce = (msg) => args.console.warn(msg.replace(/\n/, ""));
27
- logger.clearScreen = () => {
28
- args.console.resetLog();
29
- };
30
- const envDefines = {
31
- client: args.serverless ? "!import.meta.env.SSR" : "true",
32
- serverless: args.serverless ? "true" : "false",
33
- dev: args.mode === "development" ? "true" : "false",
34
- admin: args.mode === "development" && args.serverless
35
- ? `(typeof __wp_admin !== "undefined")`
36
- : args.target === "cms"
37
- ? "true"
38
- : "false",
39
- themePath: JSON.stringify(args.project.publicUrl),
40
- devUI: args.mode === "development" ? "true" : "false",
41
- serverlessOrigin: JSON.stringify("http://serverleress-endpoint"),
42
- rpcEnabled: "false",
43
- origin: JSON.stringify(process.env.SITE_URL ?? "/"),
44
- };
45
- const expandDefines = (obj, prefixes = []) => {
46
- const result = {};
47
- for (const prefix of prefixes) {
48
- for (const [key, value] of Object.entries(obj)) {
49
- result[prefix + key] = value;
50
- }
51
- }
52
- return result;
53
- };
54
- /** Initial config */
55
- const config = {
56
- appType: "custom",
57
- mode: args.mode,
58
- root: args.rootDir,
59
- customLogger: logger,
60
- logLevel: cliMode.verbose ? "info" : "warn",
61
- base: withoutTrailingSlash(args.project.publicUrl) + "/dist/" + args.target,
62
- define: {
63
- "process.env.NODE_ENV": JSON.stringify(args.mode),
64
- // ssrLoadModule: "() => Promise.resolve({})",
65
- },
66
- // optimizeDeps: {
67
- // force: true,
68
- // holdUntilCrawlEnd: true,
69
- // include: ["zustand"],
70
- // noDiscovery: true,
71
- // exclude: ["react-external.js", "react-dom-external.js", "react", "react-dom"],
72
- // esbuildOptions: {},
73
- // },
74
- resolve: {
75
- alias: [
76
- { find: "@manifest/blocks", replacement: join(args.project.rootDir, "__block-manifest.js") },
77
- { find: "@manifest/views", replacement: join(args.project.rootDir, "__view-manifest.js") },
78
- { find: "@manifest/theme", replacement: join(args.project.rootDir, "__theme-manifest.js") },
79
- { find: "@manifest/admin", replacement: join(args.project.rootDir, "__admin-manifest.js") },
80
- { find: "@manifest/tailwind", replacement: join(args.project.rootDir, "__resolved-tailwind.js") },
81
- ],
82
- },
83
- legacy: {
84
- proxySsrExternalModules: true,
85
- },
86
- plugins: [
87
- tsconfigPaths(),
88
- // pluginShimReact(args),
89
- react({
90
- babel: {
91
- overrides: [{ test: /types\./, compact: true }],
92
- plugins: [
93
- {
94
- visitor: {
95
- // TODO: Move this to a separate file
96
- // TODO: Attach the title to the block component, so we can use it for debugging
97
- ExportNamedDeclaration: (path) => {
98
- const decl = path.node.declaration;
99
- if (decl?.type !== "VariableDeclaration")
100
- return;
101
- const id = decl.declarations[0].id;
102
- if (!t.isIdentifier(id))
103
- return;
104
- if (id.name === "meta") {
105
- path.remove();
106
- }
107
- },
108
- ExportDefaultDeclaration: (path) => {
109
- if (path.node.declaration.type === "CallExpression") {
110
- const call = path.node.declaration;
111
- if (call.callee.type === "Identifier" && ["defineBlock", "defineView"].includes(call.callee.name)) {
112
- const type = call.callee.name.replace("define", "");
113
- const args = call.arguments;
114
- if (args.length === 2 &&
115
- args[0].type === "StringLiteral" &&
116
- args[1].type === "ArrowFunctionExpression") {
117
- const name = args[0].value;
118
- let body = args[1].body;
119
- if (t.isExpression(body)) {
120
- body = t.blockStatement([t.returnStatement(body)]);
121
- }
122
- path.replaceWith(t.exportDefaultDeclaration(t.functionDeclaration(t.identifier(pascalCase(type + "-" + name)), args[1].params, body, args[1].generator, args[1].async)));
123
- }
124
- }
125
- }
126
- },
127
- },
128
- },
129
- ],
130
- },
131
- }),
132
- replace({
133
- values: expandDefines(envDefines, ["process.env.", "process.", "env."]),
134
- preventAssignment: true,
135
- }),
136
- // SPA Frontend, to be served by WordPress
137
- args.target === "frontend" &&
138
- !args.serverless &&
139
- pluginEntryFile({
140
- code: `
141
- import boot from 'eddev/_internal/_entry/main.frontend.spa.js'
142
- import "./views/index.css"
143
- boot()
144
- `,
145
- id: "eddev-bootup",
146
- path: "/_boot.js",
147
- }),
148
- // SPA Admin bundle, to be served by WordPress admin
149
- args.target === "cms" &&
150
- !args.serverless &&
151
- pluginEntryFile({
152
- code: `
153
- import boot from 'eddev/_internal/_entry/main.admin.js'
154
- import "./views/index.css"
155
- boot()
156
- `,
157
- id: "eddev-bootup",
158
- path: "/_boot.js",
159
- }),
160
- // Frontend + Admin, used during development
161
- args.serverless &&
162
- pluginEntryFile({
163
- code: `
164
- import boot from 'eddev/_internal/_entry/main.serverless.dev.js'
165
- import "./views/index.css"
166
- boot()
167
- `,
168
- id: "eddev-bootup",
169
- path: "/_boot.js",
170
- }),
171
- args.serverless &&
172
- pluginEntryFile({
173
- code: `
174
- import React from 'react'
175
- import ReactDOM from 'react-dom/client'
176
- Object.assign(React, window.React)
177
- Object.assign(ReactDOM, window.ReactDOM)
178
- `,
179
- id: "eddev-test-shim",
180
- path: "/_boot_test_shim.js",
181
- }),
182
- // Frontend + Admin, used during development
183
- args.serverless &&
184
- pluginEntryFile({
185
- code: `
186
- import '/_boot_test_shim.js'
187
- import boot from 'eddev/_internal/_entry/main.serverless.dev.js'
188
- import "./views/index.css"
189
- boot()
190
- `,
191
- id: "eddev-bootup-serverless-admin",
192
- path: "/_boot_admin.js",
193
- }),
194
- // SSR Bundle, used for rendering on the server
195
- args.serverless &&
196
- pluginEntryFile({
197
- code: `
198
- export * from 'eddev/_internal/_entry/main.frontend.ssr.js'
199
- import "./views/index.css"
200
- `,
201
- id: "eddev-ssr",
202
- path: "/_ssr.js",
203
- }),
204
- // args.serverless && {
205
- // name: "eddev:serverless",
206
- // (chunk) {
207
- // console.log("Chunk", chunk)
208
- // return ""
209
- // },
210
- // },
211
- pluginResolvedTailwind(args.project, args.console, args.serverless),
212
- pluginBlocks(args.project, args.console, args.serverless),
213
- pluginViews(args.project, args.console, args.serverless),
214
- pluginThemeManifest(args.project, args.console),
215
- pluginAdminManifest(args.project, args.console),
216
- !args.serverless && buildStatus(console),
217
- // args.serverless
218
- // ? pluginEntryFile({
219
- // code: indexHtml,
220
- // id: "index.html",
221
- // path: join(args.rootDir, "index.html"),
222
- // })
223
- // : null,
224
- ],
225
- build: args.target === "cms"
226
- ? {
227
- manifest: true,
228
- sourcemap: true,
229
- modulePreload: false,
230
- minify: args.mode === "production",
231
- outDir: args.outDir,
232
- watch: {},
233
- rollupOptions: {
234
- input: "/_boot.js",
235
- external: ["react", "react-dom"],
236
- onwarn(warning, warn) {
237
- if (warning.code === "SOURCEMAP_ERROR") {
238
- return;
239
- }
240
- warn(warning);
241
- },
242
- output: {
243
- entryFileNames: "main.admin.js",
244
- format: "iife",
245
- globals: {
246
- react: "window.React",
247
- "react-dom": "window.ReactDOM",
248
- },
249
- },
250
- },
251
- }
252
- : args.serverless
253
- ? {
254
- rollupOptions: {
255
- input: "/_boot.js",
256
- external: ["react", "react-dom"],
257
- onwarn(warning, warn) {
258
- if (warning.code === "SOURCEMAP_ERROR") {
259
- return;
260
- }
261
- warn(warning);
262
- },
263
- output: args.mode === "production"
264
- ? {
265
- entryFileNames: "main.admin.js",
266
- format: "iife",
267
- globals: {
268
- react: "window.React",
269
- "react-dom": "window.ReactDOM",
270
- },
271
- }
272
- : undefined,
273
- },
274
- }
275
- : {
276
- manifest: true,
277
- sourcemap: true,
278
- minify: args.mode === "production",
279
- modulePreload: false,
280
- outDir: args.outDir,
281
- watch: {},
282
- rollupOptions: {
283
- input: "/_boot.js",
284
- onwarn(warning, warn) {
285
- if (warning.code === "SOURCEMAP_ERROR") {
286
- return;
287
- }
288
- warn(warning);
289
- },
290
- },
291
- },
292
- };
293
- return config;
294
- }
295
- function buildStatus(console) {
296
- let timer = 0;
297
- return {
298
- name: "eddev:logging",
299
- enforce: "post",
300
- watchChange() {
301
- console.resetLog();
302
- clearTimeout(timer);
303
- },
304
- buildStart() {
305
- clearTimeout(timer);
306
- console.setWorking(true);
307
- },
308
- buildEnd() {
309
- clearTimeout(timer);
310
- timer = setTimeout(() => {
311
- console.setWorking(false);
312
- }, 0);
313
- },
314
- };
315
- }
@@ -1,4 +0,0 @@
1
- import { Plugin } from "vite";
2
- import { Project } from "../../project/project.js";
3
- import { StatefulLog } from "../../utils/statefulLog.js";
4
- export declare function pluginAdminManifest(project: Project, console: StatefulLog<any>): Plugin;
@@ -1,67 +0,0 @@
1
- import { join } from "path";
2
- export function pluginAdminManifest(project, console) {
3
- const virtualId = "\0virtual:admin-manifest.js";
4
- let server = null;
5
- const fakePath = join(project.rootDir, "__admin-manifest.js");
6
- let lastHash = "";
7
- project.views.subscribeFuture(async (manifest) => {
8
- if (server) {
9
- const hash = Object.keys(manifest.views).join("");
10
- const virtualModule = server.moduleGraph.getModuleById(virtualId);
11
- if (virtualModule && hash !== lastHash && lastHash !== "") {
12
- server.moduleGraph.invalidateModule(virtualModule);
13
- }
14
- lastHash = hash;
15
- }
16
- });
17
- return {
18
- name: "eddev:adminManifest",
19
- resolveId(id) {
20
- if (id === fakePath) {
21
- return virtualId;
22
- }
23
- },
24
- async load(id) {
25
- if (id === virtualId) {
26
- const fieldManifest = await project.fields.get();
27
- const widgetManifest = await project.widgets.get();
28
- return `
29
- import { adminManifestReader } from 'eddev/_internal'
30
- import editorConfig from './blocks/_editor'
31
-
32
- const fields = {${Object.entries(fieldManifest.fields)
33
- .map(([name, field]) => {
34
- const importStatement = `() => import(${JSON.stringify("./" + field.fileName)}).then(m => m.default)`;
35
- return JSON.stringify(field.slug) + ": " + importStatement;
36
- })
37
- .join(",\n")}}
38
- const widgets = {${Object.entries(widgetManifest.widgets)
39
- .map(([name, widget]) => {
40
- const importStatement = `() => import(${JSON.stringify("./" + widget.fileName)}).then(m => m.default)`;
41
- return JSON.stringify(widget.slug) + ": " + importStatement;
42
- })
43
- .join(",\n")}}
44
-
45
- const manifest = {
46
- fields,
47
- widgets,
48
- editorConfig
49
- }
50
-
51
- adminManifestReader.set(manifest)
52
-
53
- export default manifest
54
-
55
- export { editorConfig }
56
-
57
- if (import.meta.hot) {
58
- import.meta.hot.accept()
59
- }
60
- `;
61
- }
62
- },
63
- configureServer(_server) {
64
- server = _server;
65
- },
66
- };
67
- }
@@ -1,4 +0,0 @@
1
- import { Plugin } from "vite";
2
- import { Project } from "../../project/project.js";
3
- import { StatefulLog } from "../../utils/statefulLog.js";
4
- export declare function pluginBlocks(project: Project, console: StatefulLog<any>, ssr: boolean): Plugin;