eddev 2.0.0-beta.6 → 2.0.0-beta.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/app/entry/MetaTags.d.ts +7 -0
  2. package/dist/app/entry/MetaTags.js +17 -0
  3. package/dist/app/entry/boot-admin.d.ts +1 -0
  4. package/dist/app/entry/boot-admin.js +14 -0
  5. package/dist/app/entry/spa-root.d.ts +1 -0
  6. package/dist/app/entry/spa-root.js +8 -0
  7. package/dist/app/entry/ssr-root-client.d.ts +6 -0
  8. package/dist/app/entry/ssr-root-client.js +26 -0
  9. package/dist/app/entry/ssr-root.d.ts +10 -0
  10. package/dist/app/entry/ssr-root.js +23 -0
  11. package/dist/app/lib/admin/index.d.ts +2 -2
  12. package/dist/app/lib/admin/index.js +2 -2
  13. package/dist/app/lib/admin/installFieldTypes.js +1 -1
  14. package/dist/app/lib/admin/runWidgets.js +1 -1
  15. package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
  16. package/dist/app/lib/blocks/ContentBlocks.js +5 -5
  17. package/dist/app/lib/blocks/EditableText.d.ts +1 -1
  18. package/dist/app/lib/blocks/EditableText.js +3 -3
  19. package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
  20. package/dist/app/lib/blocks/InnerBlocks.js +13 -5
  21. package/dist/app/lib/blocks/block-utils.d.ts +2 -2
  22. package/dist/app/lib/blocks/block-utils.js +2 -2
  23. package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
  24. package/dist/app/lib/blocks/editor/editor-config.d.ts +16 -3
  25. package/dist/app/lib/blocks/editor/editor-config.js +2 -4
  26. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +17 -13
  27. package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
  28. package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
  29. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  30. package/dist/app/lib/blocks/index.d.ts +9 -9
  31. package/dist/app/lib/blocks/index.js +9 -9
  32. package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
  33. package/dist/app/lib/blocks/inline-editing.js +7 -5
  34. package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
  35. package/dist/app/lib/devtools/components/DevUI.js +4 -3
  36. package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
  37. package/dist/app/lib/devtools/components/GridIndicator.js +24 -0
  38. package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
  39. package/dist/app/lib/devtools/dev-tools-store.js +8 -0
  40. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
  41. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  42. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1094 -1095
  43. package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
  44. package/dist/app/lib/devtools/index.d.ts +1 -0
  45. package/dist/app/lib/devtools/index.js +1 -1
  46. package/dist/app/lib/devtools/loader.js +8 -7
  47. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  48. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  49. package/dist/app/lib/dynamic/index.d.ts +1 -1
  50. package/dist/app/lib/dynamic/index.js +1 -1
  51. package/dist/app/lib/hooks/index.d.ts +4 -5
  52. package/dist/app/lib/hooks/index.js +4 -5
  53. package/dist/app/lib/hooks/queryUtils.d.ts +37 -3
  54. package/dist/app/lib/hooks/queryUtils.js +63 -26
  55. package/dist/app/lib/hooks/useAppData.js +1 -1
  56. package/dist/app/lib/hooks/useRPC.d.ts +0 -4
  57. package/dist/app/lib/hooks/useRPC.js +1 -8
  58. package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
  59. package/dist/app/lib/internal/finalize-rpc.js +3 -0
  60. package/dist/app/lib/internal/index.d.ts +5 -4
  61. package/dist/app/lib/internal/index.js +5 -4
  62. package/dist/app/lib/internal/internal-store.d.ts +0 -2
  63. package/dist/app/lib/internal/internal-store.js +1 -3
  64. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  65. package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
  66. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  67. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  68. package/dist/app/lib/legacy-stitches/index.js +1 -1
  69. package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
  70. package/dist/app/lib/routing/components/BackButton.js +47 -0
  71. package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
  72. package/dist/app/lib/routing/components/BrowserRouter.js +79 -11
  73. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  74. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  75. package/dist/app/lib/routing/components/Link.js +9 -10
  76. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  77. package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
  78. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  79. package/dist/app/lib/routing/components/SSRRouter.js +5 -6
  80. package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
  81. package/dist/app/lib/routing/context.d.ts +8 -5
  82. package/dist/app/lib/routing/context.js +13 -96
  83. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
  84. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  85. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
  86. package/dist/app/lib/routing/hooks/useRoute.js +22 -1
  87. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
  88. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  89. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  90. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  91. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  92. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  93. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  94. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  95. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  96. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  97. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  98. package/dist/app/lib/routing/index.d.ts +14 -13
  99. package/dist/app/lib/routing/index.js +14 -13
  100. package/dist/app/lib/routing/loader.d.ts +2 -2
  101. package/dist/app/lib/routing/loader.js +7 -5
  102. package/dist/app/lib/routing/types.d.ts +35 -9
  103. package/dist/app/lib/routing/utils.d.ts +3 -1
  104. package/dist/app/lib/routing/utils.js +12 -1
  105. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
  106. package/dist/app/lib/runtime/apiConfig.js +6 -0
  107. package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
  108. package/dist/app/lib/runtime/errorHandling.js +6 -0
  109. package/dist/app/lib/runtime/index.d.ts +2 -0
  110. package/dist/app/lib/runtime/index.js +2 -0
  111. package/dist/app/lib/views/index.d.ts +1 -1
  112. package/dist/app/lib/views/index.js +1 -1
  113. package/dist/app/server/defineRouter.d.ts +2 -0
  114. package/dist/app/server/defineRouter.js +4 -0
  115. package/dist/app/server/index.d.ts +5 -0
  116. package/dist/app/server/index.js +5 -0
  117. package/dist/app/server/proxy-wp-admin.d.ts +2 -0
  118. package/dist/app/server/proxy-wp-admin.js +112 -0
  119. package/dist/app/server/render-ssr-page.d.ts +11 -0
  120. package/dist/app/server/render-ssr-page.js +100 -0
  121. package/dist/app/server/rpc.d.ts +56 -0
  122. package/dist/app/server/rpc.js +18 -0
  123. package/dist/app/server/server-context.d.ts +53 -0
  124. package/dist/app/server/server-context.js +149 -0
  125. package/dist/app/server/utils/headers.d.ts +1 -0
  126. package/dist/app/server/utils/headers.js +17 -0
  127. package/dist/app/server/utils/replace-host.d.ts +6 -4
  128. package/dist/app/server/utils/replace-host.js +58 -11
  129. package/dist/app/utils/APIProvider.d.ts +2 -0
  130. package/dist/app/utils/APIProvider.js +5 -0
  131. package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
  132. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  133. package/dist/app/utils/ErrorMessage.d.ts +5 -0
  134. package/dist/app/utils/ErrorMessage.js +14 -0
  135. package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
  136. package/dist/app/utils/RouteErrorBoundary.js +38 -0
  137. package/dist/app/utils/query-client.d.ts +2 -0
  138. package/dist/app/utils/query-client.js +5 -1
  139. package/dist/app/utils/trpc-client.d.ts +2 -0
  140. package/dist/app/utils/trpc-client.js +34 -0
  141. package/dist/node/cli/cli-worker.d.ts +1 -1
  142. package/dist/node/cli/cli-worker.js +12 -3
  143. package/dist/node/cli/cli.js +91 -13
  144. package/dist/node/cli/display/CLIApp.d.ts +1 -1
  145. package/dist/node/cli/display/CLIApp.js +4 -7
  146. package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
  147. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
  148. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
  149. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
  150. package/dist/node/cli/display/tools/cli-tools.js +9 -9
  151. package/dist/node/cli/display/util/colors.d.ts +2 -2
  152. package/dist/node/cli/version.d.ts +1 -1
  153. package/dist/node/cli/version.js +1 -1
  154. package/dist/node/compiler/build-vinxi.d.ts +8 -0
  155. package/dist/node/compiler/build-vinxi.js +38 -0
  156. package/dist/node/compiler/bundler.admin.d.ts +2 -2
  157. package/dist/node/compiler/bundler.admin.js +3 -4
  158. package/dist/node/compiler/bundler.frontend.d.ts +1 -1
  159. package/dist/node/compiler/bundler.frontend.js +3 -4
  160. package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
  161. package/dist/node/compiler/dev-server.js +106 -0
  162. package/dist/node/compiler/get-vite-config.d.ts +19 -0
  163. package/dist/node/compiler/get-vite-config.js +200 -0
  164. package/dist/node/compiler/vinxi-app.d.ts +20 -0
  165. package/dist/node/compiler/vinxi-app.js +186 -0
  166. package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
  167. package/dist/node/compiler/vinxi-codegen.js +515 -0
  168. package/dist/node/graphql/graphql-codegen.d.ts +12 -2
  169. package/dist/node/graphql/graphql-codegen.js +213 -36
  170. package/dist/node/graphql/graphql-schema-loader.js +15 -18
  171. package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
  172. package/dist/node/graphql/query-files-loader.d.ts +3 -0
  173. package/dist/node/graphql/query-files-loader.js +5 -0
  174. package/dist/node/project/config.d.ts +31 -37
  175. package/dist/node/project/config.js +13 -11
  176. package/dist/node/project/env.d.ts +1 -1
  177. package/dist/node/project/env.js +1 -1
  178. package/dist/node/project/manifest/block-manifest.js +3 -2
  179. package/dist/node/project/manifest/manifest.d.ts +2 -1
  180. package/dist/node/project/manifest/manifest.js +15 -11
  181. package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
  182. package/dist/node/project/manifest/routes-manifest.js +74 -0
  183. package/dist/node/project/manifest/view-manifest.js +2 -2
  184. package/dist/node/project/project.d.ts +5 -2
  185. package/dist/node/project/project.js +21 -20
  186. package/dist/node/project/wp-info.js +3 -2
  187. package/dist/node/types/block-type.d.ts +5 -0
  188. package/dist/node/types/block-type.js +1 -0
  189. package/dist/node/types/view-type.js +3 -4
  190. package/dist/node/utils/fs-codegen.d.ts +42 -0
  191. package/dist/node/utils/fs-codegen.js +98 -0
  192. package/dist/node/utils/fs.js +2 -0
  193. package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
  194. package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
  195. package/dist/node/utils/watch-file-tree.d.ts +25 -0
  196. package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +12 -5
  197. package/package.json +39 -32
  198. package/types.app.d.ts +4 -2
  199. package/types.app.internal.d.ts +2 -2
  200. package/types.node.d.ts +3 -3
  201. package/dist/app/entry/Root.d.ts +0 -1
  202. package/dist/app/entry/Root.js +0 -9
  203. package/dist/app/entry/main.admin.d.ts +0 -3
  204. package/dist/app/entry/main.admin.js +0 -10
  205. package/dist/app/entry/main.frontend.spa.d.ts +0 -3
  206. package/dist/app/entry/main.frontend.spa.js +0 -13
  207. package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
  208. package/dist/app/entry/main.frontend.ssr.js +0 -79
  209. package/dist/app/entry/main.serverless.dev.d.ts +0 -4
  210. package/dist/app/entry/main.serverless.dev.js +0 -21
  211. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  212. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  213. package/dist/app/lib/hooks/apiConfig.js +0 -4
  214. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  215. package/dist/app/lib/hooks/usePageLoad.js +0 -5
  216. package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
  217. package/dist/app/server/create-api-builtin-hono.js +0 -80
  218. package/dist/app/server/create-ssr-hono.d.ts +0 -18
  219. package/dist/app/server/create-ssr-hono.js +0 -104
  220. package/dist/app/server/utils/index.html.d.ts +0 -2
  221. package/dist/app/server/utils/index.html.js +0 -14
  222. package/dist/node/compiler/index.html.d.ts +0 -2
  223. package/dist/node/compiler/index.html.js +0 -15
  224. package/dist/node/compiler/serverless.dev.js +0 -222
  225. package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
  226. package/dist/node/compiler/vite/get-vite-config.js +0 -315
  227. package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
  228. package/dist/node/compiler/vite/plugin-admin.js +0 -67
  229. package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
  230. package/dist/node/compiler/vite/plugin-blocks.js +0 -73
  231. package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
  232. package/dist/node/compiler/vite/plugin-entry.js +0 -16
  233. package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
  234. package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
  235. package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
  236. package/dist/node/compiler/vite/plugin-theme.js +0 -40
  237. package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
  238. package/dist/node/compiler/vite/plugin-views.js +0 -51
  239. package/dist/node/utils/console.d.ts +0 -21
  240. package/dist/node/utils/console.js +0 -28
  241. package/dist/node/utils/unsafe-fetch.d.ts +0 -2
  242. package/dist/node/utils/unsafe-fetch.js +0 -19
  243. package/dist/node/utils/watchFileTree.d.ts +0 -11
  244. package/tsup.config.ts +0 -40
  245. package/types.manifests.d.ts +0 -22
  246. /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
  247. /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
  248. /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
  249. /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
  250. /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
  251. /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
  252. /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
  253. /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
  254. /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
  255. /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
  256. /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
  257. /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
