eddev 2.0.0-beta.2 → 2.0.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/dist/app/entry/boot-admin.d.ts +1 -0
  2. package/dist/app/entry/{main.admin.js → boot-admin.js} +3 -5
  3. package/dist/app/entry/spa-root.d.ts +1 -0
  4. package/dist/app/entry/{Root.js → spa-root.js} +4 -4
  5. package/dist/app/entry/ssr-root-client.d.ts +4 -0
  6. package/dist/app/entry/ssr-root-client.js +9 -0
  7. package/dist/app/entry/ssr-root.d.ts +9 -0
  8. package/dist/app/entry/ssr-root.js +21 -0
  9. package/dist/app/lib/admin/index.d.ts +2 -2
  10. package/dist/app/lib/admin/index.js +2 -2
  11. package/dist/app/lib/admin/installFieldTypes.js +1 -1
  12. package/dist/app/lib/admin/runWidgets.js +1 -1
  13. package/dist/app/lib/blocks/ContentBlocks.js +4 -4
  14. package/dist/app/lib/blocks/EditableText.d.ts +1 -1
  15. package/dist/app/lib/blocks/EditableText.js +2 -2
  16. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +1 -1
  17. package/dist/app/lib/blocks/InnerBlocks.d.ts +2 -2
  18. package/dist/app/lib/blocks/InnerBlocks.js +4 -4
  19. package/dist/app/lib/blocks/block-utils.d.ts +1 -1
  20. package/dist/app/lib/blocks/block-utils.js +1 -1
  21. package/dist/app/lib/blocks/editor/EditorSupport.js +3 -3
  22. package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +1 -1
  23. package/dist/app/lib/blocks/editor/editor-config.d.ts +1 -1
  24. package/dist/app/lib/blocks/editor/editor-config.js +1 -1
  25. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +5 -5
  26. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  27. package/dist/app/lib/blocks/index.d.ts +9 -9
  28. package/dist/app/lib/blocks/index.js +9 -9
  29. package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
  30. package/dist/app/lib/blocks/inline-editing.js +3 -3
  31. package/dist/app/lib/devtools/components/BreakpointIndicator.js +5 -3
  32. package/dist/app/lib/devtools/components/DevUI.js +1 -1
  33. package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
  34. package/dist/app/lib/devtools/dev-tools-store.js +8 -0
  35. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1078 -1079
  36. package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
  37. package/dist/app/lib/devtools/index.d.ts +1 -0
  38. package/dist/app/lib/devtools/index.js +1 -1
  39. package/dist/app/lib/devtools/loader.js +4 -4
  40. package/dist/app/lib/dynamic/index.d.ts +1 -1
  41. package/dist/app/lib/dynamic/index.js +1 -1
  42. package/dist/app/lib/hooks/index.d.ts +5 -5
  43. package/dist/app/lib/hooks/index.js +5 -5
  44. package/dist/app/lib/hooks/queryUtils.d.ts +4 -1
  45. package/dist/app/lib/hooks/queryUtils.js +10 -13
  46. package/dist/app/lib/hooks/useAppData.js +1 -1
  47. package/dist/app/lib/internal/index.d.ts +4 -4
  48. package/dist/app/lib/internal/index.js +4 -4
  49. package/dist/app/lib/internal/internal-store.d.ts +0 -2
  50. package/dist/app/lib/internal/internal-store.js +1 -3
  51. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  52. package/dist/app/lib/legacy-stitches/createStitches.d.ts +3 -511
  53. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  54. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  55. package/dist/app/lib/legacy-stitches/index.js +1 -1
  56. package/dist/app/lib/routing/components/BrowserRouter.js +4 -4
  57. package/dist/app/lib/routing/components/ClientOnly.d.ts +1 -1
  58. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  59. package/dist/app/lib/routing/components/Link.js +5 -5
  60. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  61. package/dist/app/lib/routing/components/RouteRenderer.js +3 -3
  62. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  63. package/dist/app/lib/routing/components/SSRRouter.js +4 -4
  64. package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
  65. package/dist/app/lib/routing/context.d.ts +2 -2
  66. package/dist/app/lib/routing/context.js +1 -1
  67. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  68. package/dist/app/lib/routing/hooks/useRoute.d.ts +1 -1
  69. package/dist/app/lib/routing/hooks/useRoute.js +1 -1
  70. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  71. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  72. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  73. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  74. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  75. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  76. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  77. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  78. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  79. package/dist/app/lib/routing/index.d.ts +13 -13
  80. package/dist/app/lib/routing/index.js +13 -13
  81. package/dist/app/lib/routing/loader.d.ts +2 -2
  82. package/dist/app/lib/routing/loader.js +7 -5
  83. package/dist/app/lib/routing/types.d.ts +2 -2
  84. package/dist/app/lib/routing/utils.d.ts +1 -1
  85. package/dist/app/lib/views/index.d.ts +1 -1
  86. package/dist/app/lib/views/index.js +1 -1
  87. package/dist/app/server/index.d.ts +3 -0
  88. package/dist/app/server/index.js +3 -0
  89. package/dist/app/server/proxy-wp-admin.d.ts +3 -0
  90. package/dist/app/server/proxy-wp-admin.js +105 -0
  91. package/dist/app/server/render-ssr-page.d.ts +3 -0
  92. package/dist/app/server/render-ssr-page.js +21 -0
  93. package/dist/app/server/server-context.d.ts +37 -0
  94. package/dist/app/server/server-context.js +118 -0
  95. package/dist/app/server/utils/headers.d.ts +1 -0
  96. package/dist/app/server/utils/headers.js +17 -0
  97. package/dist/app/server/utils/replace-host.d.ts +6 -4
  98. package/dist/app/server/utils/replace-host.js +58 -11
  99. package/dist/node/cli/cli-worker.d.ts +1 -1
  100. package/dist/node/cli/cli-worker.js +7 -2
  101. package/dist/node/cli/cli.js +83 -12
  102. package/dist/node/cli/display/CLIApp.d.ts +1 -1
  103. package/dist/node/cli/display/CLIApp.js +3 -6
  104. package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
  105. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
  106. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
  107. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
  108. package/dist/node/cli/display/tools/cli-tools.js +9 -9
  109. package/dist/node/cli/display/util/colors.d.ts +2 -2
  110. package/dist/node/cli/version.d.ts +1 -1
  111. package/dist/node/cli/version.js +1 -1
  112. package/dist/node/compiler/build-vinxi.d.ts +8 -0
  113. package/dist/node/compiler/build-vinxi.js +37 -0
  114. package/dist/node/compiler/bundler.admin.d.ts +2 -2
  115. package/dist/node/compiler/bundler.admin.js +3 -4
  116. package/dist/node/compiler/bundler.frontend.d.ts +1 -1
  117. package/dist/node/compiler/bundler.frontend.js +3 -4
  118. package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
  119. package/dist/node/compiler/dev-server.js +97 -0
  120. package/dist/node/compiler/get-vite-config.d.ts +19 -0
  121. package/dist/node/compiler/get-vite-config.js +201 -0
  122. package/dist/node/compiler/vinxi-app.d.ts +10 -0
  123. package/dist/node/compiler/vinxi-app.js +121 -0
  124. package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
  125. package/dist/node/compiler/vinxi-codegen.js +417 -0
  126. package/dist/node/graphql/graphql-codegen.d.ts +1 -1
  127. package/dist/node/graphql/graphql-codegen.js +3 -3
  128. package/dist/node/graphql/graphql-schema-loader.js +15 -18
  129. package/dist/node/project/config.js +1 -1
  130. package/dist/node/project/env.d.ts +1 -1
  131. package/dist/node/project/env.js +1 -1
  132. package/dist/node/project/favicons.d.ts +1 -0
  133. package/dist/node/project/favicons.js +1 -1
  134. package/dist/node/project/manifest/block-manifest.js +2 -2
  135. package/dist/node/project/manifest/manifest.d.ts +1 -1
  136. package/dist/node/project/manifest/manifest.js +1 -1
  137. package/dist/node/project/manifest/view-manifest.js +2 -2
  138. package/dist/node/project/project.d.ts +3 -2
  139. package/dist/node/project/project.js +17 -19
  140. package/dist/node/project/wp-info.js +0 -2
  141. package/dist/node/types/block-type.d.ts +2 -2
  142. package/dist/node/types/view-type.js +3 -4
  143. package/dist/node/utils/fs-codegen.d.ts +40 -0
  144. package/dist/node/utils/fs-codegen.js +97 -0
  145. package/dist/node/utils/fs.js +2 -0
  146. package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
  147. package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
  148. package/package.json +29 -31
  149. package/tsconfig.app.json +2 -2
  150. package/tsconfig.node.json +2 -2
  151. package/types.app.d.ts +2 -2
  152. package/types.app.internal.d.ts +2 -2
  153. package/types.node.d.ts +3 -3
  154. package/dist/app/entry/Root.d.ts +0 -1
  155. package/dist/app/entry/main.admin.d.ts +0 -3
  156. package/dist/app/entry/main.frontend.spa.d.ts +0 -3
  157. package/dist/app/entry/main.frontend.spa.js +0 -13
  158. package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
  159. package/dist/app/entry/main.frontend.ssr.js +0 -79
  160. package/dist/app/entry/main.serverless.dev.d.ts +0 -4
  161. package/dist/app/entry/main.serverless.dev.js +0 -21
  162. package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
  163. package/dist/app/server/create-api-builtin-hono.js +0 -80
  164. package/dist/app/server/create-ssr-hono.d.ts +0 -18
  165. package/dist/app/server/create-ssr-hono.js +0 -104
  166. package/dist/app/server/utils/index.html.d.ts +0 -2
  167. package/dist/app/server/utils/index.html.js +0 -14
  168. package/dist/node/compiler/index.html.d.ts +0 -2
  169. package/dist/node/compiler/index.html.js +0 -15
  170. package/dist/node/compiler/serverless.dev.js +0 -215
  171. package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
  172. package/dist/node/compiler/vite/get-vite-config.js +0 -315
  173. package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
  174. package/dist/node/compiler/vite/plugin-admin.js +0 -67
  175. package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
  176. package/dist/node/compiler/vite/plugin-blocks.js +0 -73
  177. package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
  178. package/dist/node/compiler/vite/plugin-entry.js +0 -16
  179. package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
  180. package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
  181. package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
  182. package/dist/node/compiler/vite/plugin-theme.js +0 -40
  183. package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
  184. package/dist/node/compiler/vite/plugin-views.js +0 -51
  185. package/dist/node/utils/console.d.ts +0 -21
  186. package/dist/node/utils/console.js +0 -28
  187. package/dist/node/utils/unsafe-fetch.d.ts +0 -2
  188. package/dist/node/utils/unsafe-fetch.js +0 -19
  189. package/tsup.config.ts +0 -40
  190. package/types.manifests.d.ts +0 -22
  191. /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
  192. /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
  193. /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
  194. /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
  195. /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
  196. /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
  197. /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
  198. /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
  199. /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
  200. /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
  201. /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
  202. /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
  203. /package/dist/node/utils/{watchFileTree.d.ts → watch-file-tree.d.ts} +0 -0
  204. /package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +0 -0
