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
@@ -0,0 +1,417 @@
1
+ import { code } from "ts-poet";
2
+ import { FSCodegen } from "../utils/fs-codegen.js";
3
+ export function getVinxiFolder(opts) {
4
+ return (opts.mode === "development" ? "dev" : "prod") + (opts.serverless ? "" : "-spa");
5
+ }
6
+ export async function runVinxiCodegen(opts) {
7
+ const codegen = createVinxiCodegen(opts);
8
+ await codegen.run();
9
+ codegen.stop();
10
+ }
11
+ export function createVinxiCodegen(opts) {
12
+ const project = opts.project;
13
+ const folder = ".eddev/" + getVinxiFolder(opts);
14
+ const codegen = new FSCodegen(opts.project, {
15
+ outDir: folder,
16
+ });
17
+ if (opts.serverless) {
18
+ codegen.registerFile({
19
+ name: "context.ts",
20
+ generate: () => {
21
+ const args = {
22
+ dev: true,
23
+ origin: project.origin,
24
+ replaceUrls: {
25
+ from: project.origin,
26
+ to: opts.endpoint ?? "",
27
+ prefixes: [
28
+ { prefix: "/wp-content/uploads", replace: project.config?.serverless.uploads === "proxy" },
29
+ { prefix: "/wp-content/plugins", replace: project.config?.serverless.plugins === "proxy" },
30
+ ],
31
+ },
32
+ };
33
+ return code /* tsx */ `
34
+ import { ServerContext } from "eddev/server"
35
+ import { getManifest } from "vinxi/manifest"
36
+
37
+ export const serverContext = new ServerContext({${Object.entries(args)
38
+ .map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
39
+ .join(",\n")},
40
+ getManifest
41
+ })
42
+ `.toString();
43
+ },
44
+ });
45
+ }
46
+ if (opts.serverless) {
47
+ codegen.registerFile({
48
+ name: "react-shim.js",
49
+ generate: code /* tsx */ `
50
+ import React from "react"
51
+ import ReactDOM from "react-dom/client"
52
+ Object.assign(React, window.React)
53
+ Object.assign(ReactDOM, window.ReactDOM)
54
+ `,
55
+ });
56
+ }
57
+ codegen.registerFile({
58
+ name: "entry.admin.tsx",
59
+ generate: () => {
60
+ return code /* tsx */ `
61
+ ${opts.serverless ? `import "./react-shim.js"` : ""}
62
+ ${opts.serverless ? `import "vinxi/client"` : ""}
63
+ import "../../views/index.css"
64
+ import "./manifest/admin"
65
+ import "./manifest/blocks"
66
+ import "./manifest/styles"
67
+ import bootAdmin from "eddev/_internal/boot-admin.js"
68
+
69
+ bootAdmin()
70
+ `;
71
+ },
72
+ });
73
+ codegen.registerFile({
74
+ name: "entry.client.tsx",
75
+ generate: () => {
76
+ if (opts.serverless) {
77
+ /**
78
+ * Client entry for SSR mode
79
+ */
80
+ return code /* tsx */ `
81
+ /// <reference types="vinxi/types/client" />
82
+ /**
83
+ * SSR-mode frontend entry.
84
+ * Hydrates the main app, including the html/head/body elements.
85
+ * Also ensures that the assets used during SSR are loaded.
86
+ */
87
+ import "vinxi/client"
88
+ import "../../views/index.css"
89
+ import "./manifest/blocks"
90
+ import "./manifest/views"
91
+
92
+ import * as React from "react"
93
+ import { Root, hydrateRoot } from "react-dom/client"
94
+ import { SSRClientRoot } from "eddev/_internal/ssr-root-client.js"
95
+ import { getManifest } from "vinxi/manifest"
96
+ import { createAssets } from "@vinxi/react"
97
+ import { devToolsStore } from 'eddev/devtools'
98
+
99
+ // Set up a dynamic entry which will load the configured tailwind manifest
100
+ devToolsStore.loadTailwindConfig = () => import('./manifest/tailwind-config.js')
101
+
102
+ // Create the asset renderer, which will ensure scripts/styles are mounted correctly
103
+ function getAssets() {
104
+ const Assets = createAssets(getManifest("client").handler, getManifest("client"))
105
+ return <React.Suspense><Assets /></React.Suspense>
106
+ }
107
+
108
+ window.$reactRoot =
109
+ window.$reactRoot ||
110
+ hydrateRoot(
111
+ document,
112
+ <SSRClientRoot assets={getAssets()} />,
113
+ )
114
+
115
+ if (import.meta.hot) {
116
+ import.meta.hot.accept((mod) => {
117
+ if (mod) {
118
+ const Assets = createAssets(getManifest("client").handler, getManifest("client"))
119
+ const app = <SSRClientRoot assets={getAssets()} />
120
+ window.$reactRoot?.render(app)
121
+ }
122
+ })
123
+ }
124
+
125
+ declare global {
126
+ interface Window {
127
+ $reactRoot?: Root
128
+ }
129
+ }
130
+
131
+ `;
132
+ }
133
+ else {
134
+ return code /* tsx */ `
135
+ /**
136
+ * SPA-mode frontend entry.
137
+ * Renders the main app into the empty <div id='root'> element, and expects window._PAGE_DATA to be set.
138
+ */
139
+ import "./manifest/blocks"
140
+ import "./manifest/views"
141
+ import "../../views/index.css"
142
+ import { devToolsStore } from 'eddev/devtools'
143
+ import { createRoot } from "react-dom/client"
144
+ import { SPARoot } from "eddev/_internal/spa-root.js"
145
+ import * as React from "react"
146
+
147
+ devToolsStore.loadTailwindConfig = () => import('./manifest/tailwind-config')
148
+
149
+ createRoot(document.getElementById("root")!).render(<SPARoot />)
150
+ `;
151
+ }
152
+ },
153
+ });
154
+ if (opts.serverless) {
155
+ codegen.registerFile({
156
+ name: "handler.data-api.ts",
157
+ generate: code /* tsx */ `
158
+ /// <reference types="vinxi/types/server" />
159
+ import { createRouter, eventHandler, getRouterParam, getQuery, getWebRequest, getRequestHeaders } from "vinxi/http"
160
+ import { serverContext } from "./context.js"
161
+
162
+ const router = createRouter()
163
+ .get(
164
+ "/route/",
165
+ eventHandler(async (event) => {
166
+ const id = "/"
167
+
168
+ return await serverContext.fetchRouteData({
169
+ pathname: id,
170
+ withAppData: false,
171
+ })
172
+ }),
173
+ )
174
+ .get(
175
+ "/route/**:name",
176
+ eventHandler(async (event) => {
177
+ const id = "/" + getRouterParam(event, "name")
178
+
179
+ return await serverContext.fetchRouteData({
180
+ pathname: id,
181
+ withAppData: false,
182
+ })
183
+ }),
184
+ )
185
+ .get(
186
+ "/query/**:name",
187
+ eventHandler(async (event) => {
188
+ const id = "/" + getRouterParam(event, "name")
189
+ const paramString = getQuery(event).params
190
+
191
+ const params = typeof paramString === "string" && paramString.length ? JSON.parse(paramString) : {}
192
+
193
+ return await serverContext.fetchNamedQuery({
194
+ name: id,
195
+ params: params,
196
+ headers: getRequestHeaders(event),
197
+ })
198
+ }),
199
+ )
200
+ .post(
201
+ "/mutation/**:name",
202
+ eventHandler(async (event) => {
203
+ const id = "/" + getRouterParam(event, "name")
204
+ const body = await getWebRequest(event).json()
205
+ return await serverContext.fetchMutation({
206
+ name: id,
207
+ body,
208
+ headers: {},
209
+ })
210
+ }),
211
+ )
212
+
213
+ export default router.handler
214
+
215
+ `,
216
+ });
217
+ }
218
+ if (opts.serverless) {
219
+ codegen.registerFile({
220
+ name: "handler.ssr-page.ts",
221
+ generate: code /* tsx */ `
222
+ /// <reference types="vinxi/types/server" />
223
+ import "../../views/index.css"
224
+ import "./manifest/blocks.js"
225
+ import "./manifest/styles.js"
226
+ import "./manifest/views.js"
227
+
228
+ import { renderPageToSSRStream, proxyWpAdmin } from "eddev/server"
229
+ import { eventHandler, setResponseHeader, setResponseStatus, getRequestURL } from "vinxi/http"
230
+ import { serverContext } from "./context.js"
231
+ import { getManifest } from "vinxi/manifest"
232
+
233
+ export default eventHandler({
234
+ handler: async (event) => {
235
+ const url = getRequestURL(event)
236
+
237
+ if (url.pathname.includes('.')) {
238
+ return proxyWpAdmin(event, serverContext)
239
+ }
240
+
241
+ const response = await serverContext.fetchRouteData({
242
+ pathname: url.pathname,
243
+ withAppData: true,
244
+ headers: {},
245
+ query: {},
246
+ })
247
+ if (response.ok) {
248
+ setResponseStatus(event, response.status)
249
+ setResponseHeader(event, "Content-Type", "text/html; charset=utf-8")
250
+ return renderPageToSSRStream(url.pathname, await response.json(), serverContext)
251
+ } else {
252
+ return response
253
+ }
254
+ },
255
+ })
256
+
257
+ `,
258
+ });
259
+ }
260
+ if (opts.serverless) {
261
+ codegen.registerFile({
262
+ name: "handler.wp-proxy.ts",
263
+ generate: code /* tsx */ `
264
+ /// <reference types="vinxi/types/server" />
265
+ import { proxyWpAdmin } from "eddev/server"
266
+ import { eventHandler } from "vinxi/http"
267
+ import { serverContext } from "./context.js"
268
+
269
+ export default eventHandler(async (event) => {
270
+ return proxyWpAdmin(event, serverContext)
271
+ })
272
+ `,
273
+ });
274
+ }
275
+ codegen.registerFile({
276
+ name: "manifest/blocks.ts",
277
+ generate: async () => {
278
+ const blockManifest = await project.blocks.get();
279
+ return code /* ts */ `
280
+ import { blockManifestReader } from 'eddev/_internal'
281
+ import { dynamic } from 'eddev/dynamic'
282
+ import core from '../../../blocks/_core'
283
+
284
+ const manifest = {
285
+ ${Object.entries(blockManifest.blocks)
286
+ .filter(([name]) => !name.match(/^_[a-z]+$/i))
287
+ .map(([name, block]) => {
288
+ const importStatement = `dynamic(() => import(${JSON.stringify("../../../" + block.fileName)}))`;
289
+ return JSON.stringify(block.acfName) + ": " + importStatement;
290
+ })
291
+ .join(",\n")},
292
+ ...core
293
+ }
294
+
295
+ const info = {
296
+ ${Object.entries(blockManifest.blocks)
297
+ .filter(([name]) => !name.match(/^_[a-z]+$/i))
298
+ .map(([name, block]) => {
299
+ return (JSON.stringify(block.acfName) +
300
+ ": " +
301
+ JSON.stringify({
302
+ slug: block.slug,
303
+ tags: block.tags,
304
+ flags: block.flags ?? {},
305
+ }));
306
+ })
307
+ .join(",\n")}
308
+ }
309
+
310
+ blockManifestReader.set(manifest, info)
311
+
312
+ export default manifest
313
+
314
+ if (import.meta.hot) {
315
+ import.meta.hot.accept()
316
+ }
317
+ `;
318
+ },
319
+ subscribe: project.blocks.subscribe,
320
+ });
321
+ codegen.registerFile({
322
+ name: "manifest/admin.ts",
323
+ generate: async () => {
324
+ const fieldManifest = await project.fields.get();
325
+ const widgetManifest = await project.widgets.get();
326
+ return code /* ts */ `
327
+ import { adminManifestReader } from 'eddev/_internal'
328
+ import editorConfig from '../../../blocks/_editor'
329
+
330
+ const fields = {${Object.entries(fieldManifest.fields)
331
+ .map(([name, field]) => {
332
+ const importStatement = `() => import(${JSON.stringify("../../../" + field.fileName)}).then(m => m.default)`;
333
+ return JSON.stringify(field.slug) + ": " + importStatement;
334
+ })
335
+ .join(",\n")}}
336
+ const widgets = {${Object.entries(widgetManifest.widgets)
337
+ .map(([name, widget]) => {
338
+ const importStatement = `() => import(${JSON.stringify("../../../" + widget.fileName)}).then(m => m.default)`;
339
+ return JSON.stringify(widget.slug) + ": " + importStatement;
340
+ })
341
+ .join(",\n")}}
342
+
343
+ const manifest = {
344
+ fields,
345
+ widgets,
346
+ editorConfig
347
+ }
348
+
349
+ adminManifestReader.set(manifest)
350
+
351
+ export default manifest
352
+
353
+ export { editorConfig }
354
+
355
+ if (import.meta.hot) {
356
+ import.meta.hot.accept()
357
+ }
358
+ `;
359
+ },
360
+ subscribe: (callback) => {
361
+ const unsub = [project.fields.subscribe(callback), project.widgets.subscribe(callback)];
362
+ return () => unsub.forEach((u) => u());
363
+ },
364
+ });
365
+ codegen.registerFile({
366
+ name: "manifest/views.ts",
367
+ generate: async () => {
368
+ const viewManifest = await project.views.get();
369
+ return code /* ts */ `
370
+ import { viewManifestReader } from 'eddev/_internal'
371
+ import { dynamic } from 'eddev/dynamic'
372
+ const manifest = {${Object.entries(viewManifest.views)
373
+ .map(([name, view]) => {
374
+ const importStatement = `dynamic(() => import(${JSON.stringify("../../../" + view.fileName)}))`;
375
+ return JSON.stringify(view.slug) + ": " + importStatement;
376
+ })
377
+ .join(",\n")}}
378
+
379
+ viewManifestReader.value = manifest
380
+
381
+ export default manifest
382
+
383
+ if (import.meta.hot) {
384
+ import.meta.hot.accept()
385
+ }
386
+ `;
387
+ },
388
+ subscribe: project.views.subscribe,
389
+ });
390
+ codegen.registerFile({
391
+ name: "manifest/styles.ts",
392
+ generate: async () => {
393
+ return code /* ts */ `
394
+ export const getCssText = undefined
395
+ export const editorGlobalStyles = () => {}
396
+ `;
397
+ },
398
+ });
399
+ codegen.registerFile({
400
+ name: "manifest/tailwind-config.ts",
401
+ generate: async () => {
402
+ return code /* ts */ `
403
+ import tw from "../../../tailwind.config.ts"
404
+ import resolveConfig from 'tailwindcss/resolveConfig'
405
+ import { devToolsStore } from 'eddev/devtools'
406
+
407
+ const value = resolveConfig(tw)
408
+ devToolsStore.tailwindConfig = value
409
+
410
+ if (import.meta.hot) {
411
+ import.meta.hot.accept()
412
+ }
413
+ `;
414
+ },
415
+ });
416
+ return codegen;
417
+ }
@@ -1,5 +1,5 @@
1
1
  import { Project } from "../project/project.js";