@@ -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();
@@ -31,20 +31,24 @@ export function createManifestGenerator(args) {
31
31
  }
32
32
  };
33
33
  if (args.watch) {
34
- const disposer = await watchFileTree(args.pattern, (fileList, event) => {
35
- files = fileList;
36
- cache = new Map();
37
- if (args.onFileChange)
38
- fileList.forEach(args.onFileChange);
39
- update();
40
- if (event) {
41
- events.push(event);
42
- }
34
+ const disposer = await watchFileTree({
35
+ pattern: args.pattern,
36
+ ignore: args.ignore,
37
+ callback: (fileList, event) => {
38
+ files = fileList;
39
+ cache = new Map();
40
+ if (args.onFileChange)
41
+ fileList.forEach(args.onFileChange);
42
+ update();
43
+ if (event) {
44
+ events.push(event);
45
+ }
46
+ },
43
47
  });
44
48
  disposers.push(disposer);
45
49
  }
46
50
  else {
47
- files = await getFileTree(args.pattern);
51
+ files = await getFileTree({ pattern: args.pattern, ignore: args.ignore });
48
52
  update();
49
53
  }
50
54
  });
@@ -0,0 +1,20 @@
1
+ import { Project } from "../project.js";
2
+ export type RouteManifest = {
3
+ routes: Record<string, RouteInfo>;
4
+ contextFileName: string | null;
5
+ validationMessages: {
6
+ fieldKey: string;
7
+ message: string;
8
+ severity: "error" | "warning";
9
+ }[];
10
+ bases: string[];
11
+ };
12
+ type RouteInfo = {
13
+ kind: "context" | "route";
14
+ fileName: string;
15
+ prefix?: string;
16
+ error?: string;
17
+ };
18
+ export type RouteManifestGenerator = ReturnType<typeof loadRouteManifest>;
19
+ export declare function loadRouteManifest(project: Project): import("./manifest.js").ManifestGenerator<RouteInfo, RouteManifest>;
20
+ export {};
@@ -0,0 +1,74 @@
1
+ import { cliMode } from "../../cli/cli-mode.js";
2
+ import { createManifestGenerator } from "./manifest.js";
3
+ export function loadRouteManifest(project) {
4
+ return createManifestGenerator({
5
+ baseDir: project.rootDir,
6
+ pattern: ["server/routes/**/*.{ts,tsx}", "server/_context.{ts,tsx}"],
7
+ watch: cliMode.watch,
8
+ async generateManifest(entries) {
9
+ let result = {
10
+ routes: {},
11
+ contextFileName: null,
12
+ validationMessages: [],
13
+ bases: [],
14
+ };
15
+ const bases = new Set();
16
+ Object.entries(entries)
17
+ .sort(([b1], [b2]) => {
18
+ return b1.localeCompare(b2);
19
+ })
20
+ .forEach(([key, entry]) => {
21
+ if (entry.value.kind === "context") {
22
+ result.contextFileName = entry.value.fileName;
23
+ }
24
+ else if (entry.value.kind === "route") {
25
+ const { error: initialError } = entry.value;
26
+ const prefix = entry.value.prefix;
27
+ result.routes[key] = entry.value;
28
+ if (prefix) {
29
+ let shouldAdd = true;
30
+ bases.forEach((base) => {
31
+ if (base.startsWith(prefix)) {
32
+ bases.delete(base);
33
+ }
34
+ else if (prefix.startsWith(base)) {
35
+ shouldAdd = false;
36
+ return;
37
+ }
38
+ });
39
+ if (shouldAdd) {
40
+ bases.add(entry.value.prefix);
41
+ }
42
+ }
43
+ if (initialError) {
44
+ result.validationMessages.push({
45
+ fieldKey: key,
46
+ message: initialError,
47
+ severity: "error",
48
+ });
49
+ return;
50
+ }
51
+ }
52
+ });
53
+ result.bases = [...bases].sort().map((base) => "/" + base.replace(/\./g, "/"));
54
+ return result;
55
+ },
56
+ getKey(path) {
57
+ // Strip the views folder name + extension
58
+ return path.replace(/\.tsx?$/, "").replace(/^server\/routes\//, "");
59
+ },
60
+ async loadValue(fileName, key) {
61
+ if (fileName.startsWith("server/_context.")) {
62
+ return {
63
+ kind: "context",
64
+ fileName,
65
+ };
66
+ }
67
+ return {
68
+ kind: "route",
69
+ prefix: key.replace("/index", "").replace(/\//, "."),
70
+ fileName,
71
+ };
72
+ },
73
+ });
74
+ }
@@ -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,10 @@
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 { RouteManifestGenerator } from "./manifest/routes-manifest.js";
5
+ import { ViewManifestGenerator } from "./manifest/view-manifest.js";
5
6
  import { WidgetManifestGenerator } from "./manifest/widget-manifest.js";
6
- export declare const projectLog: import("../utils/statefulLog.js").StatefulLog<Project>;
7
+ export declare const projectLog: import("../utils/stateful-log.js").StatefulLog<Project>;
7
8
  type ProjectArgs = {
8
9
  rootDir: string;
9
10
  reportPluginCompatibility?: boolean;
@@ -18,11 +19,13 @@ export declare class Project {
18
19
  publicUrl: string;
19
20
  repoUrl: string;
20
21
  configFile: string;
22
+ origin: string;
21
23
  config?: EDConfig;
22
24
  blocks: BlockManifestGenerator;
23
25
  views: ViewManifestGenerator;
24
26
  fields: FieldManifestGenerator;
25
27
  widgets: WidgetManifestGenerator;
28
+ serverRoutes: RouteManifestGenerator;
26
29
  private wp;
27
30
  reportPluginCompatibility: boolean;
28
31
  private constructor();
@@ -1,19 +1,17 @@
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 { loadRouteManifest } from "./manifest/routes-manifest.js";
12
+ import { loadViewManifest } from "./manifest/view-manifest.js";
16
13
  import { loadWidgetManifest } from "./manifest/widget-manifest.js";
14
+ import { WPInfo } from "./wp-info.js";
17
15
  const console = createConsole("Project", "project");
18
16
  export const projectLog = console;
19
17
  /**
@@ -26,21 +24,25 @@ export class Project {
26
24
  publicUrl = "";
27
25
  repoUrl = "";
28
26
  configFile = "";
27
+ origin = "";
29
28
  config;
30
29
  blocks;
31
30
  views;
32
31
  fields;
33
32
  widgets;
33
+ serverRoutes;
34
34
  wp;
35
35
  reportPluginCompatibility = false;
36
36
  constructor(opts) {
37
37
  this.rootDir = opts.rootDir;
38
+ this.origin = ProjectEnvUtils.getSafe("SITE_URL") ?? "";
38
39
  this.reportPluginCompatibility = opts.reportPluginCompatibility || false;
39
40
  this.blocks = loadBlockManifest(this);
40
41
  this.views = loadViewManifest(this);
41
42
  this.fields = loadFieldManifest(this);
42
43
  this.widgets = loadWidgetManifest(this);
43
- this.wp = new WPInfo(ProjectEnvUtils.get("SITE_URL"));
44
+ this.serverRoutes = loadRouteManifest(this);
45
+ this.wp = new WPInfo(this.origin);
44
46
  }
45
47
  async load() {
46
48
  console.setWorking(true);
@@ -62,15 +64,14 @@ export class Project {
62
64
 
63
65
  You should rename the folder to match the repo name, or vice versa.
64
66
  `);
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
- }
67
+ // if (cliMode.interactive) {
68
+ // await clack.confirm({
69
+ // message: `Ignore and continue anyway?`,
70
+ // })
71
+ // } else {
72
+ // console.flush()
73
+ // process.exit(1)
74
+ // }
74
75
  }
75
76
  /**
76
77
  * 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;
@@ -7,10 +6,12 @@ export class WPInfo {
7
6
  this.siteUrl = siteUrl;
8
7
  }
9
8
  async getInfo(force = false) {
9
+ if (!this.siteUrl) {
10
+ throw new Error("Attempted to get site info from WordPress, but SITE_URL was not present in the environment.");
11
+ }
10
12
  if (this.cached && !force)
11
13
  return this.cached;
12
14
  const url = resolveURL(this.siteUrl, "/wp-json/ed/v1/dev/site-info");
13
- const fetch = getUnsafeFetch(this.siteUrl);
14
15
  const response = await fetch(url);
15
16
  const result = (await response.json());
16
17
  this.cached = result;
@@ -23,10 +23,13 @@ export declare const BlockMetaSchema: z.ZodObject<{
23
23
  cache: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
24
24
  allowMultiple: z.ZodDefault<z.ZodBoolean>;
25
25
  postMetaBlock: z.ZodOptional<z.ZodObject<{
26
+ postTypes: z.ZodArray<z.ZodString, "many">;
26
27
  fieldName: z.ZodString;
27
28
  }, "strip", z.ZodTypeAny, {
29
+ postTypes: string[];
28
30
  fieldName: string;
29
31
  }, {
32
+ postTypes: string[];
30
33
  fieldName: string;
31
34
  }>>;
32
35
  frontendMode: z.ZodDefault<z.ZodEnum<["hidden", "childrenOnly", "default"]>>;
@@ -56,6 +59,7 @@ export declare const BlockMetaSchema: z.ZodObject<{
56
59
  keywords?: string[] | undefined;
57
60
  templates?: string[] | null | undefined;
58
61
  postMetaBlock?: {
62
+ postTypes: string[];
59
63
  fieldName: string;
60
64
  } | undefined;
61
65
  }, {
@@ -81,6 +85,7 @@ export declare const BlockMetaSchema: z.ZodObject<{
81
85
  dynamic?: boolean | undefined;
82
86
  allowMultiple?: boolean | undefined;
83
87
  postMetaBlock?: {
88
+ postTypes: string[];
84
89
  fieldName: string;
85
90
  } | undefined;
86
91
  frontendMode?: "hidden" | "childrenOnly" | "default" | undefined;
@@ -27,6 +27,7 @@ export const BlockMetaSchema = z.object({
27
27
  allowMultiple: z.boolean().default(true),
28
28
  postMetaBlock: z
29
29
  .object({
30
+ postTypes: z.array(z.string()),
30
31
  fieldName: z.string(),
31
32
  })
32
33
  .optional(),
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { objFormat } from "obj-console";
3
- import { console } from "../utils/console.js";
4
3
  import chalk from "chalk";
5
4
  import { indent } from "../utils/helpers.js";
6
5
  export const ViewMetaSchema = z.object({
@@ -28,7 +27,7 @@ export function describeView(view) {
28
27
  return output;
29
28
  }
30
29
  export function describeViewManifest(manifest) {
31
- console.heading("View Manifest");
30
+ console.log("View Manifest");
32
31
  console.info("Discovered " + Object.keys(manifest.views).length + " view(s)");
33
32
  const totalWarnings = manifest.validationMessages.filter((m) => m.severity === "warning").length;
34
33
  const totalErrors = manifest.validationMessages.filter((m) => m.severity === "error").length;
@@ -48,7 +47,7 @@ export function describeViewManifest(manifest) {
48
47
  console.log(indent(4, describeView(view)));
49
48
  }
50
49
  if (totalWarnings > 0)
51
- console.failish(totalWarnings + " warning(s) while loading view metadata");
50
+ console.warn(totalWarnings + " warning(s) while loading view metadata");
52
51
  if (totalErrors > 0)
53
- console.fail(totalErrors + " error(s) while loading view metadata");
52
+ console.warn(totalErrors + " error(s) while loading view metadata");
54
53
  }
@@ -0,0 +1,42 @@
1
+ import { Code } from "ts-poet";
2
+ import { Project } from "../project/project.js";
3
+ type VirtualFile = {
4
+ name: string;
5
+ content: string | Code;
6
+ };
7
+ type CodeGenerator = {
8
+ getFiles(): Promise<VirtualFile | VirtualFile[] | null>;
9
+ susbcribe?(callback: () => void): () => void;
10
+ };
11
+ /**
12
+ * A codegen utility that allows you to procedurally and reactively generate files, to be flushed to the FS.
13
+ */
14
+ export declare class FSCodegen {
15
+ project: Project;
16
+ opts: {
17
+ outDir: string;
18
+ onWritten?: (opts: Set<string>) => void;
19
+ };
20
+ outDir: string;
21
+ private generators;
22
+ private generatorFiles;
23
+ private unsubscribers;
24
+ private flushScheduled;
25
+ constructor(project: Project, opts: {
26
+ outDir: string;
27
+ onWritten?: (opts: Set<string>) => void;
28
+ });
29
+ register(generator: CodeGenerator): void;
30
+ registerFile({ name, generate, subscribe, }: {
31
+ name: string;
32
+ generate: (() => string | Code | Promise<string | Code>) | string | Code;
33
+ subscribe?: (callback: () => void) => () => void;
34
+ }): void;
35
+ private runGenerator;
36
+ scheduleFlush(): void;
37
+ runAndWatch(): Promise<void>;
38
+ run(): Promise<void>;
39
+ private flush;
40
+ stop(): void;
41
+ }
42
+ export {};
@@ -0,0 +1,98 @@
1
+ import { Code } from "ts-poet";
2
+ import { globby } from "globby";
3
+ import { fs } from "./fs.js";
4
+ import { join, resolve } from "path";
5
+ /**
6
+ * A codegen utility that allows you to procedurally and reactively generate files, to be flushed to the FS.
7
+ */
8
+ export class FSCodegen {
9
+ project;
10
+ opts;
11
+ outDir;
12
+ generators = new Set();
13
+ generatorFiles = new Map();
14
+ unsubscribers = new Set();
15
+ flushScheduled = false;
16
+ constructor(project, opts) {
17
+ this.project = project;
18
+ this.opts = opts;
19
+ this.outDir = opts.outDir;
20
+ }
21
+ register(generator) {
22
+ this.generators.add(generator);
23
+ }
24
+ registerFile({ name, generate, subscribe, }) {
25
+ this.register({
26
+ async getFiles() {
27
+ return {
28
+ name,
29
+ content: generate instanceof Code ? generate.toString() : typeof generate === "string" ? generate : await generate(),
30
+ };
31
+ },
32
+ susbcribe: subscribe,
33
+ });
34
+ }
35
+ async runGenerator(generator) {
36
+ const files = await generator.getFiles();
37
+ this.generatorFiles.set(generator, files ? (Array.isArray(files) ? files : [files]) : []);
38
+ this.scheduleFlush();
39
+ }
40
+ scheduleFlush() {
41
+ if (this.flushScheduled) {
42
+ return;
43
+ }
44
+ this.flushScheduled = true;
45
+ setTimeout(() => {
46
+ this.flushScheduled = false;
47
+ this.flush();
48
+ }, 100);
49
+ }
50
+ async runAndWatch() {
51
+ await Promise.all(Array.from(this.generators).map((generator) => {
52
+ return new Promise((resolve) => {
53
+ let first = true;
54
+ if (generator.susbcribe) {
55
+ // Subscribe and run at least once
56
+ this.unsubscribers.add(generator.susbcribe(() => {
57
+ if (first) {
58
+ first = false;
59
+ this.runGenerator(generator).then(resolve);
60
+ }
61
+ else {
62
+ this.runGenerator(generator);
63
+ }
64
+ }));
65
+ }
66
+ else {
67
+ // Just run once, since there is no subscriber
68
+ this.runGenerator(generator).then(resolve);
69
+ }
70
+ });
71
+ }));
72
+ await this.flush();
73
+ }
74
+ async run() {
75
+ await Promise.all(Array.from(this.generators).map((generator) => this.runGenerator(generator)));
76
+ await this.flush();
77
+ }
78
+ async flush() {
79
+ const files = Array.from(this.generatorFiles.values()).flat();
80
+ const existing = (await globby(join(this.outDir, "/**/*"))).map((path) => resolve(this.project.rootDir, path));
81
+ const written = new Set();
82
+ await Promise.all(files.map(async (file) => {
83
+ const path = join(this.project.rootDir, this.outDir, file.name);
84
+ written.add(resolve(this.project.rootDir, path));
85
+ await fs.writeIfUnchanged(path, file.content.toString());
86
+ }));
87
+ await Promise.all(existing.map(async (path) => {
88
+ if (!written.has(path)) {
89
+ await fs.rm(path);
90
+ }
91
+ }));
92
+ this.opts.onWritten?.(written);
93
+ }
94
+ stop() {
95
+ this.unsubscribers.forEach((unsub) => unsub());
96
+ this.unsubscribers.clear();
97
+ }
98
+ }
@@ -1,7 +1,9 @@
1
1
  import * as nodeFs from "fs/promises";
2
+ import { dirname } from "path";
2
3
  export const fs = {
3
4
  ...nodeFs,
4
5
  writeIfUnchanged: async (path, content) => {
6
+ await fs.mkdirp(dirname(path));
5
7
  try {
6
8
  const currentContent = await nodeFs.readFile(path, "utf8");
7
9
  if (currentContent === content)
@@ -1,4 +1,4 @@
1
- import { serverlessLog } from "../compiler/serverless.dev.js";
1
+ import { serverlessLog } from "../compiler/dev-server.js";
2
2
  import { fs } from "./fs.js";
3
3
  import { createCA, createCert } from "mkcert";
4
4
  export async function ensureSelfSignedCert(hostname, rootDir) {
@@ -1,5 +1,5 @@
1
1
  import { cliMode } from "../cli/cli-mode.js";
2
- import { eachFormattedZodError } from "./formatZodError.js";
2
+ import { eachFormattedZodError } from "./format-zod-error.js";
3
3
  import chalk from "chalk";
4
4
  let logId = 0;
5
5
  const getID = () => logId++;
@@ -0,0 +1,25 @@
1
+ type FileList = string[];
2
+ type Disposer = () => void;
3
+ export type FileWatchEvent = "added" | "deleted" | "changed";
4
+ export type FileEvent = {
5
+ type: FileWatchEvent;
6
+ file: string;
7
+ };
8
+ type WatchTreeOpts = {
9
+ pattern: string | string[];
10
+ ignore?: string[];
11
+ callback: (files: FileList, event?: FileEvent) => void;
12
+ };
13
+ export declare function watchFileTree({ pattern, callback, ignore }: WatchTreeOpts): Promise<Disposer>;
14
+ type WatchTreeChangesOpts = {
15
+ pattern: string | string[];
16
+ ignore?: string | RegExp | string[];
17
+ callback: (event: FileEvent) => void;
18
+ };
19
+ export declare function watchFileTreeForChanges({ pattern, callback, ignore }: WatchTreeChangesOpts): Promise<Disposer>;
20
+ type GetTreeOpts = {
21
+ pattern: string | string[];
22
+ ignore?: string[];
23
+ };
24
+ export declare function getFileTree(opts: GetTreeOpts): Promise<FileList>;
25
+ export {};
@@ -1,11 +1,13 @@
1
1
  import chokidar from "chokidar";
2
2
  import { globby } from "globby";
3
- export function watchFileTree(pattern, callback) {
3
+ export function watchFileTree({ pattern, callback, ignore }) {
4
4
  const files = [];
5
5
  let ready = false;
6
6
  return new Promise((resolve) => {
7
7
  const watcher = chokidar
8
- .watch(pattern)
8
+ .watch(pattern, {
9
+ ignored: ignore,
10
+ })
9
11
  .on("add", (path) => {
10
12
  files.push(path);
11
13
  if (ready)
@@ -31,7 +33,7 @@ export function watchFileTree(pattern, callback) {
31
33
  });
32
34
  });
33
35
  }
34
- export function watchFileTreeForChanges(pattern, callback) {
36
+ export function watchFileTreeForChanges({ pattern, callback, ignore }) {
35
37
  let ready = false;
36
38
  return new Promise((resolve) => {
37
39
  const watcher = chokidar
@@ -50,9 +52,14 @@ export function watchFileTreeForChanges(pattern, callback) {
50
52
  })
51
53
  .on("ready", () => {
52
54
  ready = true;
55
+ resolve(() => {
56
+ watcher.close();
57
+ });
53
58
  });
54
59
  });
55
60
  }
56
- export function getFileTree(pattern) {
57
- return globby(pattern);
61
+ export function getFileTree(opts) {
62
+ return globby(opts.pattern, {
63
+ ignore: opts.ignore,
64
+ });
58
65
  }