@@ -1,14 +1,61 @@
1
1
  export function createUrlReplacer(conf) {
2
- const from = conf.from;
3
- const to = conf.to;
4
- const https = conf.https;
5
- const ignoreUploads = conf.ignoreUploads;
6
- const ignorePlugins = conf.ignorePlugins;
7
- const replaceTargetString = from.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\/");
8
- const replaceTargetEscapedString = from.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\\\/");
9
- const replaceTarget = new RegExp(replaceTargetString, "g");
10
- const replaceTargetEscaped = new RegExp(replaceTargetEscapedString, "g");
11
- return (value) => {
12
- return value.replaceAll(replaceTarget, to).replace(replaceTargetEscaped, to.replaceAll("/", "\\/"));
2
+ // Create a regular expression to match the URL
3
+ // Note that that the regex doesn't necessarily match the entire URL
4
+ const lookup = new RegExp(conf.from.replace(/https?[:\\\/]+/, "https?[:\\/\\\\]+") + "([a-z0-9\\-_/\\\\]+)", "ig");
5
+ return (text) => {
6
+ return text.replace(lookup, (url) => {
7
+ // Strip out the origin, to create a relative path
8
+ const path = url.replace(/https?:[\/\\]+[^\/\\]+/, "");
9
+ const isEscaped = url.includes(":\\/\\/");
10
+ const key = "/" +
11
+ path
12
+ .split(/[\/\\]+/g)
13
+ .filter((v) => v)
14
+ .join("/");
15
+ for (let item of conf.prefixes) {
16
+ if (key.startsWith(item.prefix)) {
17
+ if (item.replace) {
18
+ return url;
19
+ }
20
+ else {
21
+ return path;
22
+ }
23
+ }
24
+ }
25
+ return path;
26
+ // if (path.startsWith("/wp-content/uploads/")) {
27
+ // if (!conf.ignoreUploads) {
28
+ // return path
29
+ // } else {
30
+ // return url
31
+ // }
32
+ // // } else if (path.startsWith("/wp-content/themes/")) {
33
+ // // if (settings?.uploads === "proxy") {
34
+ // // return path
35
+ // // } else if (settings?.uploads === "remote") {
36
+ // // return url
37
+ // // }
38
+ // // } else if (path.startsWith("/wp-content/plugins/")) {
39
+ // // if (settings?.uploads === "proxy") {
40
+ // // return path
41
+ // // } else if (settings?.uploads === "remote") {
42
+ // // return url
43
+ // // }
44
+ // } else {
45
+ // return path
46
+ // }
47
+ });
13
48
  };
49
+ // const from = conf.from
50
+ // const to = conf.to
51
+ // const https = conf.https
52
+ // const ignoreUploads = conf.ignoreUploads
53
+ // const ignorePlugins = conf.ignorePlugins
54
+ // const replaceTargetString = from.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\/")
55
+ // const replaceTargetEscapedString = from.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\\\/")
56
+ // const replaceTarget = new RegExp(replaceTargetString, "g")
57
+ // const replaceTargetEscaped = new RegExp(replaceTargetEscapedString, "g")
58
+ // return (value: string) => {
59
+ // return value.replaceAll(replaceTarget, to).replace(replaceTargetEscaped, to.replaceAll("/", "\\/"))
60
+ // }
14
61
  }
@@ -1,5 +1,5 @@
1
1
  import { Worker } from "node:worker_threads";
2
- import { StatefulLog } from "../utils/statefulLog.js";
2
+ import { StatefulLog } from "../utils/stateful-log.js";
3
3
  type WorkerMode = "admin" | "frontend" | "graphql" | "serverless";
4
4
  export declare class CLIWorker {
5
5
  worker: Worker;
@@ -46,6 +46,8 @@ export class CLIWorker {
46
46
  }
47
47
  if (!isMainThread) {
48
48
  const mode = workerData.mode;
49
+ /** Ignore self-signed certificate errors in dev mode */
50
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
49
51
  configureCliMode({
50
52
  interactive: true,
51
53
  readonly: false,
@@ -84,20 +86,23 @@ if (!isMainThread) {
84
86
  }
85
87
  function pipeLog(log) {
86
88
  log.subscribe((log) => {
89
+ // We ignore SSL errors in dev mode.
87
90
  parentPort?.postMessage(JSON.stringify({ type: "log", log: serializeLogData(log) }));
88
91
  });
89
92
  }
90
93
  if (mode === "admin") {
91
- new AdminBundler(project, {
94
+ const bundler = new AdminBundler(project, {
92
95
  mode: "development",
93
96
  });
97
+ bundler.start();
94
98
  pipeLog(adminLog);
95
99
  }
96
100
  else if (mode === "frontend") {
97
- new FrontendBundler(project, {
101
+ const bundler = new FrontendBundler(project, {
98
102
  mode: "development",
99
103
  watch: true,
100
104
  });
105
+ bundler.start();
101
106
  pipeLog(frontendLog);
102
107
  }
103
108
  else if (mode === "graphql") {
@@ -4,7 +4,8 @@ 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";
7
+ import { DevServer, serverlessLog } from "../compiler/dev-server.js";
8
+ import { createVinxiCodegen } from "../compiler/vinxi-codegen.js";
8
9
  import { 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";
@@ -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
  }
@@ -125,17 +153,60 @@ program
125
153
  watch: false,
126
154
  rootDir: process.cwd(),
127
155
  });
156
+ const console = createConsole("build");
128
157
  // Load the project info
129
158
  const project = await Project.create({
130
159
  rootDir: process.cwd(),
131
160
  });
132
- // Load the compiler
133
- new AdminBundler(project, {
134
- mode: "development",
135
- });
136
- new FrontendBundler(project, {
137
- mode: "production",
161
+ const buildServerless = options.serverless || process.env.VERCEL;
162
+ if (buildServerless) {
163
+ await buildVinxi({
164
+ project,
165
+ console,
166
+ });
167
+ }
168
+ else {
169
+ const codegen = createVinxiCodegen({
170
+ mode: "production",
171
+ project: project,
172
+ serverless: false,
173
+ });
174
+ await codegen.run();
175
+ console.info("Building for SPA WordPress (Frontend and Admin)");
176
+ // Load the compiler
177
+ const admin = new AdminBundler(project, {
178
+ mode: "development",
179
+ });
180
+ const frontend = new FrontendBundler(project, {
181
+ mode: "production",
182
+ });
183
+ await Promise.all([admin.start(), frontend.start()]);
184
+ console.log("Done building SPA WordPress");
185
+ }
186
+ });
187
+ program
188
+ .command("preview")
189
+ .description("Run a local production build, which was previously built with `eddev build --serverless`")
190
+ .option("--host", "Hostname to serve the application", "127.0.0.1")
191
+ .option("--port", "Port to serve the application", "3000")
192
+ .action(async (options) => {
193
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
194
+ process.env["NODE_ENV"] = "production";
195
+ process.env["HOST"] = options.host;
196
+ process.env["PORT"] = options.port;
197
+ init(options.verbose);
198
+ configureCliMode({
199
+ interactive: true,
200
+ readonly: false,
201
+ exitOnValidationError: true,
202
+ detailed: true,
203
+ verbose: options.verbose,
204
+ watch: false,
205
+ rootDir: process.cwd(),
138
206
  });
207
+ const entry = ".output/server/index.mjs";
208
+ console.info("Looking for production serverless build in: " + entry + "...");
209
+ await import(join(process.cwd(), ".output/server/index.mjs"));
139
210
  });
140
211
  program
141
212
  .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";
@@ -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.2";
1
+ export declare const VERSION = "2.0.0-beta.20";
@@ -1 +1 @@
1
- export const VERSION = "2.0.0-beta.2";
1
+ export const VERSION = "2.0.0-beta.20";
@@ -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,37 @@
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
+ // log: console,
20
+ preset,
21
+ };
22
+ const codegen = createVinxiCodegen({
23
+ mode: "production",
24
+ project: project,
25
+ serverless: true,
26
+ });
27
+ codegen.registerFile({
28
+ name: "../../app.config.mjs",
29
+ generate: code /* ts */ `
30
+ import { createVinxiApp } from 'eddev/_internal/create-vinxi-app.js'
31
+ export default createVinxiApp(${JSON.stringify(appConf)})
32
+ `,
33
+ });
34
+ await codegen.runAndWatch();
35
+ const app = createVinxiApp(appConf);
36
+ await app.build();
37
+ }
@@ -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,97 @@
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
+ const codegen = createVinxiCodegen({
29
+ mode: "development",
30
+ project: this.project,
31
+ serverless: true,
32
+ });
33
+ await codegen.runAndWatch();
34
+ const app = createVinxiApp({
35
+ mode: "development",
36
+ origin: this.origin,
37
+ publicUrl: this.project.publicUrl,
38
+ rootDir: this.project.rootDir,
39
+ log: console,
40
+ });
41
+ const preset = process.env.TARGET ??
42
+ process.env.PRESET ??
43
+ process.env.SERVER_PRESET ??
44
+ process.env.SERVER_TARGET ??
45
+ process.env.NITRO_PRESET ??
46
+ process.env.NITRO_TARGET ??
47
+ (process.versions.bun !== undefined ? "bun" : "node-server");
48
+ const keys = await ensureSelfSignedCert(this.hostname, this.project.rootDir);
49
+ const httpsConfig = {
50
+ cert: keys.certFile,
51
+ key: keys.keyFile,
52
+ domains: [this.hostname, "localhost"],
53
+ };
54
+ let devApp = null;
55
+ app.hooks.addHooks({
56
+ "app:dev:start": async ({ app, serveConfig }) => {
57
+ serveConfig.https = httpsConfig;
58
+ serveConfig.hostname = this.hostname;
59
+ },
60
+ "app:dev:server:created": async (args) => {
61
+ devApp = args.devApp;
62
+ },
63
+ });
64
+ await createDevServer(app, {
65
+ force: false,
66
+ devtools: false,
67
+ // @ts-ignore
68
+ hostname: this.hostname,
69
+ port: this.port,
70
+ // @ts-ignore
71
+ preset: preset,
72
+ https: httpsConfig,
73
+ });
74
+ // @ts-ignore
75
+ await app.hooks.callHook("app:dev:server:listener:creating", {
76
+ app,
77
+ devApp,
78
+ });
79
+ const listener = await devApp.listen(this.port, {
80
+ hostname: this.hostname,
81
+ port: this.port,
82
+ https: httpsConfig,
83
+ qr: false,
84
+ showURL: false,
85
+ });
86
+ await app.hooks.callHook("app:dev:server:listener:created", {
87
+ app,
88
+ devApp,
89
+ listener,
90
+ });
91
+ console.setWorking(false);
92
+ console.setState({
93
+ serverlessUrl: this.hostOrigin,
94
+ wordpressUrl: this.origin,
95
+ });
96
+ }
97
+ }
@@ -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;