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
@@ -4,8 +4,9 @@ import { setDefaultResultOrder } from "dns";
4
4
  import { config as importDotEnv } from "dotenv";
5
5
  import { AdminBundler, adminLog } from "../compiler/bundler.admin.js";
6
6
  import { FrontendBundler, frontendLog } from "../compiler/bundler.frontend.js";
7
- import { ServerlessDevServer, serverlessLog } from "../compiler/serverless.dev.js";
8
- import { graphqlLog } from "../graphql/graphql-codegen.js";
7
+ import { DevServer, serverlessLog } from "../compiler/dev-server.js";
8
+ import { createVinxiCodegen } from "../compiler/vinxi-codegen.js";
9
+ import { GraphQLGenerator, graphqlLog } from "../graphql/graphql-codegen.js";
9
10
  import { BuildInfoWriter } from "../project/eddev-build-file.js";
10
11
  import { Project, projectLog } from "../project/project.js";
11
12
  import { describeBlockManifest } from "../types/block-type.js";
@@ -14,6 +15,9 @@ import { configureCliMode } from "./cli-mode.js";
14
15
  import { CLIWorker } from "./cli-worker.js";
15
16
  import { bootCLIUI } from "./display/boot-cli-app.js";
16
17
  import { VERSION } from "./version.js";
18
+ import { buildVinxi } from "../compiler/build-vinxi.js";
19
+ import { createConsole } from "../utils/stateful-log.js";
20
+ import { join } from "path";
17
21
  importDotEnv();
18
22
  const program = new Command()
19
23
  .version(VERSION)
@@ -24,13 +28,18 @@ const init = (verbose) => {
24
28
  };
25
29
  program
26
30
  .command("dev")
27
- .description("Build in dev mode")
28
- .option("-s, --serverless", 'Build in "serverless" mode', false)
29
- .option("-m, --mode <mode>", 'Defaults to all modes, but use "frontend", "admin" or "graphql" to run in just one mode', undefined)
31
+ .description("Run in dev mode")
32
+ .option("-m, --mode <mode>", "Comma separated list of modes, or a single mode.", "frontend,admin,graphql,serverless")
33
+ .option("--fast", "Shorthand for --mode graphql,serverless", false)
30
34
  .option("--verbose", "Show extra debugging info", false)
