eddev 2.0.0-beta.4 → 2.0.0-beta.41

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 (218) 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/{main.admin.js → boot-admin.js} +3 -5
  5. package/dist/app/entry/spa-root.d.ts +1 -0
  6. package/dist/app/entry/{Root.js → spa-root.js} +4 -4
  7. package/dist/app/entry/ssr-root-client.d.ts +6 -0
  8. package/dist/app/entry/ssr-root-client.js +16 -0
  9. package/dist/app/entry/ssr-root.d.ts +10 -0
  10. package/dist/app/entry/ssr-root.js +24 -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.js +4 -4
  16. package/dist/app/lib/blocks/EditableText.d.ts +1 -1
  17. package/dist/app/lib/blocks/EditableText.js +3 -3
  18. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +1 -0
  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 +3 -3
  24. package/dist/app/lib/blocks/editor/editor-config.d.ts +1 -1
  25. package/dist/app/lib/blocks/editor/editor-config.js +1 -1
  26. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +5 -5
  27. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  28. package/dist/app/lib/blocks/index.d.ts +9 -9
  29. package/dist/app/lib/blocks/index.js +9 -9
  30. package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
  31. package/dist/app/lib/blocks/inline-editing.js +7 -5
  32. package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
  33. package/dist/app/lib/devtools/components/DevUI.js +4 -3
  34. package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
  35. package/dist/app/lib/devtools/components/GridIndicator.js +24 -0
  36. package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
  37. package/dist/app/lib/devtools/dev-tools-store.js +8 -0
  38. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
  39. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  40. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1078 -1079
  41. package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
  42. package/dist/app/lib/devtools/index.d.ts +1 -0
  43. package/dist/app/lib/devtools/index.js +1 -1
  44. package/dist/app/lib/devtools/loader.js +8 -7
  45. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  46. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  47. package/dist/app/lib/dynamic/index.d.ts +1 -1
  48. package/dist/app/lib/dynamic/index.js +1 -1
  49. package/dist/app/lib/hooks/apiConfig.d.ts +3 -1
  50. package/dist/app/lib/hooks/apiConfig.js +9 -4
  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 +5 -2
  54. package/dist/app/lib/hooks/queryUtils.js +19 -20
  55. package/dist/app/lib/hooks/useAppData.js +1 -1
  56. package/dist/app/lib/internal/index.d.ts +4 -4
  57. package/dist/app/lib/internal/index.js +4 -4
  58. package/dist/app/lib/internal/internal-store.d.ts +0 -2
  59. package/dist/app/lib/internal/internal-store.js +1 -3
  60. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  61. package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
  62. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  63. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  64. package/dist/app/lib/legacy-stitches/index.js +1 -1
  65. package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
  66. package/dist/app/lib/routing/components/BackButton.js +47 -0
  67. package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
  68. package/dist/app/lib/routing/components/BrowserRouter.js +68 -11
  69. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  70. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  71. package/dist/app/lib/routing/components/Link.js +9 -10
  72. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  73. package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
  74. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  75. package/dist/app/lib/routing/components/SSRRouter.js +5 -6
  76. package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
  77. package/dist/app/lib/routing/context.d.ts +2 -2
  78. package/dist/app/lib/routing/context.js +6 -96
  79. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  80. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
  81. package/dist/app/lib/routing/hooks/useRoute.js +22 -1
  82. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
  83. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  84. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  85. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  86. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  87. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  88. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  89. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  90. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  91. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  92. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  93. package/dist/app/lib/routing/index.d.ts +14 -13
  94. package/dist/app/lib/routing/index.js +14 -13
  95. package/dist/app/lib/routing/loader.d.ts +2 -2
  96. package/dist/app/lib/routing/loader.js +7 -5
  97. package/dist/app/lib/routing/types.d.ts +28 -8
  98. package/dist/app/lib/routing/utils.d.ts +3 -1
  99. package/dist/app/lib/routing/utils.js +11 -0
  100. package/dist/app/lib/views/index.d.ts +1 -1
  101. package/dist/app/lib/views/index.js +1 -1
  102. package/dist/app/server/defineRouter.d.ts +2 -0
  103. package/dist/app/server/defineRouter.js +4 -0
  104. package/dist/app/server/index.d.ts +4 -0
  105. package/dist/app/server/index.js +4 -0
  106. package/dist/app/server/proxy-wp-admin.d.ts +3 -0
  107. package/dist/app/server/proxy-wp-admin.js +105 -0
  108. package/dist/app/server/render-ssr-page.d.ts +5 -0
  109. package/dist/app/server/render-ssr-page.js +31 -0
  110. package/dist/app/server/server-context.d.ts +50 -0
  111. package/dist/app/server/server-context.js +145 -0
  112. package/dist/app/server/utils/headers.d.ts +1 -0
  113. package/dist/app/server/utils/headers.js +17 -0
  114. package/dist/app/server/utils/replace-host.d.ts +6 -4
  115. package/dist/app/server/utils/replace-host.js +58 -11
  116. package/dist/node/cli/cli-worker.d.ts +1 -1
  117. package/dist/node/cli/cli-worker.js +7 -2
  118. package/dist/node/cli/cli.js +84 -12
  119. package/dist/node/cli/display/CLIApp.d.ts +1 -1
  120. package/dist/node/cli/display/CLIApp.js +3 -6
  121. package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
  122. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
  123. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
  124. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
  125. package/dist/node/cli/display/tools/cli-tools.js +9 -9
  126. package/dist/node/cli/display/util/colors.d.ts +2 -2
  127. package/dist/node/cli/version.d.ts +1 -1
  128. package/dist/node/cli/version.js +1 -1
  129. package/dist/node/compiler/build-vinxi.d.ts +8 -0
  130. package/dist/node/compiler/build-vinxi.js +37 -0
  131. package/dist/node/compiler/bundler.admin.d.ts +2 -2
  132. package/dist/node/compiler/bundler.admin.js +3 -4
  133. package/dist/node/compiler/bundler.frontend.d.ts +1 -1
  134. package/dist/node/compiler/bundler.frontend.js +3 -4
  135. package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
  136. package/dist/node/compiler/dev-server.js +105 -0
  137. package/dist/node/compiler/get-vite-config.d.ts +19 -0
  138. package/dist/node/compiler/get-vite-config.js +200 -0
  139. package/dist/node/compiler/vinxi-app.d.ts +19 -0
  140. package/dist/node/compiler/vinxi-app.js +159 -0
  141. package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
  142. package/dist/node/compiler/vinxi-codegen.js +464 -0
  143. package/dist/node/graphql/graphql-codegen.d.ts +1 -1
  144. package/dist/node/graphql/graphql-codegen.js +63 -16
  145. package/dist/node/graphql/graphql-schema-loader.js +15 -18
  146. package/dist/node/project/config.js +1 -1
  147. package/dist/node/project/env.d.ts +1 -1
  148. package/dist/node/project/env.js +1 -1
  149. package/dist/node/project/manifest/block-manifest.js +2 -2
  150. package/dist/node/project/manifest/manifest.d.ts +1 -1
  151. package/dist/node/project/manifest/manifest.js +1 -1
  152. package/dist/node/project/manifest/view-manifest.js +2 -2
  153. package/dist/node/project/project.d.ts +3 -2
  154. package/dist/node/project/project.js +18 -20
  155. package/dist/node/project/wp-info.js +3 -2
  156. package/dist/node/types/view-type.js +3 -4
  157. package/dist/node/utils/fs-codegen.d.ts +40 -0
  158. package/dist/node/utils/fs-codegen.js +97 -0
  159. package/dist/node/utils/fs.js +2 -0
  160. package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
  161. package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
  162. package/package.json +31 -32
  163. package/types.app.d.ts +2 -2
  164. package/types.app.internal.d.ts +2 -2
  165. package/types.node.d.ts +3 -3
  166. package/dist/app/entry/Root.d.ts +0 -1
  167. package/dist/app/entry/main.admin.d.ts +0 -3
  168. package/dist/app/entry/main.frontend.spa.d.ts +0 -3
  169. package/dist/app/entry/main.frontend.spa.js +0 -13
  170. package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
  171. package/dist/app/entry/main.frontend.ssr.js +0 -79
  172. package/dist/app/entry/main.serverless.dev.d.ts +0 -4
  173. package/dist/app/entry/main.serverless.dev.js +0 -21
  174. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  175. package/dist/app/lib/hooks/usePageLoad.js +0 -5
  176. package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
  177. package/dist/app/server/create-api-builtin-hono.js +0 -80
  178. package/dist/app/server/create-ssr-hono.d.ts +0 -18
  179. package/dist/app/server/create-ssr-hono.js +0 -104
  180. package/dist/app/server/utils/index.html.d.ts +0 -2
  181. package/dist/app/server/utils/index.html.js +0 -14
  182. package/dist/node/compiler/index.html.d.ts +0 -2
  183. package/dist/node/compiler/index.html.js +0 -15
  184. package/dist/node/compiler/serverless.dev.js +0 -215
  185. package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
  186. package/dist/node/compiler/vite/get-vite-config.js +0 -323
  187. package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
  188. package/dist/node/compiler/vite/plugin-admin.js +0 -67
  189. package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
  190. package/dist/node/compiler/vite/plugin-blocks.js +0 -73
  191. package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
  192. package/dist/node/compiler/vite/plugin-entry.js +0 -16
  193. package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
  194. package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
  195. package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
  196. package/dist/node/compiler/vite/plugin-theme.js +0 -40
  197. package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
  198. package/dist/node/compiler/vite/plugin-views.js +0 -51
  199. package/dist/node/utils/console.d.ts +0 -21
  200. package/dist/node/utils/console.js +0 -28
  201. package/dist/node/utils/unsafe-fetch.d.ts +0 -2
  202. package/dist/node/utils/unsafe-fetch.js +0 -19
  203. package/tsup.config.ts +0 -40
  204. package/types.manifests.d.ts +0 -22
  205. /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
  206. /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
  207. /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
  208. /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
  209. /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
  210. /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
  211. /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
  212. /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
  213. /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
  214. /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
  215. /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
  216. /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
  217. /package/dist/node/utils/{watchFileTree.d.ts → watch-file-tree.d.ts} +0 -0
  218. /package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +0 -0
