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
@@ -1,14 +0,0 @@
1
- export default `<!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <!--ssr-meta-->
8
- </head>
9
- <body>
10
- <div id="root"><!--ssr-outlet--></div>
11
- <!--ssr-meta-->
12
- <script type="module" src="/_boot.js"></script>
13
- </body>
14
- </html>`;
@@ -1,2 +0,0 @@
1
- declare const _default: "<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" type=\"image/svg+xml\" href=\"/vite.svg\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <link rel=\"stylesheet\" href=\"/views/index.css\" />\n <!--ssr-meta-->\n </head>\n <body>\n <div id=\"root\"><!--ssr-outlet--></div>\n <!--ssr-meta-->\n <script type=\"module\" src=\"/_boot.js\"></script>\n </body>\n</html>";
2
- export default _default;
@@ -1,15 +0,0 @@
1
- export default `<!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <link rel="stylesheet" href="/views/index.css" />
8
- <!--ssr-meta-->
9
- </head>
10
- <body>
11
- <div id="root"><!--ssr-outlet--></div>
12
- <!--ssr-meta-->
13
- <script type="module" src="/_boot.js"></script>
14
- </body>
15
- </html>`;
@@ -1,215 +0,0 @@
1
- import { getRequestListener } from "@hono/node-server";
2
- import express from "express";
3
- import expressProxy from "express-http-proxy";
4
- import { Agent as HttpAgent } from "http";
5
- import { Agent as HttpsAgent } from "https";
6
- import { listen } from "listhen";
7
- import fetch from "node-fetch";
8
- import { relative } from "path";
9
- import { parseURL } from "ufo";
10
- import { createServer as createViteServer, defineConfig, mergeConfig } from "vite";
11
- import { ProjectEnvUtils } from "../project/env.js";
12
- import { ensureSelfSignedCert } from "../utils/selfSignedCert.js";
13
- import { createConsole } from "../utils/statefulLog.js";
14
- import indexHtml from "./index.html.js";
15
- import { getViteConfig } from "./vite/get-vite-config.js";
16
- const console = createConsole("Dev Server", "dev");
17
- export const serverlessLog = console;
18
- export class ServerlessDevServer {
19
- project;
20
- opts;
21
- constructor(project, opts) {
22
- this.project = project;
23
- this.opts = opts;
24
- this.start();
25
- }
26
- async start() {
27
- console.setWorking(true);
28
- const siteURL = ProjectEnvUtils.get("SITE_URL");
29
- const parsedSiteURL = parseURL(siteURL);
30
- let serverlessPort = 8080;
31
- let hmrPort = serverlessPort + 5;
32
- const serverlessHost = parsedSiteURL.host?.endsWith(".local") ? parsedSiteURL.host : "localhost";
33
- console.info(`Starting dev server...`);
34
- const keys = await ensureSelfSignedCert(serverlessHost, this.project.rootDir);
35
- const app = express();
36
- const hotServer = await listen(() => { }, {
37
- port: hmrPort,
38
- hostname: serverlessHost,
39
- qr: false,
40
- showURL: false,
41
- https: {
42
- cert: keys.certFile,
43
- key: keys.keyFile,
44
- domains: [serverlessHost],
45
- },
46
- });
47
- hmrPort = hotServer.address.port;
48
- const mainServer = await listen(app, {
49
- port: serverlessPort,
50
- hostname: serverlessHost,
51
- qr: false,
52
- showURL: false,
53
- https: {
54
- cert: keys.certFile,
55
- key: keys.keyFile,
56
- domains: [serverlessHost],
57
- },
58
- });
59
- const vite = await createViteServer(mergeConfig(getViteConfig({
60
- console,
61
- mode: this.opts.mode,
62
- project: this.project,
63
- rootDir: this.project.rootDir,
64
- outDir: relative(this.project.rootDir, "./dist/ssr/"),
65
- serverless: true,
66
- target: "frontend",
67
- }), defineConfig({
68
- mode: "development",
69
- base: "/",
70
- server: {
71
- middlewareMode: true,
72
- hmr: {
73
- server: hotServer.server,
74
- port: hmrPort,
75
- path: "/_hmr",
76
- },
77
- },
78
- build: {
79
- ssr: true,
80
- sourcemap: true,
81
- watch: {
82
- clearScreen: true,
83
- },
84
- rollupOptions: {
85
- onwarn(warning, warn) {
86
- if (warning.code === "SOURCEMAP_ERROR") {
87
- return;
88
- }
89
- warn(warning);
90
- },
91
- },
92
- },
93
- appType: "custom",
94
- })));
95
- vite.watcher.on("change", (file) => {
96
- console.resetLog();
97
- });
98
- console.setWorking(false);
99
- const proxyTarget = "https://" + serverlessHost + ":" + serverlessPort + "/";
100
- const proxyDest = parsedSiteURL.protocol + "//" + parsedSiteURL.host + "/";
101
- console.info("Proxying WordPress from", proxyDest);
102
- const replaceTargetString = proxyDest.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\/");
103
- const replaceTargetEscapedString = proxyDest.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\\\/");
104
- const replaceTarget = new RegExp(replaceTargetString, "g");
105
- const replaceTargetEscaped = new RegExp(replaceTargetEscapedString, "g");
106
- const replaceHost = (value) => {
107
- return value.replace(replaceTarget, proxyTarget).replace(replaceTargetEscaped, proxyTarget.replaceAll("/", "\\/"));
108
- };
109
- const proxy = expressProxy(parsedSiteURL.protocol + "//" + parsedSiteURL.host, {
110
- proxyReqOptDecorator: function (proxyReqOpts, originalReq) {
111
- // @ts-ignore
112
- proxyReqOpts.rejectUnauthorized = false;
113
- // @ts-ignore
114
- proxyReqOpts.headers["X-ED-Dev-Proxy"] = "true";
115
- return proxyReqOpts;
116
- },
117
- userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) {
118
- for (let [key, value] of Object.entries(headers)) {
119
- if (typeof value === "string") {
120
- headers[key] = replaceHost(value);
121
- }
122
- else if (Array.isArray(value)) {
123
- headers[key] = value.map((v) => {
124
- return replaceHost(v);
125
- });
126
- }
127
- }
128
- return headers;
129
- },
130
- userResDecorator(proxyRes, proxyResData, userReq, userRes) {
131
- if (userReq.path.includes(".php") || !userReq.path.includes(".") || userReq.path.startsWith("/wp-json")) {
132
- proxyResData = replaceHost(proxyResData.toString("utf8"));
133
- }
134
- return proxyResData;
135
- },
136
- });
137
- app.use(async (req, res, next) => {
138
- if (!req.originalUrl.includes(".php") && !req.originalUrl.includes("/?")) {
139
- vite.middlewares.handle(req, res, next);
140
- }
141
- else {
142
- next();
143
- }
144
- });
145
- /**
146
- * Allow https access from self-signed certificates, when working locally during development
147
- */
148
- const httpsAgent = new HttpsAgent({
149
- rejectUnauthorized: false,
150
- });
151
- const httpAgent = new HttpAgent({});
152
- const fetchImpl = (...args) => {
153
- return fetch(args[0], {
154
- ...(args[1] ?? {}),
155
- agent: function (_parsedURL) {
156
- if (_parsedURL.protocol == "http:") {
157
- return httpAgent;
158
- }
159
- else {
160
- return httpsAgent;
161
- }
162
- },
163
- });
164
- };
165
- app.use(async (req, res, next) => {
166
- if (!req.path.startsWith("/api"))
167
- return next();
168
- const { getHonoAPI, patchConsole } = await vite.ssrLoadModule("/_ssr.js", {
169
- fixStacktrace: true,
170
- });
171
- patchConsole(console);
172
- const hono = getHonoAPI({
173
- fetchImpl,
174
- replaceUrls: {
175
- from: proxyDest,
176
- to: "/",
177
- },
178
- });
179
- const handler = getRequestListener(hono.fetch, {
180
- errorHandler: (err) => {
181
- console.error(err);
182
- },
183
- });
184
- await handler(req, res);
185
- });
186
- app.use(async (req, res, next) => {
187
- const url = req.originalUrl;
188
- if (url.includes(".") || url.startsWith("/wp-") || url.startsWith("/graphql"))
189
- return next();
190
- const { patchConsole, setFetchImpl, getHonoSSR, setIndexTransformer } = await vite.ssrLoadModule("/_ssr.js", {
191
- fixStacktrace: true,
192
- });
193
- patchConsole(console);
194
- const hono = getHonoSSR({
195
- fetchImpl,
196
- indexTransformer: async (index) => await vite.transformIndexHtml(url, indexHtml),
197
- replaceUrls: {
198
- from: proxyDest,
199
- to: "/",
200
- },
201
- });
202
- const handler = getRequestListener(hono.fetch, {
203
- errorHandler: (err) => {
204
- console.error(err);
205
- },
206
- });
207
- await handler(req, res);
208
- });
209
- app.use(proxy);
210
- console.setState({
211
- serverlessUrl: "https://" + serverlessHost + ":" + mainServer.address.port + "/",
212
- wordpressUrl: proxyDest,
213
- });
214
- }
215
- }
@@ -1,13 +0,0 @@
1
- import { InlineConfig } from "vite";
2
- import { Project } from "../../project/project.js";
3
- import { StatefulLog } from "../../utils/statefulLog.js";
4
- export type Args = {
5
- mode: "development" | "production";
6
- serverless: boolean;
7
- target: "frontend" | "cms";
8
- rootDir: string;
9
- outDir: string;
10
- project: Project;
11
- console: StatefulLog<any>;
12
- };
13
- export declare function getViteConfig(args: Args): InlineConfig;
@@ -1,315 +0,0 @@
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 { join } from "path";
6
- import { withoutTrailingSlash } from "ufo";
7
- import { createLogger } from "vite";
8
- import tsconfigPaths from "vite-tsconfig-paths";
9
- import { cliMode } from "../../cli/cli-mode.js";
10
- import { pluginAdminManifest } from "./plugin-admin.js";
11
- import { pluginBlocks } from "./plugin-blocks.js";
12
- import { pluginEntryFile } from "./plugin-entry.js";
13
- import { pluginResolvedTailwind } from "./plugin-resolved-tailwind.js";
14
- import { pluginThemeManifest } from "./plugin-theme.js";
15
- import { pluginViews } from "./plugin-views.js";
16
- export function getViteConfig(args) {
17
- const console = args.console;
18
- const logger = createLogger();
19
- logger.info = (msg) => args.console.info(msg.replace(/\n/, ""));
20
- logger.warn = (msg) => {
21
- if (typeof msg === "string" && msg.includes("Error when using sourcemap for reporting"))
22
- return;
23
- return args.console.warn(msg.replace(/\n/, ""));
24
- };
25
- logger.error = (msg) => args.console.fail(msg.replace(/\n/, ""));
26
- logger.warnOnce = (msg) => args.console.warn(msg.replace(/\n/, ""));
27
- logger.clearScreen = () => {
28
- args.console.resetLog();
29
- };
30
- const envDefines = {
31
- client: args.serverless ? "!import.meta.env.SSR" : "true",
32
- serverless: args.serverless ? "true" : "false",
33
- dev: args.mode === "development" ? "true" : "false",
34
- admin: args.mode === "development" && args.serverless
35
- ? `(typeof __wp_admin !== "undefined")`
36
- : args.target === "cms"
37
- ? "true"
38
- : "false",
39
- themePath: JSON.stringify(args.project.publicUrl),
40
- devUI: args.mode === "development" ? "true" : "false",
41
- serverlessOrigin: JSON.stringify("http://serverleress-endpoint"),
42
- rpcEnabled: "false",
43
- origin: JSON.stringify(process.env.SITE_URL ?? "/"),
44
- };
45
- const expandDefines = (obj, prefixes = []) => {
46
- const result = {};
47
- for (const prefix of prefixes) {
48
- for (const [key, value] of Object.entries(obj)) {
49
- result[prefix + key] = value;
50
- }
51
- }
52
- return result;
53
- };
54
- /** Initial config */
55
- const config = {
56
- appType: "custom",
57
- mode: args.mode,
58
- root: args.rootDir,
59
- customLogger: logger,
60
- logLevel: cliMode.verbose ? "info" : "warn",
61
- base: withoutTrailingSlash(args.project.publicUrl) + "/dist/" + args.target,
62
- define: {
63
- "process.env.NODE_ENV": JSON.stringify(args.mode),
64
- // ssrLoadModule: "() => Promise.resolve({})",
65
- },
66
- // optimizeDeps: {
67
- // force: true,
68
- // holdUntilCrawlEnd: true,
69
- // include: ["zustand"],
70
- // noDiscovery: true,
71
- // exclude: ["react-external.js", "react-dom-external.js", "react", "react-dom"],
72
- // esbuildOptions: {},
73
- // },
74
- resolve: {
75
- alias: [
76
- { find: "@manifest/blocks", replacement: join(args.project.rootDir, "__block-manifest.js") },
77
- { find: "@manifest/views", replacement: join(args.project.rootDir, "__view-manifest.js") },
78
- { find: "@manifest/theme", replacement: join(args.project.rootDir, "__theme-manifest.js") },
79
- { find: "@manifest/admin", replacement: join(args.project.rootDir, "__admin-manifest.js") },
80
- { find: "@manifest/tailwind", replacement: join(args.project.rootDir, "__resolved-tailwind.js") },
81
- ],
82
- },
83
- legacy: {
84
- proxySsrExternalModules: true,
85
- },
86
- plugins: [
87
- tsconfigPaths(),
88
- // pluginShimReact(args),
89
- react({
90
- babel: {
91
- overrides: [{ test: /types\./, compact: true }],
92
- plugins: [
93
- {
94
- visitor: {
95
- // TODO: Move this to a separate file
96
- // TODO: Attach the title to the block component, so we can use it for debugging
97
- ExportNamedDeclaration: (path) => {
98
- const decl = path.node.declaration;
99
- if (decl?.type !== "VariableDeclaration")
100
- return;
101
- const id = decl.declarations[0].id;
102
- if (!t.isIdentifier(id))
103
- return;
104
- if (id.name === "meta") {
105
- path.remove();
106
- }
107
- },
108
- ExportDefaultDeclaration: (path) => {
109
- if (path.node.declaration.type === "CallExpression") {
110
- const call = path.node.declaration;
111
- if (call.callee.type === "Identifier" && ["defineBlock", "defineView"].includes(call.callee.name)) {
112
- const type = call.callee.name.replace("define", "");
113
- const args = call.arguments;
114
- if (args.length === 2 &&
115
- args[0].type === "StringLiteral" &&
116
- args[1].type === "ArrowFunctionExpression") {
117
- const name = args[0].value;
118
- let body = args[1].body;
119
- if (t.isExpression(body)) {
120
- body = t.blockStatement([t.returnStatement(body)]);
121
- }
122
- path.replaceWith(t.exportDefaultDeclaration(t.functionDeclaration(t.identifier(pascalCase(type + "-" + name)), args[1].params, body, args[1].generator, args[1].async)));
123
- }
124
- }
125
- }
126
- },
127
- },
128
- },
129
- ],
130
- },
131
- }),
132
- replace({
133
- values: expandDefines(envDefines, ["process.env.", "process.", "env."]),
134
- preventAssignment: true,
135
- }),
136
- // SPA Frontend, to be served by WordPress
137
- args.target === "frontend" &&
138
- !args.serverless &&
139
- pluginEntryFile({
140
- code: `
141
- import boot from 'eddev/_internal/_entry/main.frontend.spa.js'
142
- import "./views/index.css"
143
- boot()
144
- `,
145
- id: "eddev-bootup",
146
- path: "/_boot.js",
147
- }),
148
- // SPA Admin bundle, to be served by WordPress admin
149
- args.target === "cms" &&
150
- !args.serverless &&
151
- pluginEntryFile({
152
- code: `
153
- import boot from 'eddev/_internal/_entry/main.admin.js'
154
- import "./views/index.css"
155
- boot()
156
- `,
157
- id: "eddev-bootup",
158
- path: "/_boot.js",
159
- }),
160
- // Frontend + Admin, used during development
161
- args.serverless &&
162
- pluginEntryFile({
163
- code: `
164
- import boot from 'eddev/_internal/_entry/main.serverless.dev.js'
165
- import "./views/index.css"
166
- boot()
167
- `,
168
- id: "eddev-bootup",
169
- path: "/_boot.js",
170
- }),
171
- args.serverless &&
172
- pluginEntryFile({
173
- code: `
174
- import React from 'react'
175
- import ReactDOM from 'react-dom/client'
176
- Object.assign(React, window.React)
177
- Object.assign(ReactDOM, window.ReactDOM)
178
- `,
179
- id: "eddev-test-shim",
180
- path: "/_boot_test_shim.js",
181
- }),
182
- // Frontend + Admin, used during development
183
- args.serverless &&
184
- pluginEntryFile({
185
- code: `
186
- import '/_boot_test_shim.js'
187
- import boot from 'eddev/_internal/_entry/main.serverless.dev.js'
188
- import "./views/index.css"
189
- boot()
190
- `,
191
- id: "eddev-bootup-serverless-admin",
192
- path: "/_boot_admin.js",
193
- }),
194
- // SSR Bundle, used for rendering on the server
195
- args.serverless &&
196
- pluginEntryFile({
197
- code: `
198
- export * from 'eddev/_internal/_entry/main.frontend.ssr.js'
199
- import "./views/index.css"
200
- `,
201
- id: "eddev-ssr",
202
- path: "/_ssr.js",
203
- }),
204
- // args.serverless && {
205
- // name: "eddev:serverless",
206
- // (chunk) {
207
- // console.log("Chunk", chunk)
208
- // return ""
209
- // },
210
- // },
211
- pluginResolvedTailwind(args.project, args.console, args.serverless),
212
- pluginBlocks(args.project, args.console, args.serverless),
213
- pluginViews(args.project, args.console, args.serverless),
214
- pluginThemeManifest(args.project, args.console),
215
- pluginAdminManifest(args.project, args.console),
216
- !args.serverless && buildStatus(console),
217
- // args.serverless
218
- // ? pluginEntryFile({
219
- // code: indexHtml,
220
- // id: "index.html",
221
- // path: join(args.rootDir, "index.html"),
222
- // })
223
- // : null,
224
- ],
225
- build: args.target === "cms"
226
- ? {
227
- manifest: true,
228
- sourcemap: true,
229
- modulePreload: false,
230
- minify: args.mode === "production",
231
- outDir: args.outDir,
232
- watch: {},
233
- rollupOptions: {
234
- input: "/_boot.js",
235
- external: ["react", "react-dom"],
236
- onwarn(warning, warn) {
237
- if (warning.code === "SOURCEMAP_ERROR") {
238
- return;
239
- }
240
- warn(warning);
241
- },
242
- output: {
243
- entryFileNames: "main.admin.js",
244
- format: "iife",
245
- globals: {
246
- react: "window.React",
247
- "react-dom": "window.ReactDOM",
248
- },
249
- },
250
- },
251
- }
252
- : args.serverless
253
- ? {
254
- rollupOptions: {
255
- input: "/_boot.js",
256
- external: ["react", "react-dom"],
257
- onwarn(warning, warn) {
258
- if (warning.code === "SOURCEMAP_ERROR") {
259
- return;
260
- }
261
- warn(warning);
262
- },
263
- output: args.mode === "production"
264
- ? {
265
- entryFileNames: "main.admin.js",
266
- format: "iife",
267
- globals: {
268
- react: "window.React",
269
- "react-dom": "window.ReactDOM",
270
- },
271
- }
272
- : undefined,
273
- },
274
- }
275
- : {
276
- manifest: true,
277
- sourcemap: true,
278
- minify: args.mode === "production",
279
- modulePreload: false,
280
- outDir: args.outDir,
281
- watch: {},
282
- rollupOptions: {
283
- input: "/_boot.js",
284
- onwarn(warning, warn) {
285
- if (warning.code === "SOURCEMAP_ERROR") {
286
- return;
287
- }
288
- warn(warning);
289
- },
290
- },
291
- },
292
- };
293
- return config;
294
- }
295
- function buildStatus(console) {
296
- let timer = 0;
297
- return {
298
- name: "eddev:logging",
299
- enforce: "post",
300
- watchChange() {
301
- console.resetLog();
302
- clearTimeout(timer);
303
- },
304
- buildStart() {
305
- clearTimeout(timer);
306
- console.setWorking(true);
307
- },
308
- buildEnd() {
309
- clearTimeout(timer);
310
- timer = setTimeout(() => {
311
- console.setWorking(false);
312
- }, 0);
313
- },
314
- };
315
- }
@@ -1,4 +0,0 @@
1
- import { Plugin } from "vite";
2
- import { Project } from "../../project/project.js";
3
- import { StatefulLog } from "../../utils/statefulLog.js";
4
- export declare function pluginAdminManifest(project: Project, console: StatefulLog<any>): Plugin;
@@ -1,67 +0,0 @@
1
- import { join } from "path";
2
- export function pluginAdminManifest(project, console) {
3
- const virtualId = "\0virtual:admin-manifest.js";
4
- let server = null;
5
- const fakePath = join(project.rootDir, "__admin-manifest.js");
6
- let lastHash = "";
7
- project.views.subscribeFuture(async (manifest) => {
8
- if (server) {
9
- const hash = Object.keys(manifest.views).join("");
10
- const virtualModule = server.moduleGraph.getModuleById(virtualId);
11
- if (virtualModule && hash !== lastHash && lastHash !== "") {
12
- server.moduleGraph.invalidateModule(virtualModule);
13
- }
14
- lastHash = hash;
15
- }
16
- });
17
- return {
18
- name: "eddev:adminManifest",
19
- resolveId(id) {
20
- if (id === fakePath) {
21
- return virtualId;
22
- }
23
- },
24
- async load(id) {
25
- if (id === virtualId) {
26
- const fieldManifest = await project.fields.get();
27
- const widgetManifest = await project.widgets.get();
28
- return `
29
- import { adminManifestReader } from 'eddev/_internal'
30
- import editorConfig from './blocks/_editor'
31
-
32
- const fields = {${Object.entries(fieldManifest.fields)
33
- .map(([name, field]) => {
34
- const importStatement = `() => import(${JSON.stringify("./" + field.fileName)}).then(m => m.default)`;
35
- return JSON.stringify(field.slug) + ": " + importStatement;
36
- })
37
- .join(",\n")}}
38
- const widgets = {${Object.entries(widgetManifest.widgets)
39
- .map(([name, widget]) => {
40
- const importStatement = `() => import(${JSON.stringify("./" + widget.fileName)}).then(m => m.default)`;
41
- return JSON.stringify(widget.slug) + ": " + importStatement;
42
- })
43
- .join(",\n")}}
44
-
45
- const manifest = {
46
- fields,
47
- widgets,
48
- editorConfig
49
- }
50
-
51
- adminManifestReader.set(manifest)
52
-
53
- export default manifest
54
-
55
- export { editorConfig }
56
-
57
- if (import.meta.hot) {
58
- import.meta.hot.accept()
59
- }
60
- `;
61
- }
62
- },
63
- configureServer(_server) {
64
- server = _server;
65
- },
66
- };
67
- }
@@ -1,4 +0,0 @@
1
- import { Plugin } from "vite";
2
- import { Project } from "../../project/project.js";
3
- import { StatefulLog } from "../../utils/statefulLog.js";
4
- export declare function pluginBlocks(project: Project, console: StatefulLog<any>, ssr: boolean): Plugin;