31
35
  .action(async (options) => {
32
- process.env.NODE_ENV = "development";
36
+ process.env["NODE_ENV"] = "development";
37
+ /** Ignore self-signed certificate errors in dev mode */
38
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
33
39
  serverlessLog.info(chalk.yellowBright(`⚡️ ED. Stack v${VERSION}`));
40
+ if (options.fast) {
41
+ options.mode = "graphql,serverless";
42
+ }
34
43
  const tasks = {
35
44
  admin: !options.mode || options.mode.includes("admin"),
36
45
  frontend: !options.mode || options.mode.includes("frontend"),
@@ -66,6 +75,15 @@ program
66
75
  const infoWriter = new BuildInfoWriter(project);
67
76
  infoWriter.watch();
68
77
  infoWriter.write();
78
+ if (tasks.admin || tasks.frontend) {
79
+ const spaStaging = createVinxiCodegen({
80
+ mode: "development",
81
+ project,
82
+ serverless: false,
83
+ endpoint: "",
84
+ });
85
+ spaStaging.runAndWatch();
86
+ }
69
87
  // Boot up admin in a worker
70
88
  if (tasks.admin) {
71
89
  new CLIWorker({
@@ -88,6 +106,9 @@ program
88
106
  serverlessLog.log(...args);
89
107
  };
90
108
  console.error = (...args) => {
109
+ // We ignore SSL errors in dev mode.
110
+ if (typeof args[0] === "string" && args[0].includes("NODE_TLS_REJECT_UNAUTHORIZED"))
111
+ return;
91
112
  serverlessLog.error(...args);
92
113
  };
93
114
  console.warn = (...args) => {
@@ -96,7 +117,14 @@ program
96
117
  console.info = (...args) => {
97
118
  serverlessLog.info(...args);
98
119
  };
99
- new ServerlessDevServer(project, {
120
+ const serverlessStaging = createVinxiCodegen({
121
+ mode: "development",
122
+ project,
123
+ serverless: true,
124
+ endpoint: "",
125
+ });
126
+ await serverlessStaging.runAndWatch();
127
+ new DevServer(project, {
100
128
  mode: "development",
101
129
  });
102
130
  }
@@ -115,6 +143,9 @@ program
115
143
  .option("-s, --serverless", 'Build in "serverless" mode', false)
116
144
  .option("--verbose", "Show extra debugging info", false)
117
145
  .action(async (options) => {
146
+ process.env["NODE_ENV"] = "production";
147
+ /** Ignore self-signed certificate errors in dev mode */
148
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
118
149
  init(options.verbose);
119
150
  configureCliMode({
120
151
  interactive: false,
@@ -125,17 +156,64 @@ program
125
156
  watch: false,
126
157
  rootDir: process.cwd(),
127
158
  });
159
+ const console = createConsole("build");
128
160
  // Load the project info
129
161
  const project = await Project.create({
130
162
  rootDir: process.cwd(),
131
163
  });
132
- // Load the compiler
133
- new AdminBundler(project, {
134
- mode: "development",
135
- });
136
- new FrontendBundler(project, {
137
- mode: "production",
164
+ const buildServerless = options.serverless || process.env.VERCEL;
165
+ if (buildServerless) {
166
+ await buildVinxi({
167
+ project,
168
+ console,
169
+ });
170
+ }
171
+ else {
172
+ // Generate bootstrap files
173
+ const codegen = createVinxiCodegen({
174
+ mode: "production",
175
+ project: project,
176
+ serverless: false,
177
+ });
178
+ await codegen.run();
179
+ console.info("Building for SPA WordPress (Frontend and Admin)");
180
+ // Load the compiler
181
+ const admin = new AdminBundler(project, {
182
+ mode: "production",
183
+ });
184
+ const frontend = new FrontendBundler(project, {
185
+ mode: "production",
186
+ });
187
+ const graphql = new GraphQLGenerator(project, {
188
+ optimize: true,
189
+ });
190
+ await Promise.all([admin.start(), frontend.start(), graphql.start()]);
191
+ console.log("Done building SPA WordPress");
192
+ }
193
+ });
194
+ program
195
+ .command("preview")
196
+ .description("Run a local production build, which was previously built with `eddev build --serverless`")
197
+ .option("--host", "Hostname to serve the application", "127.0.0.1")
198
+ .option("--port", "Port to serve the application", "3000")
199
+ .action(async (options) => {
200
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
201
+ process.env["NODE_ENV"] = "production";
202
+ process.env["HOST"] = options.host;
203
+ process.env["PORT"] = options.port;
204
+ init(options.verbose);
205
+ configureCliMode({
206
+ interactive: true,
207
+ readonly: false,
208
+ exitOnValidationError: true,
209
+ detailed: true,
210
+ verbose: options.verbose,
211
+ watch: false,
212
+ rootDir: process.cwd(),
138
213
  });
214
+ const entry = ".output/server/index.mjs";
215
+ console.info("Looking for production serverless build in: " + entry + "...");
216
+ await import(join(process.cwd(), ".output/server/index.mjs"));
139
217
  });
140
218
  program
141
219
  .command("info")
@@ -2,7 +2,7 @@ import type { graphqlLog } from "../../graphql/graphql-codegen.js";
2
2
  import type { Project, projectLog } from "../../project/project.js";
3
3
  import type { adminLog } from "../../compiler/bundler.admin.js";
4
4
  import type { frontendLog } from "../../compiler/bundler.frontend.js";
5
- import { serverlessLog } from "../../compiler/serverless.dev.js";
5
+ import { serverlessLog } from "../../compiler/dev-server.js";
6
6
  export type CLIDisplayProps = {
7
7
  getProject: () => Project;
8
8
  logs: {
@@ -5,7 +5,7 @@ import { VERSION } from "../version.js";
5
5
  import { LogEntries, LogItem } from "./components/LogEntries.js";
6
6
  import { useStatefulLogs } from "./hooks/useStatefulLog.js";
7
7
  import { statusColor, statusIcon } from "./util/colors.js";
8
- import { serverlessLog } from "../../compiler/serverless.dev.js";
8
+ import { serverlessLog } from "../../compiler/dev-server.js";
9
9
  import { useEffect, useState } from "react";
10
10
  import TextInput from "./components/TextInput.js";
11
11
  import { findTools } from "./tools/cli-tools.js";
@@ -37,7 +37,7 @@ export function CLIApp(props) {
37
37
  process.stdout.write("\u001b[3J\u001b[1J");
38
38
  console.clear();
39
39
  props.logs.serverless?.resetLog();
40
- redraw();
40
+ setImmediate(redraw);
41
41
  }
42
42
  else if (input === "q") {
43
43
  process.exit(0);
@@ -83,17 +83,14 @@ function MainMenu(props) {
83
83
  else if (key.return) {
84
84
  const match = matches[focusIndex];
85
85
  if (match) {
86
- props.onSelect(match.tool.id);
86
+ // props.onSelect(match.tool.id)
87
87
  }
88
88
  }
89
89
  });
90
90
  return (_jsx(Panel, { label: "Main Menu", icon: "\u25C8", color: "yellow", info: "[ESC] to close", children: _jsxs(Box, { width: "100%", flexDirection: "column", paddingX: 1, paddingY: 0, children: [_jsxs(Box, { gap: 1, flexDirection: "row", children: [_jsx(Text, { color: "whiteBright", children: "What would you like to do?" }), _jsx(Text, { color: "gray", children: "[ESC] to close" })] }), _jsxs(Box, { paddingBottom: 1, children: [_jsx(Text, { color: "white", children: "> " }), _jsx(TextInput, { value: search, onChange: (value) => {
91
91
  setSearch(value);
92
92
  setFocusIndex(0);
93
- }, showCursor: true, focus: true, placeholder: "Search..." })] }), matches.length === 0 ? _jsx(Text, { color: "redBright", children: "😓 No results" }) : null, matches.map((item, index) => {
94
- const focused = focusIndex === index;
95
- return (_jsxs(Box, { children: [_jsx(Box, { width: 3, children: _jsx(Text, { children: focused ? "👉" : "" }) }), _jsxs(Box, { children: [_jsx(Text, { color: focused ? "yellow" : "white", children: item.tool.name }), _jsx(Text, { children: String(item.score) })] })] }, item.tool.id));
96
- })] }) }));
93
+ }, showCursor: true, focus: true, placeholder: "Search..." })] }), matches.length === 0 ? _jsx(Text, { color: "redBright", children: "😓 No results" }) : null] }) }));
97
94
  }
