eddev 2.0.0-beta.1 → 2.0.0-beta.100

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 (277) hide show
  1. package/dist/app/entry/HydrationOverlay.d.ts +1 -0
  2. package/dist/app/entry/HydrationOverlay.js +2 -0
  3. package/dist/app/entry/MetaTags.d.ts +7 -0
  4. package/dist/app/entry/MetaTags.js +17 -0
  5. package/dist/app/entry/boot-admin.d.ts +1 -0
  6. package/dist/app/entry/boot-admin.js +13 -0
  7. package/dist/app/entry/hydration-script.d.ts +1 -0
  8. package/dist/app/entry/hydration-script.js +18 -0
  9. package/dist/app/entry/spa-root.d.ts +1 -0
  10. package/dist/app/entry/spa-root.js +8 -0
  11. package/dist/app/entry/ssr-root-client.d.ts +6 -0
  12. package/dist/app/entry/ssr-root-client.js +20 -0
  13. package/dist/app/entry/ssr-root.d.ts +8 -0
  14. package/dist/app/entry/ssr-root.js +22 -0
  15. package/dist/app/lib/admin/index.d.ts +2 -2
  16. package/dist/app/lib/admin/index.js +2 -2
  17. package/dist/app/lib/admin/installFieldTypes.js +1 -1
  18. package/dist/app/lib/admin/runWidgets.js +1 -1
  19. package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
  20. package/dist/app/lib/blocks/ContentBlocks.js +5 -5
  21. package/dist/app/lib/blocks/EditableText.d.ts +1 -1
  22. package/dist/app/lib/blocks/EditableText.js +3 -3
  23. package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
  24. package/dist/app/lib/blocks/InnerBlocks.js +13 -5
  25. package/dist/app/lib/blocks/block-utils.d.ts +2 -2
  26. package/dist/app/lib/blocks/block-utils.js +2 -2
  27. package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +7 -0
  28. package/dist/app/lib/blocks/editor/EditorHighlights.js +130 -0
  29. package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
  30. package/dist/app/lib/blocks/editor/editor-config.d.ts +17 -4
  31. package/dist/app/lib/blocks/editor/editor-config.js +21 -9
  32. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +20 -14
  33. package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
  34. package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
  35. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  36. package/dist/app/lib/blocks/index.d.ts +9 -9
  37. package/dist/app/lib/blocks/index.js +9 -9
  38. package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
  39. package/dist/app/lib/blocks/inline-editing.js +7 -5
  40. package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
  41. package/dist/app/lib/devtools/components/DevUI.js +4 -3
  42. package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
  43. package/dist/app/lib/devtools/components/GridIndicator.js +29 -0
  44. package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
  45. package/dist/app/lib/devtools/dev-tools-store.js +8 -0
  46. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
  47. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  48. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1102 -1103
  49. package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
  50. package/dist/app/lib/devtools/index.d.ts +1 -0
  51. package/dist/app/lib/devtools/index.js +1 -1
  52. package/dist/app/lib/devtools/loader.js +8 -7
  53. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  54. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  55. package/dist/app/lib/dynamic/dynamic.d.ts +1 -1
  56. package/dist/app/lib/dynamic/dynamic.js +5 -1
  57. package/dist/app/lib/dynamic/index.d.ts +1 -1
  58. package/dist/app/lib/dynamic/index.js +1 -1
  59. package/dist/app/lib/hooks/index.d.ts +4 -5
  60. package/dist/app/lib/hooks/index.js +4 -5
  61. package/dist/app/lib/hooks/queryUtils.d.ts +41 -4
  62. package/dist/app/lib/hooks/queryUtils.js +74 -37
  63. package/dist/app/lib/hooks/useAppData.js +1 -1
  64. package/dist/app/lib/hooks/useRPC.d.ts +0 -4
  65. package/dist/app/lib/hooks/useRPC.js +1 -8
  66. package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
  67. package/dist/app/lib/internal/finalize-rpc.js +3 -0
  68. package/dist/app/lib/internal/index.d.ts +5 -4
  69. package/dist/app/lib/internal/index.js +5 -4
  70. package/dist/app/lib/internal/internal-store.d.ts +0 -2
  71. package/dist/app/lib/internal/internal-store.js +1 -3
  72. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  73. package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
  74. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  75. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  76. package/dist/app/lib/legacy-stitches/index.js +1 -1
  77. package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
  78. package/dist/app/lib/routing/components/BackButton.js +47 -0
  79. package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
  80. package/dist/app/lib/routing/components/BrowserRouter.js +95 -19
  81. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  82. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  83. package/dist/app/lib/routing/components/Link.js +11 -12
  84. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  85. package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
  86. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  87. package/dist/app/lib/routing/components/SSRRouter.js +5 -6
  88. package/dist/app/lib/routing/components/ScrollRestoration.js +5 -2
  89. package/dist/app/lib/routing/context.d.ts +8 -5
  90. package/dist/app/lib/routing/context.js +13 -96
  91. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
  92. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  93. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
  94. package/dist/app/lib/routing/hooks/useRoute.js +22 -1
  95. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
  96. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  97. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  98. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  99. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  100. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  101. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  102. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  103. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  104. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  105. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  106. package/dist/app/lib/routing/index.d.ts +14 -13
  107. package/dist/app/lib/routing/index.js +14 -13
  108. package/dist/app/lib/routing/loader.d.ts +2 -2
  109. package/dist/app/lib/routing/loader.js +26 -15
  110. package/dist/app/lib/routing/types.d.ts +36 -10
  111. package/dist/app/lib/routing/utils.d.ts +5 -2
  112. package/dist/app/lib/routing/utils.js +37 -4
  113. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
  114. package/dist/app/lib/runtime/apiConfig.js +6 -0
  115. package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
  116. package/dist/app/lib/runtime/errorHandling.js +6 -0
  117. package/dist/app/lib/runtime/index.d.ts +2 -0
  118. package/dist/app/lib/runtime/index.js +2 -0
  119. package/dist/app/lib/views/index.d.ts +1 -1
  120. package/dist/app/lib/views/index.js +1 -1
  121. package/dist/app/server/defineRouter.d.ts +2 -0
  122. package/dist/app/server/defineRouter.js +4 -0
  123. package/dist/app/server/index.d.ts +5 -0
  124. package/dist/app/server/index.js +5 -0
  125. package/dist/app/server/proxy-wp-admin.d.ts +2 -0
  126. package/dist/app/server/proxy-wp-admin.js +124 -0
  127. package/dist/app/server/render-ssr-page.d.ts +21 -0
  128. package/dist/app/server/render-ssr-page.js +166 -0
  129. package/dist/app/server/rpc.d.ts +56 -0
  130. package/dist/app/server/rpc.js +18 -0
  131. package/dist/app/server/server-context.d.ts +72 -0
  132. package/dist/app/server/server-context.js +283 -0
  133. package/dist/app/server/utils/headers.d.ts +1 -0
  134. package/dist/app/server/utils/headers.js +17 -0
  135. package/dist/app/server/utils/replace-host.d.ts +6 -4
  136. package/dist/app/server/utils/replace-host.js +66 -11
  137. package/dist/app/server/utils/swr-cache.d.ts +4 -0
  138. package/dist/app/server/utils/swr-cache.js +31 -0
  139. package/dist/app/utils/APIProvider.d.ts +2 -0
  140. package/dist/app/utils/APIProvider.js +5 -0
  141. package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
  142. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  143. package/dist/app/utils/ErrorMessage.d.ts +5 -0
  144. package/dist/app/utils/ErrorMessage.js +14 -0
  145. package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
  146. package/dist/app/utils/RouteErrorBoundary.js +38 -0
  147. package/dist/app/utils/asset-capture.d.ts +2 -0
  148. package/dist/app/utils/asset-capture.js +5 -0
  149. package/dist/app/utils/hydration-debugger.d.ts +13 -0
  150. package/dist/app/utils/hydration-debugger.js +11 -0
  151. package/dist/app/utils/query-client.d.ts +2 -0
  152. package/dist/app/utils/query-client.js +5 -1
  153. package/dist/app/utils/trpc-client.d.ts +2 -0
  154. package/dist/app/utils/trpc-client.js +39 -0
  155. package/dist/node/cli/cli-worker.d.ts +1 -1
  156. package/dist/node/cli/cli-worker.js +11 -3
  157. package/dist/node/cli/cli.js +112 -13
  158. package/dist/node/cli/display/CLIApp.d.ts +1 -1
  159. package/dist/node/cli/display/CLIApp.js +4 -7
  160. package/dist/node/cli/display/boot-cli-app.js +1 -1
  161. package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
  162. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
  163. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
  164. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
  165. package/dist/node/cli/display/tools/cli-tools.js +9 -9
  166. package/dist/node/cli/display/util/colors.d.ts +2 -2
  167. package/dist/node/cli/version.d.ts +1 -1
  168. package/dist/node/cli/version.js +1 -1
  169. package/dist/node/compiler/build-vinxi.d.ts +8 -0
  170. package/dist/node/compiler/build-vinxi.js +38 -0
  171. package/dist/node/compiler/bundler.admin.d.ts +2 -2
  172. package/dist/node/compiler/bundler.admin.js +4 -4
  173. package/dist/node/compiler/bundler.frontend.d.ts +1 -1
  174. package/dist/node/compiler/bundler.frontend.js +4 -4
  175. package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
  176. package/dist/node/compiler/dev-server.js +107 -0
  177. package/dist/node/compiler/get-vite-config.d.ts +20 -0
  178. package/dist/node/compiler/get-vite-config.js +207 -0
  179. package/dist/node/compiler/vinxi-app.d.ts +22 -0
  180. package/dist/node/compiler/vinxi-app.js +228 -0
  181. package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
  182. package/dist/node/compiler/vinxi-codegen.js +638 -0
  183. package/dist/node/graphql/graphql-codegen.d.ts +12 -2
  184. package/dist/node/graphql/graphql-codegen.js +213 -36
  185. package/dist/node/graphql/graphql-schema-loader.d.ts +2 -1
  186. package/dist/node/graphql/graphql-schema-loader.js +5 -19
  187. package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
  188. package/dist/node/graphql/query-files-loader.d.ts +3 -0
  189. package/dist/node/graphql/query-files-loader.js +5 -0
  190. package/dist/node/project/config.d.ts +159 -73
  191. package/dist/node/project/config.js +70 -21
  192. package/dist/node/project/env.d.ts +5 -1
  193. package/dist/node/project/env.js +2 -1
  194. package/dist/node/project/manifest/block-manifest.js +3 -2
  195. package/dist/node/project/manifest/manifest.d.ts +2 -1
  196. package/dist/node/project/manifest/manifest.js +15 -11
  197. package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
  198. package/dist/node/project/manifest/routes-manifest.js +74 -0
  199. package/dist/node/project/manifest/view-manifest.js +2 -2
  200. package/dist/node/project/project.d.ts +11 -2
  201. package/dist/node/project/project.js +49 -20
  202. package/dist/node/project/wp-info.d.ts +1 -0
  203. package/dist/node/project/wp-info.js +13 -3
  204. package/dist/node/types/block-type.d.ts +25 -20
  205. package/dist/node/types/block-type.js +1 -0
  206. package/dist/node/types/view-type.d.ts +7 -7
  207. package/dist/node/types/view-type.js +3 -4
  208. package/dist/node/utils/fetch-wp.d.ts +1 -0
  209. package/dist/node/utils/fetch-wp.js +27 -0
  210. package/dist/node/utils/fs-codegen.d.ts +42 -0
  211. package/dist/node/utils/fs-codegen.js +98 -0
  212. package/dist/node/utils/fs.js +2 -0
  213. package/dist/node/utils/{isDeploying.js → is-deploying.js} +1 -1
  214. package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
  215. package/dist/node/utils/{statefulLog.js → stateful-log.js} +3 -1
  216. package/dist/node/utils/watch-file-tree.d.ts +25 -0
  217. package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +12 -5
  218. package/package.json +40 -38
  219. package/types.app.d.ts +4 -2
  220. package/types.app.internal.d.ts +2 -2
  221. package/types.node.d.ts +3 -3
  222. package/dist/app/entry/Root.d.ts +0 -1
  223. package/dist/app/entry/Root.js +0 -9
  224. package/dist/app/entry/main.admin.d.ts +0 -3
  225. package/dist/app/entry/main.admin.js +0 -10
  226. package/dist/app/entry/main.frontend.spa.d.ts +0 -3
  227. package/dist/app/entry/main.frontend.spa.js +0 -13
  228. package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
  229. package/dist/app/entry/main.frontend.ssr.js +0 -79
  230. package/dist/app/entry/main.serverless.dev.d.ts +0 -4
  231. package/dist/app/entry/main.serverless.dev.js +0 -21
  232. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  233. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  234. package/dist/app/lib/hooks/apiConfig.js +0 -4
  235. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  236. package/dist/app/lib/hooks/usePageLoad.js +0 -5
  237. package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
  238. package/dist/app/server/create-api-builtin-hono.js +0 -80
  239. package/dist/app/server/create-ssr-hono.d.ts +0 -18
  240. package/dist/app/server/create-ssr-hono.js +0 -104
  241. package/dist/app/server/utils/index.html.d.ts +0 -2
  242. package/dist/app/server/utils/index.html.js +0 -14
  243. package/dist/node/compiler/index.html.d.ts +0 -2
  244. package/dist/node/compiler/index.html.js +0 -15
  245. package/dist/node/compiler/serverless.dev.js +0 -215
  246. package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
  247. package/dist/node/compiler/vite/get-vite-config.js +0 -315
  248. package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
  249. package/dist/node/compiler/vite/plugin-admin.js +0 -67
  250. package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
  251. package/dist/node/compiler/vite/plugin-blocks.js +0 -73
  252. package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
  253. package/dist/node/compiler/vite/plugin-entry.js +0 -16
  254. package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
  255. package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
  256. package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
  257. package/dist/node/compiler/vite/plugin-theme.js +0 -40
  258. package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
  259. package/dist/node/compiler/vite/plugin-views.js +0 -51
  260. package/dist/node/utils/console.d.ts +0 -21
  261. package/dist/node/utils/console.js +0 -28
  262. package/dist/node/utils/unsafe-fetch.d.ts +0 -2
  263. package/dist/node/utils/unsafe-fetch.js +0 -19
  264. package/dist/node/utils/watchFileTree.d.ts +0 -11
  265. package/tsup.config.ts +0 -40
  266. package/types.manifests.d.ts +0 -22
  267. /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
  268. /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
  269. /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
  270. /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
  271. /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
  272. /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
  273. /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
  274. /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
  275. /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
  276. /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
  277. /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
