eddev 2.0.0-beta.1 → 2.0.0-beta.11

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 (130) 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/blocks/ErrorBoundaryFrontend.d.ts +1 -1
  10. package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +1 -1
  11. package/dist/app/lib/devtools/components/BreakpointIndicator.js +5 -3
  12. package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
  13. package/dist/app/lib/devtools/dev-tools-store.js +8 -0
  14. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +120 -121
  15. package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
  16. package/dist/app/lib/devtools/index.d.ts +1 -0
  17. package/dist/app/lib/devtools/index.js +1 -1
  18. package/dist/app/lib/hooks/queryUtils.d.ts +4 -1
  19. package/dist/app/lib/hooks/queryUtils.js +8 -11
  20. package/dist/app/lib/internal/internal-store.d.ts +0 -2
  21. package/dist/app/lib/internal/internal-store.js +1 -3
  22. package/dist/app/lib/routing/components/ClientOnly.d.ts +1 -1
  23. package/dist/app/lib/routing/loader.js +6 -4
  24. package/dist/app/server/index.d.ts +3 -0
  25. package/dist/app/server/index.js +3 -0
  26. package/dist/app/server/proxy-wp-admin.d.ts +3 -0
  27. package/dist/app/server/proxy-wp-admin.js +106 -0
  28. package/dist/app/server/render-ssr-page.d.ts +2 -0
  29. package/dist/app/server/render-ssr-page.js +22 -0
  30. package/dist/app/server/server-context.d.ts +34 -0
  31. package/dist/app/server/server-context.js +116 -0
  32. package/dist/app/server/utils/headers.d.ts +1 -0
  33. package/dist/app/server/utils/headers.js +17 -0
  34. package/dist/app/server/utils/replace-host.d.ts +6 -4
  35. package/dist/app/server/utils/replace-host.js +58 -11
  36. package/dist/node/cli/cli-worker.d.ts +1 -1
  37. package/dist/node/cli/cli-worker.js +3 -0
  38. package/dist/node/cli/cli.js +45 -14
  39. package/dist/node/cli/display/CLIApp.d.ts +1 -1
  40. package/dist/node/cli/display/CLIApp.js +1 -1
  41. package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
  42. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
  43. package/dist/node/cli/display/util/colors.d.ts +2 -2
  44. package/dist/node/cli/version.d.ts +1 -1
  45. package/dist/node/cli/version.js +1 -1
  46. package/dist/node/compiler/build-vinxi.d.ts +8 -0
  47. package/dist/node/compiler/build-vinxi.js +37 -0
  48. package/dist/node/compiler/bundler.admin.d.ts +1 -1
  49. package/dist/node/compiler/bundler.admin.js +3 -3
  50. package/dist/node/compiler/bundler.frontend.d.ts +1 -1
  51. package/dist/node/compiler/bundler.frontend.js +3 -3
  52. package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
  53. package/dist/node/compiler/dev-server.js +97 -0
  54. package/dist/node/compiler/get-vite-config.d.ts +19 -0
  55. package/dist/node/compiler/get-vite-config.js +184 -0
  56. package/dist/node/compiler/vinxi-app.d.ts +10 -0
  57. package/dist/node/compiler/vinxi-app.js +121 -0
  58. package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
  59. package/dist/node/compiler/vinxi-codegen.js +408 -0
  60. package/dist/node/graphql/graphql-codegen.d.ts +1 -1
  61. package/dist/node/graphql/graphql-codegen.js +3 -3
  62. package/dist/node/graphql/graphql-schema-loader.js +15 -18
  63. package/dist/node/project/config.js +1 -1
  64. package/dist/node/project/env.d.ts +1 -1
  65. package/dist/node/project/env.js +1 -1
  66. package/dist/node/project/manifest/block-manifest.js +2 -2
  67. package/dist/node/project/manifest/manifest.d.ts +1 -1
  68. package/dist/node/project/manifest/manifest.js +1 -1
  69. package/dist/node/project/manifest/view-manifest.js +2 -2
  70. package/dist/node/project/project.d.ts +2 -1
  71. package/dist/node/project/project.js +13 -15
  72. package/dist/node/project/wp-info.js +0 -2
  73. package/dist/node/types/view-type.js +3 -4
  74. package/dist/node/utils/fs-codegen.d.ts +40 -0
  75. package/dist/node/utils/fs-codegen.js +97 -0
  76. package/dist/node/utils/fs.js +2 -0
  77. package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
  78. package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
  79. package/package.json +29 -31
  80. package/dist/app/entry/Root.d.ts +0 -1
  81. package/dist/app/entry/main.admin.d.ts +0 -3
  82. package/dist/app/entry/main.frontend.spa.d.ts +0 -3
  83. package/dist/app/entry/main.frontend.spa.js +0 -13
  84. package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
  85. package/dist/app/entry/main.frontend.ssr.js +0 -79
  86. package/dist/app/entry/main.serverless.dev.d.ts +0 -4
  87. package/dist/app/entry/main.serverless.dev.js +0 -21
  88. package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
  89. package/dist/app/server/create-api-builtin-hono.js +0 -80
  90. package/dist/app/server/create-ssr-hono.d.ts +0 -18
  91. package/dist/app/server/create-ssr-hono.js +0 -104
  92. package/dist/app/server/utils/index.html.d.ts +0 -2
  93. package/dist/app/server/utils/index.html.js +0 -14
  94. package/dist/node/compiler/index.html.d.ts +0 -2
  95. package/dist/node/compiler/index.html.js +0 -15
  96. package/dist/node/compiler/serverless.dev.js +0 -215
  97. package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
  98. package/dist/node/compiler/vite/get-vite-config.js +0 -315
  99. package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
  100. package/dist/node/compiler/vite/plugin-admin.js +0 -67
  101. package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
  102. package/dist/node/compiler/vite/plugin-blocks.js +0 -73
  103. package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
  104. package/dist/node/compiler/vite/plugin-entry.js +0 -16
  105. package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
  106. package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
  107. package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
  108. package/dist/node/compiler/vite/plugin-theme.js +0 -40
  109. package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
  110. package/dist/node/compiler/vite/plugin-views.js +0 -51
  111. package/dist/node/utils/console.d.ts +0 -21
  112. package/dist/node/utils/console.js +0 -28
  113. package/dist/node/utils/unsafe-fetch.d.ts +0 -2
  114. package/dist/node/utils/unsafe-fetch.js +0 -19
  115. package/tsup.config.ts +0 -40
  116. package/types.manifests.d.ts +0 -22
  117. /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
  118. /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
  119. /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
  120. /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
  121. /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
  122. /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
  123. /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
  124. /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
  125. /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
  126. /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
  127. /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
  128. /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
  129. /package/dist/node/utils/{watchFileTree.d.ts → watch-file-tree.d.ts} +0 -0
  130. /package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +0 -0