98
95
  function MiniLog({ log, border }) {
99
96
  const color = statusColor(log.status);
@@ -1,4 +1,4 @@
1
- import type { LogEntry, LogGroup, LogGroupOrEntry } from "../../../utils/statefulLog.js";
1
+ import type { LogEntry, LogGroup, LogGroupOrEntry } from "../../../utils/stateful-log.js";
2
2
  export declare function LogEntries(props: {
3
3
  entries: LogGroupOrEntry[];
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { StatefulLog } from "../../../utils/statefulLog.js";
1
+ import { StatefulLog } from "../../../utils/stateful-log.js";
2
2
  export type LogInfo<T extends StatefulLog<any> | undefined> = {
3
3
  label: string;
4
4
  value: Exclude<T, undefined>["state"];
@@ -1,2 +1,2 @@
1
- import { ToolProps } from "./cli-tools";
1
+ import { ToolProps } from "./cli-tools.js";
2
2
  export declare function CreateBlock(props: ToolProps): import("react/jsx-runtime").JSX.Element;
@@ -12,15 +12,5 @@ export type ToolInfo = {
12
12
  keywords?: string[];
13
13
  component: FunctionComponent<ToolProps>;
14
14
  };
15
- export declare function findTools(term: string): {
16
- tool: {
17
- id: string;
18
- type: ToolType;
19
- keywords?: string[] | undefined;
20
- name: string;
21
- component: FunctionComponent<ToolProps>;
22
- };
23
- score: number;
24
- matches: import("@nozbe/microfuzz").FuzzyMatches;
25
- }[];
15
+ export declare function findTools(term: string): ToolInfo[];
26
16
  export {};
@@ -1,15 +1,15 @@
1
- import microfuzz from "@nozbe/microfuzz";
2
1
  import { TOOLS } from "./cli-tool-list.js";
3
2
  const toolList = Object.entries(TOOLS).map(([key, value]) => ({ ...value, id: key }));
4
3
  // https://github.com/Nozbe/microfuzz/issues/1
5
4
  // @ts-ignore
6
- const fuzzy = (typeof microfuzz === "function" ? microfuzz : microfuzz.default);
7
- const fuzzyIndex = fuzzy(toolList, {
8
- getText: (tool) => [tool.name, ...(tool.keywords ? tool.keywords : [])],
9
- });
5
+ // const fuzzy = (typeof microfuzz === "function" ? microfuzz : microfuzz.default) as typeof microfuzz
6
+ // const fuzzyIndex = fuzzy(toolList, {
7
+ // getText: (tool) => [tool.name, ...(tool.keywords ? tool.keywords : [])],
8
+ // })
10
9
  export function findTools(term) {
11
- if (!term) {
12
- return toolList.map((tool) => ({ tool, score: 1, matches: [] }));
13
- }
14
- return fuzzyIndex(term).map((result) => ({ tool: result.item, score: result.score, matches: result.matches }));
10
+ return [];
11
+ // if (!term) {
12
+ // return toolList.map((tool) => ({ tool, score: 1, matches: [] }))
13
+ // }
14
+ // return fuzzyIndex(term).map((result) => ({ tool: result.item, score: result.score, matches: result.matches }))
15
15
  }
@@ -1,4 +1,4 @@
1
- import { LogStatus } from "../../../utils/statefulLog.js";
2
- export declare function statusColor(status: LogStatus): "greenBright" | "redBright" | "blueBright" | "whiteBright" | "#FF890C" | "#0C86FF" | "grayBright";
1
+ import { LogStatus } from "../../../utils/stateful-log.js";
2
+ export declare function statusColor(status: LogStatus): "greenBright" | "redBright" | "#FF890C" | "blueBright" | "#0C86FF" | "grayBright" | "whiteBright";
3
3
  export declare function statusIcon(status: LogStatus): "✖" | "✔" | "⚠" | "ℹ" | "⚙" | "v" | "?" | "➜";
4
4
  export declare function statusLabel(status: LogStatus): "Error" | "Warning" | "Info" | "Working" | "Fail" | "Success" | "Verbose" | "Help" | "Log";
@@ -1 +1 @@
1
- export declare const VERSION = "2.0.0-beta.6";
1
+ export declare const VERSION = "2.0.0-beta.61";
@@ -1 +1 @@
1
- export const VERSION = "2.0.0-beta.6";
1
+ export const VERSION = "2.0.0-beta.61";
@@ -0,0 +1,8 @@
1
+ import { Project } from "../project/project.js";
2
+ import { StatefulLog } from "../utils/stateful-log.js";
3
+ type Options = {
4
+ project: Project;
5
+ console: StatefulLog<any>;
6
+ };
7
+ export declare function buildVinxi(opts: Options): Promise<void>;
8
+ export {};
@@ -0,0 +1,38 @@
1
+ import { code } from "ts-poet";
2
+ import { createVinxiApp } from "./vinxi-app.js";
3
+ import { createVinxiCodegen } from "./vinxi-codegen.js";
4
+ export async function buildVinxi(opts) {
5
+ const { project, console } = opts;
6
+ const preset = process.env.TARGET ??
7
+ process.env.PRESET ??
8
+ process.env.SERVER_PRESET ??
9
+ process.env.SERVER_TARGET ??
10
+ process.env.NITRO_PRESET ??
11
+ process.env.NITRO_TARGET ??
12
+ (process.env.VERCEL ? "vercel" : undefined) ??
13
+ (process.versions.bun !== undefined ? "bun" : "node-server");
14
+ const appConf = {
15
+ mode: "production",
16
+ origin: project.origin,
17
+ publicUrl: project.publicUrl,
18
+ rootDir: project.rootDir,
19
+ rpcBases: (await project.serverRoutes.get()).bases,
20
+ // log: console,
21
+ preset,
22
+ };
23
+ const codegen = createVinxiCodegen({
24
+ mode: "production",
25
+ project: project,
26
+ serverless: true,
27
+ });
28
+ codegen.registerFile({
29
+ name: "../../app.config.mjs",
30
+ generate: code /* ts */ `
31
+ import { createVinxiApp } from 'eddev/_internal/create-vinxi-app.js'
32
+ export default createVinxiApp(${JSON.stringify(appConf)})
33
+ `,
34
+ });
35
+ await codegen.runAndWatch();
36
+ const app = createVinxiApp(appConf);
37
+ await app.build();
38
+ }
@@ -1,5 +1,5 @@
1
1
  import { Project } from "../project/project.js";
2
- export declare const adminLog: import("../utils/statefulLog.js").StatefulLog<unknown>;
2
+ export declare const adminLog: import("../utils/stateful-log.js").StatefulLog<unknown>;
3
3
  type Options = {
4
4
  mode: "development" | "production";
5
5
  watch?: boolean;
@@ -8,6 +8,6 @@ export declare class AdminBundler {
8
8
  project: Project;
9
9
  opts: Options;
10
10
  constructor(project: Project, opts: Options);
11
- protected start(): Promise<void>;
11
+ start(): Promise<void>;
12
12
  }
13
13
  export {};
@@ -1,7 +1,7 @@
1
1
  import { relative } from "path";
2
2
  import { build, defineConfig, mergeConfig } from "vite";
3
- import { createConsole } from "../utils/statefulLog.js";
4
- import { getViteConfig } from "./vite/get-vite-config.js";
3
+ import { createConsole } from "../utils/stateful-log.js";
4
+ import { getViteConfig } from "./get-vite-config.js";
5
5
  const console = createConsole("Admin Bundle", "admin");
6
6
  export const adminLog = console;
7
7
  export class AdminBundler {
@@ -10,14 +10,13 @@ export class AdminBundler {
10
10
  constructor(project, opts) {
11
11
  this.project = project;
12
12
  this.opts = opts;
13
- this.start();
14
13
  }
15
14
  async start() {
16
15
  console.info(`Creating ${this.opts.mode} WordPress admin build...`);
17
16
  const baseConfig = getViteConfig({
18
17
  console,
19
18
  mode: this.opts.mode,
20
- project: this.project,
19
+ publicUrl: this.project.publicUrl,
21
20
  rootDir: this.project.rootDir,
22
21
  outDir: relative(this.project.rootDir, "./dist/cms/"),
23
22
  serverless: false,
@@ -1,5 +1,5 @@
1
1
  import { Project } from "../project/project.js";
2
- export declare const frontendLog: import("../utils/statefulLog.js").StatefulLog<unknown>;
2
+ export declare const frontendLog: import("../utils/stateful-log.js").StatefulLog<unknown>;
3
3
  type Options = {
4
4
  mode: "development" | "production";
5
5
  watch?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { relative } from "path";
2
2
  import { build, defineConfig, mergeConfig } from "vite";
3
- import { createConsole } from "../utils/statefulLog.js";
4
- import { getViteConfig } from "./vite/get-vite-config.js";
3
+ import { createConsole } from "../utils/stateful-log.js";
4
+ import { getViteConfig } from "./get-vite-config.js";
5
5
  const console = createConsole("Frontend Bundler", "spa");
6
6
  export const frontendLog = console;
7
7
  export class FrontendBundler {
@@ -10,14 +10,13 @@ export class FrontendBundler {
10
10
  constructor(project, opts) {
11
11
  this.project = project;
12
12
  this.opts = opts;
13
- this.start();
14
13
  }
15
14
  async start() {
16
15
  console.info(`Creating ${this.opts.mode} SPA build...`);
17
16
  const baseConfig = getViteConfig({
18
17
  console,
19
18
  mode: this.opts.mode,
20
- project: this.project,
19
+ publicUrl: this.project.publicUrl,
21
20
  rootDir: this.project.rootDir,
22
21
  outDir: relative(this.project.rootDir, "./dist/frontend/"),
23
22
  serverless: false,
@@ -3,13 +3,15 @@ export type ServerlessDevStatus = {
3
3
  serverlessUrl: string;
4
4
  wordpressUrl: string;
5
5
  };
6
- export declare const serverlessLog: import("../utils/statefulLog.js").StatefulLog<ServerlessDevStatus>;
7
- type Options = {
8
- mode: "development" | "production";
9
- };
10
- export declare class ServerlessDevServer {
6
+ export declare const serverlessLog: import("../utils/stateful-log.js").StatefulLog<ServerlessDevStatus>;
7
+ type Options = {};
8
+ export declare class DevServer {
11
9
  project: Project;
12
10
  opts: Options;
11
+ origin: string;
12
+ hostname: string;
13
+ hostOrigin: string;
14
+ port: number;
13
15
  constructor(project: Project, opts: Options);
14
16
  start(): Promise<void>;
15
17
  }
@@ -0,0 +1,106 @@
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
+ });
44
+ const preset = process.env.TARGET ??
45
+ process.env.PRESET ??
46
+ process.env.SERVER_PRESET ??
47
+ process.env.SERVER_TARGET ??
48
+ process.env.NITRO_PRESET ??
49
+ process.env.NITRO_TARGET ??
50
+ (process.versions.bun !== undefined ? "bun" : "node-server");
51
+ // console.log("Ensuring self signed cert")
52
+ const keys = await ensureSelfSignedCert(this.hostname, this.project.rootDir);
53
+ // console.log("Done")
54
+ const httpsConfig = {
55
+ cert: keys.certFile,
56
+ key: keys.keyFile,
57
+ domains: [this.hostname, "localhost"],
58
+ };
59
+ let devApp = null;
60
+ app.hooks.addHooks({
61
+ "app:dev:start": async ({ app, serveConfig }) => {
62
+ serveConfig.https = httpsConfig;
63
+ serveConfig.hostname = this.hostname;
64
+ },
65
+ "app:dev:server:created": async (args) => {
66
+ devApp = args.devApp;
67
+ },
68
+ });
69
+ // console.log("Creating dev server")
70
+ await createDevServer(app, {
71
+ force: false,
72
+ devtools: false,
73
+ // @ts-ignore
74
+ hostname: this.hostname,
75
+ port: this.port,
76
+ // @ts-ignore
77
+ preset: preset,
78
+ https: httpsConfig,
79
+ });
80
+ // console.log("Rnning listen hook")
81
+ // @ts-ignore
82
+ await app.hooks.callHook("app:dev:server:listener:creating", {
83
+ app,
84
+ devApp,
85
+ });
86
+ // console.log("Creating another listener")
87
+ const listener = await devApp.listen(this.port, {
88
+ hostname: this.hostname,
89
+ port: this.port,
90
+ https: httpsConfig,
91
+ qr: false,
92
+ showURL: false,
93
+ });
94
+ await app.hooks.callHook("app:dev:server:listener:created", {
95
+ app,
96
+ devApp,
97
+ listener,
98
+ });
99
+ // console.log("Listening")
100
+ console.setWorking(false);
101
+ console.setState({
102
+ serverlessUrl: this.hostOrigin,
103
+ wordpressUrl: this.origin,
104
+ });
105
+ }
106
+ }
@@ -0,0 +1,19 @@
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
+ };
12
+ export declare function envPlugin(args: Args): PluginOption;
13
+ export declare function reactPlugin(): PluginOption[];
14
+ /**
15
+ * Turns on SSR module proxying,
16
+ */
17
+ export declare function ssrPlugin(): PluginOption;
18
+ export declare function corePlugins(args: Args): PluginOption[];
19
+ export declare function getViteConfig(args: Args): InlineConfig;