@@ -0,0 +1,200 @@
1
+ import * as t from "@babel/types";
2
+ import replace from "@rollup/plugin-replace";
3
+ import react from "@vitejs/plugin-react";
4
+ import { pascalCase } from "change-case-all";
5
+ import { withoutTrailingSlash } from "ufo";
6
+ import { createLogger } from "vite";
7
+ import tsconfigPaths from "vite-tsconfig-paths";
8
+ import { cliMode } from "../cli/cli-mode.js";
9
+ export function envPlugin(args) {
10
+ const envDefines = {
11
+ client: args.serverless ? "!import.meta.env.SSR" : "true",
12
+ serverless: args.serverless ? "true" : "false",
13
+ dev: args.mode === "development" ? "true" : "false",
14
+ admin: args.target === "cms" ? "true" : "false",
15
+ themePath: JSON.stringify(args.publicUrl),
16
+ devUI: args.mode === "development" ? "true" : "false",
17
+ serverlessOrigin: JSON.stringify("http://serverleress-endpoint"),
18
+ rpcEnabled: "false",
19
+ origin: JSON.stringify(process.env.SITE_URL ?? "/"),
20
+ };
21
+ const expandDefines = (obj, prefixes = []) => {
22
+ const result = {};
23
+ for (const prefix of prefixes) {
24
+ for (const [key, value] of Object.entries(obj)) {
25
+ result[prefix + key] = value;
26
+ }
27
+ }
28
+ return result;
29
+ };
30
+ return replace({
31
+ values: expandDefines(envDefines, ["process.env.", "process.", "env."]),
32
+ preventAssignment: true,
33
+ });
34
+ }
35
+ export function reactPlugin() {
36
+ return react({
37
+ babel: {
38
+ overrides: [{ test: /types\./, compact: true }],
39
+ plugins: [
40
+ {
41
+ visitor: {
42
+ ExportNamedDeclaration: (path) => {
43
+ const decl = path.node.declaration;
44
+ if (decl?.type !== "VariableDeclaration")
45
+ return;
46
+ const id = decl.declarations[0].id;
47
+ if (!t.isIdentifier(id))
48
+ return;
49
+ if (id.name === "meta") {
50
+ path.remove();
51
+ }
52
+ },
53
+ ExportDefaultDeclaration: (path) => {
54
+ if (!path.hub.file.opts.filename.match(/\/(blocks|views)\//))
55
+ return;
56
+ if (path.node.declaration.type === "CallExpression") {
57
+ const call = path.node.declaration;
58
+ if (call.callee.type === "Identifier" && ["defineBlock", "defineView"].includes(call.callee.name)) {
59
+ const type = call.callee.name.replace("define", "");
60
+ const args = call.arguments;
61
+ if (args.length === 2 &&
62
+ args[0].type === "StringLiteral" &&
63
+ args[1].type === "ArrowFunctionExpression") {
64
+ const name = args[0].value;
65
+ let body = args[1].body;
66
+ if (t.isExpression(body)) {
67
+ body = t.blockStatement([t.returnStatement(body)]);
68
+ }
69
+ path.replaceWith(t.exportDefaultDeclaration(t.functionDeclaration(t.identifier(pascalCase(type + "-" + name)), args[1].params, body, args[1].generator, args[1].async)));
70
+ }
71
+ }
72
+ }
73
+ },
74
+ },
75
+ },
76
+ ],
77
+ },
78
+ });
79
+ }
80
+ /**
81
+ * Turns on SSR module proxying,
82
+ */
83
+ export function ssrPlugin() {
84
+ return {
85
+ name: "proxy-external-ssr-modules",
86
+ config(config) {
87
+ config.legacy = {
88
+ ...config.legacy,
89
+ proxySsrExternalModules: true,
90
+ };
91
+ config.ssr = {
92
+ ...config.ssr,
93
+ // @ts-ignore
94
+ noExternal: ["eddev", "vinxi", "react-use", ...(config?.optimizeDeps?.noExternal ?? [])],
95
+ optimizeDeps: {
96
+ exclude: ["eddev", "vinxi"],
97
+ },
98
+ };
99
+ config.optimizeDeps = {
100
+ ...config.optimizeDeps,
101
+ include: [
102
+ "valtio",
103
+ "@tanstack/react-query",
104
+ "qs",
105
+ "react",
106
+ "react-dom/client",
107
+ ...(config?.optimizeDeps?.include ?? []),
108
+ ],
109
+ exclude: ["eddev", "vinxi", ...(config?.optimizeDeps?.exclude ?? [])],
110
+ };
111
+ return config;
112
+ },
113
+ };
114
+ }
115
+ function buildStatusPlugin(console) {
116
+ let timer = 0;
117
+ return {
118
+ name: "eddev:logging",
119
+ enforce: "post",
120
+ watchChange() {
121
+ console.resetLog();
122
+ clearTimeout(timer);
123
+ },
124
+ buildStart() {
125
+ clearTimeout(timer);
126
+ console.setWorking(true);
127
+ },
128
+ buildEnd() {
129
+ clearTimeout(timer);
130
+ timer = setTimeout(() => {
131
+ console.setWorking(false);
132
+ }, 0);
133
+ },
134
+ };
135
+ }
136
+ export function corePlugins(args) {
137
+ return [args.serverless && ssrPlugin(), envPlugin(args), tsconfigPaths(), reactPlugin()].flat();
138
+ }
139
+ export function getViteConfig(args) {
140
+ const console = args.console;
141
+ const logger = createLogger();
142
+ logger.info = (msg) => args.console.info(msg.replace(/\n/, ""));
143
+ logger.warn = (msg) => {
144
+ if (typeof msg === "string" && msg.includes("Error when using sourcemap for reporting"))
145
+ return;
146
+ return args.console.warn(msg.replace(/\n/, ""));
147
+ };
148
+ logger.error = (msg) => args.console.fail(msg.replace(/\n/, ""));
149
+ logger.warnOnce = (msg) => args.console.warn(msg.replace(/\n/, ""));
150
+ logger.clearScreen = () => {
151
+ args.console.resetLog();
152
+ };
153
+ /** Initial config */
154
+ const config = {
155
+ appType: "custom",
156
+ mode: args.mode,
157
+ root: args.rootDir,
158
+ customLogger: logger,
159
+ logLevel: cliMode.verbose ? "info" : "warn",
160
+ base: withoutTrailingSlash(args.publicUrl) + "/dist/" + args.target,
161
+ define: {
162
+ "process.env.NODE_ENV": JSON.stringify(args.mode),
163
+ },
164
+ plugins: [tsconfigPaths(), envPlugin(args), reactPlugin(), buildStatusPlugin(console)],
165
+ build: {
166
+ manifest: true,
167
+ sourcemap: true,
168
+ minify: args.mode === "production",
169
+ modulePreload: false,
170
+ outDir: args.outDir,
171
+ // watch: {},
172
+ rollupOptions: {
173
+ input: `./.eddev/${args.mode === "production" ? "prod" : "dev"}-spa/entry.${args.target === "cms" ? "admin" : "client"}.tsx`,
174
+ external: args.target === "cms" ? ["react", "react-dom"] : [],
175
+ onwarn(warning, warn) {
176
+ if (!cliMode.verbose &&
177
+ warning.code &&
178
+ ["SOURCEMAP_ERROR", "UNUSED_EXTERNAL_IMPORT", "INVALID_ANNOTATION", "EVAL"].includes(warning.code)) {
179
+ return;
180
+ }
181
+ if (warning.code) {
182
+ warning.message = warning.code + ": " + warning.message;
183
+ }
184
+ warn(warning);
185
+ },
186
+ output: args.target === "cms"
187
+ ? {
188
+ entryFileNames: "main.admin.js",
189
+ format: "iife",
190
+ globals: {
191
+ react: "window.React",
192
+ "react-dom": "window.ReactDOM",
193
+ },
194
+ }
195
+ : undefined,
196
+ },
197
+ },
198
+ };
199
+ return config;
200
+ }
@@ -0,0 +1,19 @@
1
+ import { StatefulLog } from "../utils/stateful-log.js";
2
+ export type AppArgs = {
3
+ mode: "development" | "production";
4
+ publicUrl: string;
5
+ rootDir: string;
6
+ origin: string;
7
+ log?: StatefulLog<any>;
8
+ preset?: string;
9
+ routes?: CustomRoute[];
10
+ };
11
+ type HTTPMethod = "GET" | "POST" | "PUT" | "OPTIONS" | "HEAD";
12
+ type CustomRouteFunction = (req: Request) => Response;
13
+ type CustomRouteModule = Record<HTTPMethod, CustomRouteFunction>;
14
+ type CustomRoute = {
15
+ pattern: string;
16
+ handler: () => Promise<CustomRouteModule>;
17
+ };
18
+ export declare function createVinxiApp(args: AppArgs): import("vinxi").App;
19
+ export {};
@@ -0,0 +1,159 @@
1
+ import { joinURL } from "ufo";
2
+ import { createApp } from "vinxi";
3
+ import tsconfigPaths from "vite-tsconfig-paths";
4
+ import { StatefulLog } from "../utils/stateful-log.js";
5
+ import { corePlugins, envPlugin } from "./get-vite-config.js";
6
+ import { getVinxiFolder } from "./vinxi-codegen.js";
7
+ export function createVinxiApp(args) {
8
+ const log = args.log ?? new StatefulLog({ label: "Build" });
9
+ const folder = "./.eddev/" +
10
+ getVinxiFolder({
11
+ mode: args.mode,
12
+ serverless: true,
13
+ });
14
+ return createApp({
15
+ server: {
16
+ // experimental: {
17
+ // websocket: true,
18
+ // },
19
+ preset: args.preset,
20
+ routeRules: {
21
+ "/wp-content/uploads/**": {
22
+ proxy: joinURL(args.origin, "wp-content/uploads/**"),
23
+ cache: {
24
+ maxAge: 86400,
25
+ varies: [],
26
+ },
27
+ },
28
+ "/wp-content/plugins/**": {
29
+ proxy: joinURL(args.origin, "wp-content/plugins/**"),
30
+ headers: {
31
+ "Cache-Control": "max-age=86400",
32
+ "CDN-Cache-Control": "max-age=86400",
33
+ "Vercel-CDN-Cache-Control": "max-age=86400",
34
+ },
35
+ },
36
+ "/wp-content/**": { proxy: joinURL(args.origin, "wp-content/**") },
37
+ "/wp-includes/**": { proxy: joinURL(args.origin, "wp-includes/**") },
38
+ "/_data/route/**": {
39
+ isr: 300,
40
+ swr: true,
41
+ cache: {
42
+ maxAge: 300,
43
+ swr: true,
44
+ varies: ["Authorization", "woocommerce-session"],
45
+ },
46
+ },
47
+ "/_data/query/**": {
48
+ swr: true,
49
+ cache: {
50
+ maxAge: 300,
51
+ swr: true,
52
+ },
53
+ },
54
+ "/**/*": {
55
+ isr: 300,
56
+ swr: true,
57
+ cache: {
58
+ maxAge: 300,
59
+ swr: true,
60
+ },
61
+ },
62
+ },
63
+ },
64
+ routers: [
65
+ {
66
+ name: "public",
67
+ type: "static",
68
+ dir: "./assets",
69
+ base: joinURL(args.publicUrl, "assets"),
70
+ },
71
+ {
72
+ name: "data-api",
73
+ type: "http",
74
+ base: "/_data/",
75
+ handler: `${folder}/handler.data-api.ts`,
76
+ target: "server",
77
+ plugins: () => [
78
+ tsconfigPaths(),
79
+ envPlugin({
80
+ rootDir: args.rootDir,
81
+ console: log,
82
+ mode: "development",
83
+ publicUrl: args.publicUrl,
84
+ serverless: true,
85
+ target: "frontend",
86
+ }),
87
+ ],
88
+ },
89
+ {
90
+ name: "wp-proxy",
91
+ type: "http",
92
+ base: "/wp-",
93
+ handler: `${folder}/handler.wp-proxy.ts`,
94
+ target: "server",
95
+ plugins: () => [
96
+ tsconfigPaths(),
97
+ envPlugin({
98
+ rootDir: args.rootDir,
99
+ console: log,
100
+ mode: "development",
101
+ publicUrl: args.publicUrl,
102
+ serverless: true,
103
+ target: "frontend",
104
+ }),
105
+ ],
106
+ },
107
+ {
108
+ name: "client",
109
+ type: "client",
110
+ handler: `${folder}/entry.client.tsx`,
111
+ target: "browser",
112
+ plugins: () => [
113
+ ...corePlugins({
114
+ rootDir: args.rootDir,
115
+ console: log,
116
+ mode: "development",
117
+ publicUrl: args.publicUrl,
118
+ serverless: true,
119
+ target: "frontend",
120
+ }),
121
+ ],
122
+ base: "/_build",
123
+ },
124
+ {
125
+ name: "admin",
126
+ type: "client",
127
+ handler: `${folder}/entry.admin.tsx`,
128
+ target: "browser",
129
+ plugins: () => [
130
+ ...corePlugins({
131
+ rootDir: args.rootDir,
132
+ console: log,
133
+ mode: "development",
134
+ publicUrl: args.publicUrl,
135
+ serverless: true,
136
+ target: "cms",
137
+ }),
138
+ ],
139
+ base: "/_admin",
140
+ },
141
+ {
142
+ name: "ssr",
143
+ type: "http",
144
+ handler: `${folder}/handler.ssr-page.ts`,
145
+ target: "server",
146
+ plugins: () => [
147
+ ...corePlugins({
148
+ rootDir: args.rootDir,
149
+ console: log,
150
+ mode: "development",
151
+ publicUrl: args.publicUrl,
152
+ serverless: true,
153
+ target: "frontend",
154
+ }),
155
+ ],
156
+ },
157
+ ],
158
+ });
159
+ }
@@ -0,0 +1,12 @@
1
+ import { Project } from "../project/project.js";
2
+ import { FSCodegen } from "../utils/fs-codegen.js";
3
+ type Options = {
4
+ mode: "development" | "production";
5
+ serverless: boolean;
6
+ project: Project;
7
+ endpoint?: string;
8
+ };
9
+ export declare function getVinxiFolder(opts: Pick<Options, "mode" | "serverless">): string;
10
+ export declare function runVinxiCodegen(opts: Options): Promise<void>;
11
+ export declare function createVinxiCodegen(opts: Options): FSCodegen;
12
+ export {};