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,39 @@
1
+ import { createTRPCUntypedClient, httpLink, splitLink, unstable_httpSubscriptionLink, } from "@trpc/client";
2
+ import SuperJSON from "superjson";
3
+ import { parseURL, stringifyParsedURL } from "ufo";
4
+ const updatePath = (url) => {
5
+ const parsed = parseURL(url);
6
+ parsed.pathname = "/" + parsed.pathname.replace(/(^\/|\/$)/g, "").replace(/\./g, "/") + "/";
7
+ return stringifyParsedURL(parsed);
8
+ };
9
+ let client;
10
+ export function getRPCClient() {
11
+ if (env.rpcEnabled) {
12
+ if (!client) {
13
+ // @ts-ignore
14
+ const endpoint = env.serverless ? "/" : window.SERVERLESS_ENDPOINT ?? "/";
15
+ client = createTRPCUntypedClient({
16
+ links: [
17
+ splitLink({
18
+ condition: (op) => op.type === "subscription",
19
+ true: unstable_httpSubscriptionLink({
20
+ url: endpoint,
21
+ transformer: SuperJSON,
22
+ }),
23
+ false: httpLink({
24
+ url: endpoint,
25
+ fetch: (url, opts) => {
26
+ return fetch(updatePath(url), {
27
+ ...opts,
28
+ credentials: "omit",
29
+ });
30
+ },
31
+ transformer: SuperJSON,
32
+ }),
33
+ }),
34
+ ],
35
+ });
36
+ }
37
+ }
38
+ return client;
39
+ }
@@ -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,
@@ -88,20 +90,26 @@ if (!isMainThread) {
88
90
  });
89
91
  }