2
- export declare const graphqlLog: import("../utils/statefulLog.js").StatefulLog<GraphQLGenerator>;
2
+ export declare const graphqlLog: import("../utils/stateful-log.js").StatefulLog<GraphQLGenerator>;
3
3
  export declare class GraphQLGenerator {
4
4
  project: Project;
5
5
  private needsRegenerate;
@@ -10,9 +10,9 @@ import * as typescriptPlugin from "@graphql-codegen/typescript";
10
10
  import * as typescriptOperationsPlugin from "@graphql-codegen/typescript-operations";
11
11
  import chalk from "chalk";
12
12
  import { code } from "ts-poet";
13
- import { highlightCode } from "../utils/highlightCode.js";
14
- import { createConsole } from "../utils/statefulLog.js";
15
- import { watchFileTreeForChanges } from "../utils/watchFileTree.js";
13
+ import { highlightCode } from "../utils/highlight-code.js";
14
+ import { createConsole } from "../utils/stateful-log.js";
15
+ import { watchFileTreeForChanges } from "../utils/watch-file-tree.js";
16
16
  import pluginFiles from "./plugins/gql-plugin-files.js";
17
17
  import pluginNoDuplicates from "./plugins/gql-plugin-no-duplicates.js";
18
18
  import pluginQueries from "./plugins/gql-plugin-queries.js";
@@ -1,8 +1,6 @@
1
1
  import { loadSchema } from "@graphql-tools/load";
2
2
  import { UrlLoader } from "@graphql-tools/url-loader";
3
3
  import { introspectionFromSchema } from "graphql";
4
- import { Agent } from "https";
5
- import fetch from "node-fetch";
6
4
  import { graphqlLog as console } from "./graphql-codegen.js";
7
5
  import chalk from "chalk";
8
6
  import { hash } from "object-code";
@@ -23,22 +21,21 @@ export class GraphQLSchemaLoader {
23
21
  console.info(`${this.lastHash ? "Reloading" : "Loading"} GraphQL schema from ${chalk.yellowBright(this.url)}`);
24
22
  const rawSchema = await loadSchema(this.url, {
25
23
  loaders: [new UrlLoader()],
26
- fetch: (url, opts) => {
27
- const httpsAgent = new Agent({
28
- rejectUnauthorized: false,
29
- });
30
- return fetch(url, {
31
- ...opts,
32
- agent: function (_parsedURL) {
33
- if (_parsedURL.protocol == "http:") {
34
- return undefined;
35
- }
36
- else {
37
- return httpsAgent;
38
- }
39
- },
40
- });
41
- },
24
+ // fetch: (url: string, opts: any) => {
25
+ // const httpsAgent = new Agent({
26
+ // rejectUnauthorized: false,
27
+ // })
28
+ // return fetch(url, {
29
+ // ...opts,
30
+ // agent: function (_parsedURL) {
31
+ // if (_parsedURL.protocol == "http:") {
32
+ // return undefined
33
+ // } else {
34
+ // return httpsAgent
35
+ // }
36
+ // },
37
+ // })
38
+ // },
42
39
  }).catch((e) => {
43
40
  return e;
44
41
  });
@@ -4,7 +4,7 @@ import { z } from "zod";
4
4
  import { zodToJsonSchema } from "zod-to-json-schema";
5
5
  import { cliMode } from "../cli/cli-mode.js";
6
6
  import { fs } from "../utils/fs.js";
7
- import { isDeploying } from "../utils/isDeploying.js";
7
+ import { isDeploying } from "../utils/is-deploying.js";
8
8
  import { projectLog as console } from "./project.js";
9
9
  export const EDConfigSchema = z.object({
10
10
  $schema: z.string().optional(),
@@ -35,5 +35,5 @@ export declare const ProjectEnvUtils: {
35
35
  valid: false;
36
36
  };
37
37
  getSafe<T extends ProjectEnvKey>(key: T): Required<ProjectEnvMap[T]> | undefined;
38
- get<T extends ProjectEnvKey>(key: T, cons?: import("../utils/statefulLog.js").StatefulLog<import("./project.js").Project>): z.infer<(typeof fields)[T]>;
38
+ get<T extends ProjectEnvKey>(key: T, cons?: import("../utils/stateful-log.js").StatefulLog<import("./project.js").Project>): z.infer<(typeof fields)[T]>;
39
39
  };
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { cliMode } from "../cli/cli-mode.js";
3
3
  import { projectLog as console } from "./project.js";
4
- import { formatZodError } from "../utils/formatZodError.js";
4
+ import { formatZodError } from "../utils/format-zod-error.js";
5
5
  const portNumber = z
6
6
  .string()
7
7
  .default("0")
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- "use strict";
1
+ export {};
@@ -1,8 +1,8 @@
1
1
  import { camelCase, kebabCase } from "change-case-all";
2
2
  import { cliMode } from "../../cli/cli-mode.js";
3
3
  import { BlockMetaSchema } from "../../types/block-type.js";
4
- import { metaExtractor } from "../../utils/export-extractor.js";
5
- import { formatZodError } from "../../utils/formatZodError.js";
4
+ import { metaExtractor } from "../../utils/ts-export-extractor.js";
5
+ import { formatZodError } from "../../utils/format-zod-error.js";
6
6
  import { fs } from "../../utils/fs.js";
7
7
  import { createManifestGenerator } from "./manifest.js";
8
8
  export function loadBlockManifest(project) {
@@ -1,4 +1,4 @@
1
- import { FileEvent } from "../../utils/watchFileTree.js";
1
+ import { FileEvent } from "../../utils/watch-file-tree.js";
2
2
  type ManifestEntry<TEntryData> = {
3
3
  key: string;
4
4
  relativePath: string;
@@ -1,4 +1,4 @@
1
- import { getFileTree, watchFileTree } from "../../utils/watchFileTree.js";
1
+ import { getFileTree, watchFileTree } from "../../utils/watch-file-tree.js";
2
2
  import { relative } from "path";
3
3
  export function createManifestGenerator(args) {
4
4
  let subscribers = new Set();
@@ -1,9 +1,9 @@
1
1
  import { basename } from "node:path";
2
2
  import { cliMode } from "../../cli/cli-mode.js";
3
3
  import { ViewMetaSchema } from "../../types/view-type.js";
4
- import { metaExtractor } from "../../utils/export-extractor.js";
5
- import { formatZodError } from "../../utils/formatZodError.js";
4
+ import { formatZodError } from "../../utils/format-zod-error.js";
6
5
  import { fs } from "../../utils/fs.js";
6
+ import { metaExtractor } from "../../utils/ts-export-extractor.js";
7
7
  import { createManifestGenerator } from "./manifest.js";
8
8
  export function loadViewManifest(project) {
9
9
  return createManifestGenerator({
@@ -1,9 +1,9 @@
1
1
  import { EDConfig } from "./config.js";
2
2
  import { BlockManifestGenerator } from "./manifest/block-manifest.js";
3
- import { ViewManifestGenerator } from "./manifest/view-manifest.js";
4
3
  import { FieldManifestGenerator } from "./manifest/field-manifest.js";
4
+ import { ViewManifestGenerator } from "./manifest/view-manifest.js";
5
5
  import { WidgetManifestGenerator } from "./manifest/widget-manifest.js";
6
- export declare const projectLog: import("../utils/statefulLog.js").StatefulLog<Project>;
6
+ export declare const projectLog: import("../utils/stateful-log.js").StatefulLog<Project>;
7
7
  type ProjectArgs = {
8
8
  rootDir: string;
9
9
  reportPluginCompatibility?: boolean;
@@ -18,6 +18,7 @@ export declare class Project {
18
18
  publicUrl: string;
19
19
  repoUrl: string;
20
20
  configFile: string;
21
+ origin: string;
21
22
  config?: EDConfig;
22
23
  blocks: BlockManifestGenerator;
23
24
  views: ViewManifestGenerator;
@@ -1,19 +1,16 @@
1
- import * as clack from "@clack/prompts";
1
+ import { objFormat } from "obj-console";
2
2
  import { relative, resolve } from "path";
3
3
  import { undent } from "undent";
4
- import { cliMode } from "../cli/cli-mode.js";
5
- // import { console } from "../utils/console.js"
6
- import { objFormat } from "obj-console";
7
- import { getRepoInfo } from "../utils/getRepoInfo.js";
8
- import { isDeploying } from "../utils/isDeploying.js";
9
- import { createConsole } from "../utils/statefulLog.js";
4
+ import { getRepoInfo } from "../utils/get-repo-info.js";
5
+ import { isDeploying } from "../utils/is-deploying.js";
6
+ import { createConsole } from "../utils/stateful-log.js";
10
7
  import { Configurator } from "./config.js";
11
- import { loadBlockManifest } from "./manifest/block-manifest.js";
12
- import { loadViewManifest } from "./manifest/view-manifest.js";
13
- import { WPInfo } from "./wp-info.js";
14
8
  import { ProjectEnvUtils } from "./env.js";
9
+ import { loadBlockManifest } from "./manifest/block-manifest.js";
15
10
  import { loadFieldManifest } from "./manifest/field-manifest.js";
11
+ import { loadViewManifest } from "./manifest/view-manifest.js";
16
12
  import { loadWidgetManifest } from "./manifest/widget-manifest.js";
13
+ import { WPInfo } from "./wp-info.js";
17
14
  const console = createConsole("Project", "project");
18
15
  export const projectLog = console;
19
16
  /**
@@ -26,6 +23,7 @@ export class Project {
26
23
  publicUrl = "";
27
24
  repoUrl = "";
28
25
  configFile = "";
26
+ origin = "";
29
27
  config;
30
28
  blocks;
31
29
  views;
@@ -35,6 +33,7 @@ export class Project {
35
33
  reportPluginCompatibility = false;
36
34
  constructor(opts) {
37
35
  this.rootDir = opts.rootDir;
36
+ this.origin = ProjectEnvUtils.get("SITE_URL");
38
37
  this.reportPluginCompatibility = opts.reportPluginCompatibility || false;
39
38
  this.blocks = loadBlockManifest(this);
40
39
  this.views = loadViewManifest(this);
@@ -62,15 +61,14 @@ export class Project {
62
61
 
63
62
  You should rename the folder to match the repo name, or vice versa.
64
63
  `);
65
- if (cliMode.interactive) {
66
- await clack.confirm({
67
- message: `Ignore and continue anyway?`,
68
- });
69
- }
70
- else {
71
- console.flush();
72
- process.exit(1);
73
- }
64
+ // if (cliMode.interactive) {
65
+ // await clack.confirm({
66
+ // message: `Ignore and continue anyway?`,
67
+ // })
68
+ // } else {
69
+ // console.flush()
70
+ // process.exit(1)
71
+ // }
74
72
  }
75
73
  /**
76
74
  * Load configuration
@@ -1,5 +1,4 @@
1
1
  import { resolveURL } from "ufo";
2
- import { getUnsafeFetch } from "../utils/unsafe-fetch.js";
3
2
  export class WPInfo {
4
3
  siteUrl;
5
4
  cached;
@@ -10,7 +9,6 @@ export class WPInfo {
10
9
  if (this.cached && !force)
11
10
  return this.cached;
12
11
  const url = resolveURL(this.siteUrl, "/wp-json/ed/v1/dev/site-info");
13
- const fetch = getUnsafeFetch(this.siteUrl);
14
12
  const response = await fetch(url);
15
13
  const result = (await response.json());
16
14
  this.cached = result;