@@ -0,0 +1,107 @@
1
+ import { parseURL } from "ufo";
2
+ import { createDevServer } from "vinxi/dev-server";
3
+ import { ProjectEnvUtils } from "../project/env.js";
4
+ import { ensureSelfSignedCert } from "../utils/self-signed-cert.js";
5
+ import { createConsole } from "../utils/stateful-log.js";
6
+ import { createVinxiApp } from "./vinxi-app.js";
7
+ import { createVinxiCodegen } from "./vinxi-codegen.js";
8
+ const console = createConsole("Dev Server", "dev");
9
+ export const serverlessLog = console;
10
+ export class DevServer {
11
+ project;
12
+ opts;
13
+ origin;
14
+ hostname;
15
+ hostOrigin;
16
+ port = 8080;
17
+ constructor(project, opts) {
18
+ this.project = project;
19
+ this.opts = opts;
20
+ this.start();
21
+ this.origin = ProjectEnvUtils.get("SITE_URL");
22
+ const parsedSiteURL = parseURL(this.origin);
23
+ this.hostname = parsedSiteURL.host?.endsWith(".local") ? parsedSiteURL.host : "localhost";
24
+ this.hostOrigin = "https://" + this.hostname + ":" + this.port;
25
+ }
26
+ async start() {
27
+ console.setWorking(true);
28
+ // console.log("Setting up vinxi codegen")
29
+ const codegen = createVinxiCodegen({
30
+ mode: "development",
31
+ project: this.project,
32
+ serverless: true,
33
+ });
34
+ await codegen.runAndWatch();
35
+ // console.log("Has run once")
36
+ const app = createVinxiApp({
37
+ mode: "development",
38
+ origin: this.origin,
39
+ publicUrl: this.project.publicUrl,
40
+ rootDir: this.project.rootDir,
41
+ log: console,
42
+ rpcBases: (await this.project.serverRoutes.get()).bases,
43
+ config: this.project.config,
44
+ });
45
+ const preset = process.env.TARGET ??
46
+ process.env.PRESET ??
47
+ process.env.SERVER_PRESET ??
48
+ process.env.SERVER_TARGET ??
49
+ process.env.NITRO_PRESET ??
50
+ process.env.NITRO_TARGET ??
51
+ (process.versions.bun !== undefined ? "bun" : "node-server");
52
+ // console.log("Ensuring self signed cert")
53
+ const keys = await ensureSelfSignedCert(this.hostname, this.project.rootDir);
54
+ // console.log("Done")
55
+ const httpsConfig = {
56
+ cert: keys.certFile,
57
+ key: keys.keyFile,
58
+ domains: [this.hostname, "localhost"],
59
+ };
60
+ let devApp = null;
61
+ app.hooks.addHooks({
62
+ "app:dev:start": async ({ app, serveConfig }) => {
63
+ serveConfig.https = httpsConfig;
64
+ serveConfig.hostname = this.hostname;
65
+ },
66
+ "app:dev:server:created": async (args) => {
67
+ devApp = args.devApp;
68
+ },
69
+ });
70
+ // console.log("Creating dev server")
71
+ await createDevServer(app, {
72
+ force: false,
73
+ devtools: false,
74
+ // @ts-ignore
75
+ hostname: this.hostname,
76
+ port: this.port,
77
+ // @ts-ignore
78
+ preset: preset,
79
+ https: httpsConfig,
80
+ });
81
+ // console.log("Rnning listen hook")
82
+ // @ts-ignore
83
+ await app.hooks.callHook("app:dev:server:listener:creating", {
84
+ app,
85
+ devApp,
86
+ });
87
+ // console.log("Creating another listener")
88
+ const listener = await devApp.listen(this.port, {
89
+ hostname: this.hostname,
90
+ port: this.port,
91
+ https: httpsConfig,
92
+ qr: false,
93
+ showURL: false,
94
+ });
95
+ await app.hooks.callHook("app:dev:server:listener:created", {
96
+ app,
97
+ devApp,
98
+ listener,
99
+ });
100
+ // console.log("Listening")
101
+ console.setWorking(false);
102
+ console.setState({
103
+ serverlessUrl: this.hostOrigin,
104
+ wordpressUrl: this.origin,
105
+ });
106
+ }
107
+ }
@@ -0,0 +1,20 @@
1
+ import { InlineConfig, PluginOption } from "vite";
2
+ import { StatefulLog } from "../utils/stateful-log.js";
3
+ export type Args = {
4
+ mode: "development" | "production";
5
+ serverless: boolean;
6
+ target: "frontend" | "cms";
7
+ rootDir: string;
8
+ outDir?: string;
9
+ publicUrl: string;
10
+ console: StatefulLog<any>;
11
+ client: boolean;
12
+ };
13
+ export declare function envPlugin(args: Args): PluginOption;
14
+ export declare function reactPlugin(): PluginOption[];
15
+ /**
16
+ * Turns on SSR module proxying,
17
+ */
18
+ export declare function ssrPlugin(): PluginOption;
19
+ export declare function corePlugins(args: Args): PluginOption[];
20
+ export declare function getViteConfig(args: Args): InlineConfig;
@@ -0,0 +1,207 @@
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 { withoutTrailingSlash } from "ufo";
6
+ import { createLogger } from "vite";
7
+ import tsconfigPaths from "vite-tsconfig-paths";
8
+ import { cliMode } from "../cli/cli-mode.js";
9
+ export function envPlugin(args) {
10
+ const envDefines = {
11
+ client: args.client ? "true" : "false",
12
+ serverless: args.serverless ? "true" : "false",
13
+ dev: args.mode === "development" ? "true" : "false",
14
+ admin: args.target === "cms" ? "true" : "false",
15
+ themePath: JSON.stringify(args.publicUrl),
16
+ devUI: args.mode === "development" ? "true" : "false",
17
+ serverlessOrigin: JSON.stringify("http://serverleress-endpoint"),
18
+ rpcEnabled: "true",
19
+ origin: JSON.stringify(process.env.SITE_URL ?? "/"),
20
+ };
21
+ const expandDefines = (obj, prefixes = []) => {
22
+ const result = {};
23
+ for (const prefix of prefixes) {
24
+ for (const [key, value] of Object.entries(obj)) {
25
+ result[prefix + key] = value;
26
+ }
27
+ }
28
+ return result;
29
+ };
30
+ return replace({
31
+ values: {
32
+ ...expandDefines(envDefines, ["process.env.", "process.", "env."]),
33
+ },
34
+ preventAssignment: true,
35
+ });
36
+ }
37
+ export function reactPlugin() {
38
+ return react({
39
+ babel: {
40
+ overrides: [{ test: /types\./, compact: true }],
41
+ plugins: [
42
+ {
43
+ visitor: {
44
+ ExportNamedDeclaration: (path) => {
45
+ const decl = path.node.declaration;
46
+ if (decl?.type !== "VariableDeclaration")
47
+ return;
48
+ const id = decl.declarations[0].id;
49
+ if (!t.isIdentifier(id))
50
+ return;
51
+ if (id.name === "meta") {
52
+ path.remove();
53
+ }
54
+ },
55
+ ExportDefaultDeclaration: (path) => {
56
+ if (!path.hub.file.opts.filename.match(/\/(blocks|views)\//))
57
+ return;
58
+ if (path.node.declaration.type === "CallExpression") {
59
+ const call = path.node.declaration;
60
+ if (call.callee.type === "Identifier" && ["defineBlock", "defineView"].includes(call.callee.name)) {
61
+ const type = call.callee.name.replace("define", "");
62
+ const args = call.arguments;
63
+ if (args.length === 2 &&
64
+ args[0].type === "StringLiteral" &&
65
+ args[1].type === "ArrowFunctionExpression") {
66
+ const name = args[0].value;
67
+ let body = args[1].body;
68
+ if (t.isExpression(body)) {
69
+ body = t.blockStatement([t.returnStatement(body)]);
70
+ }
71
+ path.replaceWith(t.exportDefaultDeclaration(t.functionDeclaration(t.identifier(pascalCase(type + "-" + name)), args[1].params, body, args[1].generator, args[1].async)));
72
+ }
73
+ }
74
+ }
75
+ },
76
+ },
77
+ },
78
+ ],
79
+ },
80
+ });
81
+ }
82
+ /**
83
+ * Turns on SSR module proxying,
84
+ */
85
+ export function ssrPlugin() {
86
+ return {
87
+ name: "proxy-external-ssr-modules",
88
+ config(config) {
89
+ config.legacy = {
90
+ ...config.legacy,
91
+ proxySsrExternalModules: true,
92
+ };
93
+ config.ssr = {
94
+ ...config.ssr,
95
+ noExternal: [
96
+ "eddev",
97
+ "vinxi",
98
+ "react-use",
99
+ // @ts-ignore
100
+ ...(config?.optimizeDeps?.noExternal ?? []),
101
+ ],
102
+ optimizeDeps: {
103
+ exclude: ["eddev", "vinxi"],
104
+ },
105
+ };
106
+ config.optimizeDeps = {
107
+ ...config.optimizeDeps,
108
+ include: [
109
+ "valtio",
110
+ "@tanstack/react-query",
111
+ "qs",
112
+ "react",
113
+ "react-dom/client",
114
+ ...(config?.optimizeDeps?.include ?? []),
115
+ ],
116
+ exclude: ["eddev", "vinxi", ...(config?.optimizeDeps?.exclude ?? [])],
117
+ };
118
+ return config;
119
+ },
120
+ };
121
+ }
122
+ function buildStatusPlugin(console) {
123
+ let timer = 0;
124
+ return {
125
+ name: "eddev:logging",
126
+ enforce: "post",
127
+ watchChange() {
128
+ console.resetLog();
129
+ clearTimeout(timer);
130
+ },
131
+ buildStart() {
132
+ clearTimeout(timer);
133
+ console.setWorking(true);
134
+ },
135
+ buildEnd() {
136
+ clearTimeout(timer);
137
+ timer = setTimeout(() => {
138
+ console.setWorking(false);
139
+ }, 0);
140
+ },
141
+ };
142
+ }
143
+ export function corePlugins(args) {
144
+ return [args.serverless && ssrPlugin(), envPlugin(args), tsconfigPaths(), reactPlugin()].flat();
145
+ }
146
+ export function getViteConfig(args) {
147
+ const console = args.console;
148
+ const logger = createLogger();
149
+ logger.info = (msg) => args.console.info(msg.replace(/\n/, ""));
150
+ logger.warn = (msg) => {
151
+ if (typeof msg === "string" && msg.includes("Error when using sourcemap for reporting"))
152
+ return;
153
+ return args.console.warn(msg.replace(/\n/, ""));
154
+ };
155
+ logger.error = (msg) => args.console.fail(msg.replace(/\n/, ""));
156
+ logger.warnOnce = (msg) => args.console.warn(msg.replace(/\n/, ""));
157
+ logger.clearScreen = () => {
158
+ args.console.resetLog();
159
+ };
160
+ /** Initial config */
161
+ const config = {
162
+ appType: "custom",
163
+ mode: args.mode,
164
+ root: args.rootDir,
165
+ customLogger: logger,
166
+ logLevel: cliMode.verbose ? "info" : "warn",
167
+ base: withoutTrailingSlash(args.publicUrl) + "/dist/" + args.target,
168
+ define: {
169
+ "process.env.NODE_ENV": JSON.stringify(args.mode),
170
+ },
171
+ plugins: [tsconfigPaths(), envPlugin(args), reactPlugin(), buildStatusPlugin(console)],
172
+ build: {
173
+ manifest: true,
174
+ sourcemap: true,
175
+ minify: args.mode === "production",
176
+ modulePreload: false,
177
+ outDir: args.outDir,
178
+ // watch: {},
179
+ rollupOptions: {
180
+ input: `./.eddev/${args.mode === "production" ? "prod" : "dev"}-spa/entry.${args.target === "cms" ? "admin" : "client"}.tsx`,
181
+ external: args.target === "cms" ? ["react", "react-dom"] : [],
182
+ onwarn(warning, warn) {
183
+ if (!cliMode.verbose &&
184
+ warning.code &&
185
+ ["SOURCEMAP_ERROR", "UNUSED_EXTERNAL_IMPORT", "INVALID_ANNOTATION", "EVAL"].includes(warning.code)) {
186
+ return;
187
+ }
188
+ if (warning.code) {
189
+ warning.message = warning.code + ": " + warning.message;
190
+ }
191
+ warn(warning);
192
+ },
193
+ output: args.target === "cms"
194
+ ? {
195
+ entryFileNames: "main.admin.js",
196
+ format: "iife",
197
+ globals: {
198
+ react: "window.React",
199
+ "react-dom": "window.ReactDOM",
200
+ },
201
+ }
202
+ : undefined,
203
+ },
204
+ },
205
+ };
206
+ return config;
207
+ }
@@ -0,0 +1,22 @@
1
+ import { StatefulLog } from "../utils/stateful-log.js";
2
+ import { EDConfig } from "../project/config.js";
3
+ export type AppArgs = {
4
+ mode: "development" | "production";
5
+ publicUrl: string;
6
+ rootDir: string;
7
+ origin: string;
8
+ log?: StatefulLog<any>;
9
+ preset?: string;
10
+ routes?: CustomRoute[];
11
+ rpcBases?: string[];
12
+ config: EDConfig;
13
+ };
14
+ type HTTPMethod = "GET" | "POST" | "PUT" | "OPTIONS" | "HEAD";
15
+ type CustomRouteFunction = (req: Request) => Response;
16
+ type CustomRouteModule = Record<HTTPMethod, CustomRouteFunction>;
17
+ type CustomRoute = {
18
+ pattern: string;
19
+ handler: () => Promise<CustomRouteModule>;
20
+ };
21
+ export declare function createVinxiApp(args: AppArgs): import("vinxi").App;
22
+ export {};
@@ -0,0 +1,228 @@
1
+ import { joinURL } from "ufo";
2
+ import { createApp } from "vinxi";
3
+ import tsconfigPaths from "vite-tsconfig-paths";
4
+ import { StatefulLog } from "../utils/stateful-log.js";
5
+ import { corePlugins, envPlugin } from "./get-vite-config.js";
6
+ import { getVinxiFolder } from "./vinxi-codegen.js";
7
+ export function createVinxiApp(args) {
8
+ const log = args.log ?? new StatefulLog({ label: "Build" });
9
+ const folder = "./.eddev/" +
10
+ getVinxiFolder({
11
+ mode: args.mode,
12
+ serverless: true,
13
+ });
14
+ return createApp({
15
+ server: {
16
+ // experimental: {
17
+ // websocket: true,
18
+ // },
19
+ preset: args.preset,
20
+ routeRules: {
21
+ "/wp-content/uploads/**": {
22
+ proxy: joinURL(args.origin, "wp-content/uploads/**"),
23
+ static: true,
24
+ cache: {
25
+ maxAge: 86400,
26
+ varies: [],
27
+ },
28
+ },
29
+ "/favicon.ico": {
30
+ proxy: joinURL(args.origin, "favicon.ico"),
31
+ static: true,
32
+ cache: {
33
+ maxAge: 3600,
34
+ varies: [],
35
+ },
36
+ },
37
+ "/robots.txt": {
38
+ cache: {
39
+ maxAge: 3600,
40
+ varies: [],
41
+ },
42
+ },
43
+ "/sitemap.xml": {
44
+ cache: {
45
+ maxAge: 3600,
46
+ swr: true,
47
+ },
48
+ },
49
+ "/sitemap*.xml": {
50
+ cache: {
51
+ maxAge: 3600,
52
+ swr: true,
53
+ },
54
+ },
55
+ "/wp-content/plugins/**": {
56
+ proxy: joinURL(args.origin, "wp-content/plugins/**"),
57
+ headers: {
58
+ "Cache-Control": "max-age=86400",
59
+ "CDN-Cache-Control": "max-age=86400",
60
+ "Vercel-CDN-Cache-Control": "max-age=86400",
61
+ },
62
+ },
63
+ "/wp-content/**": { proxy: joinURL(args.origin, "wp-content/**") },
64
+ "/wp-includes/**": { proxy: joinURL(args.origin, "wp-includes/**") },
65
+ "/_data/route/**": {
66
+ isr: 300,
67
+ swr: true,
68
+ cache: {
69
+ maxAge: 300,
70
+ swr: true,
71
+ varies: ["Authorization", "woocommerce-session"],
72
+ },
73
+ },
74
+ "/_data/query/**": {
75
+ isr: false,
76
+ cache: {
77
+ maxAge: 300,
78
+ varies: ["Authorization", "woocommerce-session"],
79
+ },
80
+ },
81
+ ...args.rpcBases?.reduce((acc, base) => {
82
+ return {
83
+ ...acc,
84
+ ["/" + base.replace(/(^\/|\/$)/g, "") + "/**/*"]: {
85
+ isr: false,
86
+ swr: false,
87
+ },
88
+ };
89
+ }, {}),
90
+ "/**/*": {
91
+ isr: 300,
92
+ swr: true,
93
+ cache: {
94
+ maxAge: 300,
95
+ swr: true,
96
+ staleMaxAge: 3600,
97
+ },
98
+ },
99
+ },
100
+ vercel: {
101
+ config: {
102
+ bypassToken: process.env.VERCEL_BYPASS_TOKEN,
103
+ },
104
+ },
105
+ },
106
+ routers: [
107
+ ...args.config.serverless.themeAssets.map((folder) => {
108
+ const folderName = folder
109
+ .split("/")
110
+ .filter((p) => !p.includes("*") && p !== ".")
111
+ .join("/");
112
+ return {
113
+ name: "public_" + folderName,
114
+ type: "static",
115
+ dir: "./" + folderName,
116
+ base: joinURL(args.publicUrl, folderName),
117
+ };
118
+ }),
119
+ {
120
+ name: "bypass-api",
121
+ type: "http",
122
+ base: "/_bypass/",
123
+ handler: `${folder}/handler.bypass.ts`,
124
+ target: "server",
125
+ plugins: () => [
126
+ tsconfigPaths(),
127
+ envPlugin({
128
+ rootDir: args.rootDir,
129
+ console: log,
130
+ mode: args.mode,
131
+ publicUrl: args.publicUrl,
132
+ serverless: true,
133
+ target: "frontend",
134
+ client: false,
135
+ }),
136
+ ],
137
+ },
138
+ // {
139
+ // name: "wp-proxy",
140
+ // type: "http",
141
+ // base: "/wp-",
142
+ // handler: `${folder}/handler.wp-proxy.ts`,
143
+ // target: "server",
144
+ // plugins: () => [
145
+ // ...corePlugins({
146
+ // rootDir: args.rootDir,
147
+ // console: log,
148
+ // mode: args.mode,
149
+ // publicUrl: args.publicUrl,
150
+ // serverless: true,
151
+ // target: "frontend",
152
+ // }),
153
+ // ],
154
+ // },
155
+ {
156
+ name: "client",
157
+ type: "client",
158
+ handler: `${folder}/entry.client.tsx`,
159
+ target: "browser",
160
+ plugins: () => [
161
+ ...corePlugins({
162
+ rootDir: args.rootDir,
163
+ console: log,
164
+ mode: args.mode,
165
+ publicUrl: args.publicUrl,
166
+ serverless: true,
167
+ target: "frontend",
168
+ client: true,
169
+ }),
170
+ ],
171
+ base: "/_build",
172
+ },
173
+ {
174
+ name: "admin",
175
+ type: "client",
176
+ handler: `${folder}/entry.admin.tsx`,
177
+ target: "browser",
178
+ plugins: () => [
179
+ ...corePlugins({
180
+ rootDir: args.rootDir,
181
+ console: log,
182
+ mode: args.mode,
183
+ publicUrl: args.publicUrl,
184
+ serverless: true,
185
+ target: "cms",
186
+ client: true,
187
+ }),
188
+ ],
189
+ base: "/_admin",
190
+ },
191
+ // ...((args.rpcBases ?? []).map((base) => ({
192
+ // name: "trpc" + base.replace(/^\//, "-"),
193
+ // type: "http",
194
+ // base: "/" + base.replace(/^\//, ""),
195
+ // handler: `${folder}/handler.trpc-api.ts`,
196
+ // target: "server",
197
+ // plugins: () => [
198
+ // tsconfigPaths(),
199
+ // envPlugin({
200
+ // rootDir: args.rootDir,
201
+ // console: log,
202
+ // mode: args.mode,
203
+ // publicUrl: args.publicUrl,
204
+ // serverless: true,
205
+ // target: "frontend",
206
+ // }),
207
+ // ],
208
+ // })) as RouterSchemaInput[]),
209
+ {
210
+ name: "ssr",
211
+ type: "http",
212
+ handler: `${folder}/handler.ssr-page.ts`,
213
+ target: "server",
214
+ plugins: () => [
215
+ ...corePlugins({
216
+ rootDir: args.rootDir,
217
+ console: log,
218
+ mode: args.mode,
219
+ publicUrl: args.publicUrl,
220
+ serverless: true,
221
+ target: "frontend",
222
+ client: false,
223
+ }),
224
+ ],
225
+ },
226
+ ],
227
+ });
228
+ }
@@ -0,0 +1,12 @@
1
+ import { Project } from "../project/project.js";
2
+ import { FSCodegen } from "../utils/fs-codegen.js";
3
+ type Options = {
4
+ mode: "development" | "production";
5
+ serverless: boolean;
6
+ project: Project;
7
+ endpoint?: string;
8
+ };
9
+ export declare function getVinxiFolder(opts: Pick<Options, "mode" | "serverless">): string;
10
+ export declare function runVinxiCodegen(opts: Options): Promise<void>;
11
+ export declare function createVinxiCodegen(opts: Options): FSCodegen;
12
+ export {};