90
92
  if (mode === "admin") {
91
- new AdminBundler(project, {
93
+ const bundler = new AdminBundler(project, {
92
94
  mode: "development",
93
95
  });
96
+ bundler.start();
94
97
  pipeLog(adminLog);
95
98
  }
96
99
  else if (mode === "frontend") {
97
- new FrontendBundler(project, {
100
+ const bundler = new FrontendBundler(project, {
98
101
  mode: "development",
99
102
  watch: true,
100
103
  });
104
+ bundler.start();
101
105
  pipeLog(frontendLog);
102
106
  }
103
107
  else if (mode === "graphql") {
104
- const codegen = new GraphQLGenerator(project);
108
+ const codegen = new GraphQLGenerator(project, {
109
+ generate: true,
110
+ optimize: true,
111
+ watch: true,
112
+ });
105
113
  codegen.start();
106
114
  pipeLog(graphqlLog);
107
115
  }
@@ -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,25 @@ 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
+ console.error = (...args) => { };
37
+ console.log = (...args) => { };
38
+ console.info = (...args) => { };
39
+ console.warn = (...args) => { };
40
+ // if (typeof args[0] === "string" && args[0].includes("NODE_TLS_REJECT_UNAUTHORIZED")) return
41
+ // serverlessLog.error(...args)
42
+ // }
43
+ process.env["NODE_ENV"] = "development";
44
+ /** Ignore self-signed certificate errors in dev mode */
45
+ // process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0"
33
46
  serverlessLog.info(chalk.yellowBright(`⚡️ ED. Stack v${VERSION}`));
47
+ if (options.fast) {
48
+ options.mode = "graphql,serverless";
49
+ }
34
50
  const tasks = {
35
51
  admin: !options.mode || options.mode.includes("admin"),
36
52
  frontend: !options.mode || options.mode.includes("frontend"),
@@ -63,9 +79,24 @@ program
63
79
  rootDir: process.cwd(),
64
80
  reportPluginCompatibility: true,
65
81
  });
82
+ const result = await project.verifyOriginAccess();
83
+ if (!result.success) {
84
+ projectLog.fail(result.message);
85
+ process.exit(1);
86
+ return;
87
+ }
66
88
  const infoWriter = new BuildInfoWriter(project);
67
89
  infoWriter.watch();
68
90
  infoWriter.write();
91
+ if (tasks.admin || tasks.frontend) {
92
+ const spaStaging = createVinxiCodegen({
93
+ mode: "development",
94
+ project,
95
+ serverless: false,
96
+ endpoint: "",
97
+ });
98
+ spaStaging.runAndWatch();
99
+ }
69
100
  // Boot up admin in a worker
70
101
  if (tasks.admin) {
71
102
  new CLIWorker({
@@ -88,6 +119,9 @@ program
88
119
  serverlessLog.log(...args);
89
120
  };
90
121
  console.error = (...args) => {
122
+ // We ignore SSL errors in dev mode.
123
+ if (typeof args[0] === "string" && args[0].includes("NODE_TLS_REJECT_UNAUTHORIZED"))
124
+ return;
91
125
  serverlessLog.error(...args);
92
126
  };
93
127
  console.warn = (...args) => {
@@ -96,7 +130,14 @@ program
96
130
  console.info = (...args) => {
97
131
  serverlessLog.info(...args);
98
132
  };
99
- new ServerlessDevServer(project, {
133
+ const serverlessStaging = createVinxiCodegen({
134
+ mode: "development",
135
+ project,
136
+ serverless: true,
137
+ endpoint: "",
138
+ });
139
+ await serverlessStaging.runAndWatch();
140
+ new DevServer(project, {
100
141
  mode: "development",
101
142
  });
102
143
  }
@@ -115,6 +156,9 @@ program
115
156
  .option("-s, --serverless", 'Build in "serverless" mode', false)
116
157
  .option("--verbose", "Show extra debugging info", false)
117
158
  .action(async (options) => {
159
+ process.env["NODE_ENV"] = "production";
160
+ /** Ignore self-signed certificate errors in dev mode */
161
+ // process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0"
118
162
  init(options.verbose);
119
163
  configureCliMode({
120
164
  interactive: false,
@@ -125,17 +169,72 @@ program
125
169
  watch: false,
126
170
  rootDir: process.cwd(),
127
171
  });
172
+ const console = createConsole("build");
128
173
  // Load the project info
129
174
  const project = await Project.create({
130
175
  rootDir: process.cwd(),
131
176
  });
132
- // Load the compiler
133
- new AdminBundler(project, {
134
- mode: "development",
135
- });
136
- new FrontendBundler(project, {
137
- mode: "production",
177
+ const buildServerless = options.serverless || process.env.VERCEL;
178
+ if (buildServerless) {
179
+ // Verify that the we have access to the origin
180
+ const result = await project.verifyOriginAccess();
181
+ if (!result.success) {
182
+ console.error(result.message);
183
+ process.exit(1);
184
+ return;
185
+ }
186
+ await buildVinxi({
187
+ project,
188
+ console,
189
+ });
190
+ }
191
+ else {
192
+ const infoWriter = new BuildInfoWriter(project);
193
+ // Generate bootstrap files
194
+ const codegen = createVinxiCodegen({
195
+ mode: "production",
196
+ project: project,
197
+ serverless: false,
198
+ });
199
+ await codegen.run();
200
+ console.info("Building for SPA WordPress (Frontend and Admin)");
201
+ // Load the compiler
202
+ const admin = new AdminBundler(project, {
203
+ mode: "production",
204
+ });
205
+ const frontend = new FrontendBundler(project, {
206
+ mode: "production",
207
+ });
208
+ const graphql = new GraphQLGenerator(project, {
209
+ optimize: true,
210
+ });
211
+ await Promise.all([infoWriter.write(), admin.start(), frontend.start(), graphql.start()]);
212
+ console.log("Done building SPA WordPress");
213
+ }
214
+ });
215
+ program
216
+ .command("preview")
217
+ .description("Run a local production build, which was previously built with `eddev build --serverless`")
218
+ .option("--host", "Hostname to serve the application", "127.0.0.1")
219
+ .option("--port", "Port to serve the application", "3000")
220
+ .action(async (options) => {
221
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
222
+ process.env["NODE_ENV"] = "production";
223
+ process.env["HOST"] = options.host;
224
+ process.env["PORT"] = options.port;
225
+ init(options.verbose);
226
+ configureCliMode({
227
+ interactive: true,
228
+ readonly: false,
229
+ exitOnValidationError: true,
230
+ detailed: true,
231
+ verbose: options.verbose,
232
+ watch: false,
233
+ rootDir: process.cwd(),
138
234
  });
235
+ const entry = ".output/server/index.mjs";
236
+ console.info("Looking for production serverless build in: " + entry + "...");
237
+ await import(join(process.cwd(), ".output/server/index.mjs"));
139
238
  });
140
239
  program
141
240
  .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);
@@ -5,6 +5,6 @@ export function bootCLIUI(props) {
5
5
  console.clear();
6
6
  render(_jsx(CLIApp, { ...props }), {
7
7
  exitOnCtrlC: true,
8
- patchConsole: true,
8
+ patchConsole: false,
9
9
  });
10
10
  }
@@ -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";
1
+ export declare const VERSION = "2.0.0-beta.95";
@@ -1 +1 @@
1
- export const VERSION = "2.0.0";
1
+ export const VERSION = "2.0.0-beta.95";
@@ -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
+ preset,
21
+ config: project.config,
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,18 +10,18 @@ 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,
24
23
  target: "cms",
24
+ client: true,
25
25
  });
26
26
  console.verbose("Vite config:", baseConfig);
27
27
  await build(mergeConfig(baseConfig, defineConfig({
@@ -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,18 +10,18 @@ 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,
24
23
  target: "frontend",
24
+ client: true,
25
25
  });
26
26
  console.verbose("Vite config:", baseConfig);
27
27
  await build(mergeConfig(baseConfig, defineConfig({
@@ -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
  }