@@ -2,7 +2,7 @@ import type { graphqlLog } from "../../graphql/graphql-codegen.js";
2
2
  import type { Project, projectLog } from "../../project/project.js";
3
3
  import type { adminLog } from "../../compiler/bundler.admin.js";
4
4
  import type { frontendLog } from "../../compiler/bundler.frontend.js";
5
- import { serverlessLog } from "../../compiler/serverless.dev.js";
5
+ import { serverlessLog } from "../../compiler/dev-server.js";
6
6
  export type CLIDisplayProps = {
7
7
  getProject: () => Project;
8
8
  logs: {
@@ -5,7 +5,7 @@ import { VERSION } from "../version.js";
5
5
  import { LogEntries, LogItem } from "./components/LogEntries.js";
6
6
  import { useStatefulLogs } from "./hooks/useStatefulLog.js";
7
7
  import { statusColor, statusIcon } from "./util/colors.js";
8
- import { serverlessLog } from "../../compiler/serverless.dev.js";
8
+ import { serverlessLog } from "../../compiler/dev-server.js";
9
9
  import { useEffect, useState } from "react";
10
10
  import TextInput from "./components/TextInput.js";
11
11
  import { findTools } from "./tools/cli-tools.js";
@@ -1,4 +1,4 @@
1
- import type { LogEntry, LogGroup, LogGroupOrEntry } from "../../../utils/statefulLog.js";
1
+ import type { LogEntry, LogGroup, LogGroupOrEntry } from "../../../utils/stateful-log.js";
2
2
  export declare function LogEntries(props: {
3
3
  entries: LogGroupOrEntry[];
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { StatefulLog } from "../../../utils/statefulLog.js";
1
+ import { StatefulLog } from "../../../utils/stateful-log.js";
2
2
  export type LogInfo<T extends StatefulLog<any> | undefined> = {
3
3
  label: string;
4
4
  value: Exclude<T, undefined>["state"];
@@ -1,4 +1,4 @@
1
- import { LogStatus } from "../../../utils/statefulLog.js";
2
- export declare function statusColor(status: LogStatus): "greenBright" | "redBright" | "blueBright" | "whiteBright" | "#FF890C" | "#0C86FF" | "grayBright";
1
+ import { LogStatus } from "../../../utils/stateful-log.js";
2
+ export declare function statusColor(status: LogStatus): "greenBright" | "redBright" | "#FF890C" | "blueBright" | "#0C86FF" | "grayBright" | "whiteBright";
3
3
  export declare function statusIcon(status: LogStatus): "✖" | "✔" | "⚠" | "ℹ" | "⚙" | "v" | "?" | "➜";
4
4
  export declare function statusLabel(status: LogStatus): "Error" | "Warning" | "Info" | "Working" | "Fail" | "Success" | "Verbose" | "Help" | "Log";
@@ -1 +1 @@
1
- export declare const VERSION = "2.0.0";
1
+ export declare const VERSION = "2.0.0-beta.11";
@@ -1 +1 @@
1
- export const VERSION = "2.0.0";
1
+ export const VERSION = "2.0.0-beta.11";
@@ -0,0 +1,8 @@
1
+ import { Project } from "../project/project.js";
2
+ import { StatefulLog } from "../utils/stateful-log.js";
3
+ type Options = {
4
+ project: Project;
5
+ console: StatefulLog<any>;
6
+ };
7
+ export declare function buildVinxi(opts: Options): Promise<void>;
8
+ export {};
@@ -0,0 +1,37 @@
1
+ import { code } from "ts-poet";
2
+ import { createVinxiApp } from "./vinxi-app.js";
3
+ import { createVinxiCodegen } from "./vinxi-codegen.js";
4
+ export async function buildVinxi(opts) {
5
+ const { project, console } = opts;
6
+ const preset = process.env.TARGET ??
7
+ process.env.PRESET ??
8
+ process.env.SERVER_PRESET ??
9
+ process.env.SERVER_TARGET ??
10
+ process.env.NITRO_PRESET ??
11
+ process.env.NITRO_TARGET ??
12
+ (process.env.VERCEL ? "vercel" : undefined) ??
13
+ (process.versions.bun !== undefined ? "bun" : "node-server");
14
+ const appConf = {
15
+ mode: "production",
16
+ origin: project.origin,
17
+ publicUrl: project.publicUrl,
18
+ rootDir: project.rootDir,
19
+ // log: console,
20
+ preset,
21
+ };
22
+ const codegen = createVinxiCodegen({
23
+ mode: "production",
24
+ project: project,
25
+ serverless: true,
26
+ });
27
+ codegen.registerFile({
28
+ name: "../../app.config.mjs",
29
+ generate: code /* ts */ `
30
+ import { createVinxiApp } from 'eddev/_internal/create-vinxi-app.js'
31
+ export default createVinxiApp(${JSON.stringify(appConf)})
32
+ `,
33
+ });
34
+ await codegen.runAndWatch();
35
+ const app = createVinxiApp(appConf);
36
+ await app.build();
37
+ }
@@ -1,5 +1,5 @@
1
1
  import { Project } from "../project/project.js";
2
- export declare const adminLog: import("../utils/statefulLog.js").StatefulLog<unknown>;
2
+ export declare const adminLog: import("../utils/stateful-log.js").StatefulLog<unknown>;
3
3
  type Options = {
4
4
  mode: "development" | "production";
5
5
  watch?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { relative } from "path";
2
2
  import { build, defineConfig, mergeConfig } from "vite";
3
- import { createConsole } from "../utils/statefulLog.js";
4
- import { getViteConfig } from "./vite/get-vite-config.js";
3
+ import { createConsole } from "../utils/stateful-log.js";
4
+ import { getViteConfig } from "./get-vite-config.js";
5
5
  const console = createConsole("Admin Bundle", "admin");
6
6
  export const adminLog = console;
7
7
  export class AdminBundler {
@@ -17,7 +17,7 @@ export class AdminBundler {
17
17
  const baseConfig = getViteConfig({
18
18
  console,
19
19
  mode: this.opts.mode,
20
- project: this.project,
20
+ publicUrl: this.project.publicUrl,
21
21
  rootDir: this.project.rootDir,
22
22
  outDir: relative(this.project.rootDir, "./dist/cms/"),
23
23
  serverless: false,
@@ -1,5 +1,5 @@
1
1
  import { Project } from "../project/project.js";
2
- export declare const frontendLog: import("../utils/statefulLog.js").StatefulLog<unknown>;
2
+ export declare const frontendLog: import("../utils/stateful-log.js").StatefulLog<unknown>;
3
3
  type Options = {
4
4
  mode: "development" | "production";
5
5
  watch?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { relative } from "path";
2
2
  import { build, defineConfig, mergeConfig } from "vite";
3
- import { createConsole } from "../utils/statefulLog.js";
4
- import { getViteConfig } from "./vite/get-vite-config.js";
3
+ import { createConsole } from "../utils/stateful-log.js";
4
+ import { getViteConfig } from "./get-vite-config.js";
5
5
  const console = createConsole("Frontend Bundler", "spa");
6
6
  export const frontendLog = console;
7
7
  export class FrontendBundler {
@@ -17,7 +17,7 @@ export class FrontendBundler {
17
17
  const baseConfig = getViteConfig({
18
18
  console,
19
19
  mode: this.opts.mode,
20
- project: this.project,
20
+ publicUrl: this.project.publicUrl,
21
21
  rootDir: this.project.rootDir,
22
22
  outDir: relative(this.project.rootDir, "./dist/frontend/"),
23
23
  serverless: false,
@@ -3,13 +3,15 @@ export type ServerlessDevStatus = {
3
3
  serverlessUrl: string;
4
4
  wordpressUrl: string;
5
5
  };
6
- export declare const serverlessLog: import("../utils/statefulLog.js").StatefulLog<ServerlessDevStatus>;
7
- type Options = {
8
- mode: "development" | "production";
9
- };
10
- export declare class ServerlessDevServer {
6
+ export declare const serverlessLog: import("../utils/stateful-log.js").StatefulLog<ServerlessDevStatus>;
7
+ type Options = {};
8
+ export declare class DevServer {
11
9
  project: Project;
12
10
  opts: Options;
11
+ origin: string;
12
+ hostname: string;
13
+ hostOrigin: string;
14
+ port: number;
13
15
  constructor(project: Project, opts: Options);
14
16
  start(): Promise<void>;
15
17
  }
@@ -0,0 +1,97 @@
1
+ import { parseURL } from "ufo";
2
+ import { createDevServer } from "vinxi/dev-server";
3
+ import { ProjectEnvUtils } from "../project/env.js";
4
+ import { ensureSelfSignedCert } from "../utils/self-signed-cert.js";
5
+ import { createConsole } from "../utils/stateful-log.js";
6
+ import { createVinxiApp } from "./vinxi-app.js";
7
+ import { createVinxiCodegen } from "./vinxi-codegen.js";
8
+ const console = createConsole("Dev Server", "dev");
9
+ export const serverlessLog = console;
10
+ export class DevServer {
11
+ project;
12
+ opts;
13
+ origin;
14
+ hostname;
15
+ hostOrigin;
16
+ port = 8080;
17
+ constructor(project, opts) {
18
+ this.project = project;
19
+ this.opts = opts;
20
+ this.start();
21
+ this.origin = ProjectEnvUtils.get("SITE_URL");
22
+ const parsedSiteURL = parseURL(this.origin);
23
+ this.hostname = parsedSiteURL.host?.endsWith(".local") ? parsedSiteURL.host : "localhost";
24
+ this.hostOrigin = "https://" + this.hostname + ":" + this.port;
25
+ }
26
+ async start() {
27
+ console.setWorking(true);
28
+ const codegen = createVinxiCodegen({
29
+ mode: "development",
30
+ project: this.project,
31
+ serverless: true,
32
+ });
33
+ await codegen.runAndWatch();
34
+ const app = createVinxiApp({
35
+ mode: "development",
36
+ origin: this.origin,
37
+ publicUrl: this.project.publicUrl,
38
+ rootDir: this.project.rootDir,
39
+ log: console,
40
+ });
41
+ const preset = process.env.TARGET ??
42
+ process.env.PRESET ??
43
+ process.env.SERVER_PRESET ??
44
+ process.env.SERVER_TARGET ??
45
+ process.env.NITRO_PRESET ??
46
+ process.env.NITRO_TARGET ??
47
+ (process.versions.bun !== undefined ? "bun" : "node-server");
48
+ const keys = await ensureSelfSignedCert(this.hostname, this.project.rootDir);
49
+ const httpsConfig = {
50
+ cert: keys.certFile,
51
+ key: keys.keyFile,
52
+ domains: [this.hostname, "localhost"],
53
+ };
54
+ let devApp = null;
55
+ app.hooks.addHooks({
56
+ "app:dev:start": async ({ app, serveConfig }) => {
57
+ serveConfig.https = httpsConfig;
58
+ serveConfig.hostname = this.hostname;
59
+ },
60
+ "app:dev:server:created": async (args) => {
61
+ devApp = args.devApp;
62
+ },
63
+ });
64
+ await createDevServer(app, {
65
+ force: false,
66
+ devtools: false,
67
+ // @ts-ignore
68
+ hostname: this.hostname,
69
+ port: this.port,
70
+ // @ts-ignore
71
+ preset: preset,
72
+ https: httpsConfig,
73
+ });
74
+ // @ts-ignore
75
+ await app.hooks.callHook("app:dev:server:listener:creating", {
76
+ app,
77
+ devApp,
78
+ });
79
+ const listener = await devApp.listen(this.port, {
80
+ hostname: this.hostname,
81
+ port: this.port,
82
+ https: httpsConfig,
83
+ qr: false,
84
+ showURL: false,
85
+ });
86
+ await app.hooks.callHook("app:dev:server:listener:created", {
87
+ app,
88
+ devApp,
89
+ listener,
90
+ });
91
+ console.setWorking(false);
92
+ console.setState({
93
+ serverlessUrl: this.hostOrigin,
94
+ wordpressUrl: this.origin,
95
+ });
96
+ }
97
+ }
@@ -0,0 +1,19 @@
1
+ import { InlineConfig, PluginOption } from "vite";
2
+ import { StatefulLog } from "../utils/stateful-log.js";
3
+ export type Args = {
4
+ mode: "development" | "production";
5
+ serverless: boolean;
6
+ target: "frontend" | "cms";
7
+ rootDir: string;
8
+ outDir?: string;
9
+ publicUrl: string;
10
+ console: StatefulLog<any>;
11
+ };
12
+ export declare function envPlugin(args: Args): PluginOption;
13
+ export declare function reactPlugin(): PluginOption[];
14
+ /**
15
+ * Turns on SSR module proxying,
16
+ */
17
+ export declare function ssrPlugin(): PluginOption;
18
+ export declare function corePlugins(args: Args): PluginOption[];
19
+ export declare function getViteConfig(args: Args): InlineConfig;
@@ -0,0 +1,184 @@
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
+ proxySsrExternalModules: true,
89
+ };
90
+ return config;
91
+ },
92
+ };
93
+ }
94
+ function buildStatusPlugin(console) {
95
+ let timer = 0;
96
+ return {
97
+ name: "eddev:logging",
98
+ enforce: "post",
99
+ watchChange() {
100
+ console.resetLog();
101
+ clearTimeout(timer);
102
+ },
103
+ buildStart() {
104
+ clearTimeout(timer);
105
+ console.setWorking(true);
106
+ },
107
+ buildEnd() {
108
+ clearTimeout(timer);
109
+ timer = setTimeout(() => {
110
+ console.setWorking(false);
111
+ }, 0);
112
+ },
113
+ };
114
+ }
115
+ export function corePlugins(args) {
116
+ return [
117
+ tsconfigPaths(),
118
+ reactPlugin(),
119
+ args.mode === "development" && args.serverless && ssrPlugin(),
120
+ envPlugin(args),
121
+ ].flat();
122
+ }
123
+ export function getViteConfig(args) {
124
+ const console = args.console;
125
+ const logger = createLogger();
126
+ logger.info = (msg) => args.console.info(msg.replace(/\n/, ""));
127
+ logger.warn = (msg) => {
128
+ if (typeof msg === "string" && msg.includes("Error when using sourcemap for reporting"))
129
+ return;
130
+ return args.console.warn(msg.replace(/\n/, ""));
131
+ };
132
+ logger.error = (msg) => args.console.fail(msg.replace(/\n/, ""));
133
+ logger.warnOnce = (msg) => args.console.warn(msg.replace(/\n/, ""));
134
+ logger.clearScreen = () => {
135
+ args.console.resetLog();
136
+ };
137
+ /** Initial config */
138
+ const config = {
139
+ appType: "custom",
140
+ mode: args.mode,
141
+ root: args.rootDir,
142
+ customLogger: logger,
143
+ logLevel: cliMode.verbose ? "info" : "warn",
144
+ base: withoutTrailingSlash(args.publicUrl) + "/dist/" + args.target,
145
+ define: {
146
+ "process.env.NODE_ENV": JSON.stringify(args.mode),
147
+ },
148
+ plugins: [tsconfigPaths(), envPlugin(args), reactPlugin(), buildStatusPlugin(console)],
149
+ build: {
150
+ manifest: true,
151
+ sourcemap: true,
152
+ minify: args.mode === "production",
153
+ modulePreload: false,
154
+ outDir: args.outDir,
155
+ watch: {},
156
+ rollupOptions: {
157
+ input: `/.eddev/${args.mode === "production" ? "prod" : "dev"}-spa/entry.${args.target === "cms" ? "admin" : "client"}.tsx`,
158
+ external: args.target === "cms" ? ["react", "react-dom"] : [],
159
+ onwarn(warning, warn) {
160
+ if (!cliMode.verbose &&
161
+ warning.code &&
162
+ ["SOURCEMAP_ERROR", "UNUSED_EXTERNAL_IMPORT", "INVALID_ANNOTATION", "EVAL"].includes(warning.code)) {
163
+ return;
164
+ }
165
+ if (warning.code) {
166
+ warning.message = warning.code + ": " + warning.message;
167
+ }
168
+ warn(warning);
169
+ },
170
+ output: args.target === "cms"
171
+ ? {
172
+ entryFileNames: "main.admin.js",
173
+ format: "iife",
174
+ globals: {
175
+ react: "window.React",
176
+ "react-dom": "window.ReactDOM",
177
+ },
178
+ }
179
+ : undefined,
180
+ },
181
+ },
182
+ };
183
+ return config;
184
+ }
@@ -0,0 +1,10 @@
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
+ };
10
+ export declare function createVinxiApp(args: AppArgs): import("vinxi").App;
@@ -0,0 +1,121 @@
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/**": { proxy: joinURL(args.origin, "wp-content/**") },
22
+ "/wp-includes/**": { proxy: joinURL(args.origin, "wp-includes/**") },
23
+ },
24
+ },
25
+ routers: [
26
+ {
27
+ name: "public",
28
+ type: "static",
29
+ dir: "./assets",
30
+ base: joinURL(args.publicUrl, "assets"),
31
+ },
32
+ {
33
+ name: "data-api",
34
+ type: "http",
35
+ base: "/_data/",
36
+ handler: `${folder}/handler.data-api.ts`,
37
+ target: "server",
38
+ plugins: () => [
39
+ tsconfigPaths(),
40
+ envPlugin({
41
+ rootDir: args.rootDir,
42
+ console: log,
43
+ mode: "development",
44
+ publicUrl: args.publicUrl,
45
+ serverless: true,
46
+ target: "frontend",
47
+ }),
48
+ ],
49
+ },
50
+ {
51
+ name: "wp-proxy",
52
+ type: "http",
53
+ base: "/wp-",
54
+ handler: `${folder}/handler.wp-proxy.ts`,
55
+ target: "server",
56
+ plugins: () => [
57
+ tsconfigPaths(),
58
+ envPlugin({
59
+ rootDir: args.rootDir,
60
+ console: log,
61
+ mode: "development",
62
+ publicUrl: args.publicUrl,
63
+ serverless: true,
64
+ target: "frontend",
65
+ }),
66
+ ],
67
+ },
68
+ {
69
+ name: "client",
70
+ type: "client",
71
+ handler: `${folder}/entry.client.tsx`,
72
+ target: "browser",
73
+ plugins: () => [
74
+ ...corePlugins({
75
+ rootDir: args.rootDir,
76
+ console: log,
77
+ mode: "development",
78
+ publicUrl: args.publicUrl,
79
+ serverless: true,
80
+ target: "frontend",
81
+ }),
82
+ ],
83
+ base: "/_build",
84
+ },
85
+ {
86
+ name: "admin",
87
+ type: "client",
88
+ handler: `${folder}/entry.admin.tsx`,
89
+ target: "browser",
90
+ plugins: () => [
91
+ ...corePlugins({
92
+ rootDir: args.rootDir,
93
+ console: log,
94
+ mode: "development",
95
+ publicUrl: args.publicUrl,
96
+ serverless: true,
97
+ target: "cms",
98
+ }),
99
+ ],
100
+ base: "/_admin",
101
+ },
102
+ {
103
+ name: "ssr",
104
+ type: "http",
105
+ handler: `${folder}/handler.ssr-page.ts`,
106
+ target: "server",
107
+ plugins: () => [
108
+ // reactRefresh(),
109
+ ...corePlugins({
110
+ rootDir: args.rootDir,
111
+ console: log,
112
+ mode: "development",
113
+ publicUrl: args.publicUrl,
114
+ serverless: true,
115
+ target: "frontend",
116
+ }),
117
+ ],
118
+ },
119
+ ],
120
+ });
121
+ }
@@ -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 {};