eddev 2.0.0-beta.115 → 2.0.0-beta.116

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.
@@ -1,11 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect } from "react";
3
3
  import { useSnapshot } from "valtio";
4
4
  import { BrowserRouter } from "../lib/routing/components/BrowserRouter.js";
5
5
  import { clientMetaTags } from "../lib/routing/context.js";
6
6
  import { APIProvider } from "../utils/APIProvider.js";
7
+ import { DevUILoader } from "../lib/devtools/loader.js";
7
8
  export function SSRClientRoot(props) {
8
- return (_jsxs(APIProvider, { children: [_jsx(DynamicMetaTags, {}), _jsx(BrowserRouter, {})] }));
9
+ return (_jsxs(APIProvider, { children: [_jsx(BrowserRouter, {}), _jsxs(_Fragment, { children: [_jsx(DynamicMetaTags, {}), _jsx(DevUILoader, {})] })] }));
9
10
  }
10
11
  function DynamicMetaTags() {
11
12
  const dynamicTags = useSnapshot(clientMetaTags).tags;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { SSRRouter } from "../lib/routing/components/SSRRouter.js";
3
3
  import { getRouteMeta, normalizeRoute } from "../lib/routing/utils.js";
4
4
  import { APIProvider } from "../utils/APIProvider.js";
@@ -6,16 +6,16 @@ export function SSRRoot(props) {
6
6
  const loader = props.loader;
7
7
  loader.setAppData(props.initialData.appData.data);
8
8
  loader.populateRouteData(props.pathname, props.initialData);
9
- return (_jsx(APIProvider, { children: _jsx(SSRRouter, { loader: loader, route: normalizeRoute({
10
- id: "initial",
11
- component: loader.getRouteComponent(props.initialData.view),
12
- key: "",
13
- props: props.initialData.viewData.data,
14
- view: props.initialData.view,
15
- search: "",
16
- pathname: props.pathname,
17
- query: {},
18
- hash: "",
19
- meta: getRouteMeta(props.initialData),
20
- }) }) }));
9
+ return (_jsxs(APIProvider, { children: [_jsx(SSRRouter, { loader: loader, route: normalizeRoute({
10
+ id: "initial",
11
+ component: loader.getRouteComponent(props.initialData.view),
12
+ key: "",
13
+ props: props.initialData.viewData.data,
14
+ view: props.initialData.view,
15
+ search: "",
16
+ pathname: props.pathname,
17
+ query: {},
18
+ hash: "",
19
+ meta: getRouteMeta(props.initialData),
20
+ }) }), _jsx(_Fragment, {})] }));
21
21
  }
@@ -8,7 +8,6 @@ export function configureEditorBlocks(config) {
8
8
  const wp = window.wp;
9
9
  let hideStyles = document.getElementById("title-hider");
10
10
  hideStyles?.remove();
11
- console.log("CONFIG", config);
12
11
  if (config.hideTitle) {
13
12
  hideStyles = document.createElement("style");
14
13
  hideStyles.id = "title-hider";
@@ -17,7 +16,6 @@ export function configureEditorBlocks(config) {
17
16
  display: none !important;
18
17
  }
19
18
  `;
20
- console.log("hideStyles", hideStyles);
21
19
  document.head.appendChild(hideStyles);
22
20
  }
23
21
  if (config.template) {
@@ -141,17 +139,24 @@ export function updateTemplateConfig() {
141
139
  }
142
140
  }
143
141
  export function watchEditorTemplate() {
144
- let lastTemplate = "unknown";
145
- wp.data.subscribe(() => {
146
- setTimeout(() => {
147
- const post = wp.data.select("core/editor").getCurrentPost();
148
- let template = wp.data.select("core/editor").getPostEdits()?.template ?? post?.template ?? "";
149
- if (template !== lastTemplate) {
150
- lastTemplate = template;
142
+ let lastKey = "unknown";
143
+ let timer = 0;
144
+ const update = () => {
145
+ const post = wp.data.select("core/editor").getCurrentPost();
146
+ const template = wp.data.select("core/editor").getPostEdits()?.template ?? post?.template ?? "";
147
+ const key = [post.type, template, post.slug, post.title].join(";");
148
+ if (key !== lastKey) {
149
+ lastKey = key;
150
+ clearTimeout(timer);
151
+ timer = setTimeout(() => {
151
152
  updateTemplateConfig();
152
- }
153
- }, 10);
153
+ }, 20);
154
+ }
155
+ };
156
+ wp.data.subscribe(() => {
157
+ update();
154
158
  });
159
+ update();
155
160
  }
156
161
  function setWrapperBlock(blockName, blocks) {
157
162
  const wp = window.wp;
@@ -3,11 +3,11 @@ import { useEffect } from "react";
3
3
  import { useSnapshot } from "valtio";
4
4
  import { getBlockMetadata } from "../block-utils.js";
5
5
  import { InlineEditingContextProvider } from "../inline-editing.js";
6
+ import { EditorHighlights } from "./EditorHighlights.js";
6
7
  import { BlockContext, EditableBlock } from "./EditorSupport.js";
7
8
  import { blocksByTag } from "./blocks-by-tag.js";
8
9
  import { editorConfigStore, getEditingPostInfo, watchEditorTemplate } from "./editor-config.js";
9
10
  import { rootBlocks } from "./root-blocks.js";
10
- import { EditorHighlights } from "./EditorHighlights.js";
11
11
  function listenForHandleResize() {
12
12
  let interval = setInterval(() => {
13
13
  let viewportTarget = document.querySelector(".interface-interface-skeleton__content");
@@ -23,14 +23,24 @@ function listenForHandleResize() {
23
23
  }
24
24
  export function whenEditorIsReady() {
25
25
  return new Promise((resolve) => {
26
+ let ready = false;
26
27
  const unsubscribe = wp.data.subscribe(() => {
27
28
  // This will trigger after the initial render blocking, before the window load event
28
29
  // This seems currently more reliable than using __unstableIsEditorReady
29
30
  if (wp.data.select("core/editor").isCleanNewPost() || wp.data.select("core/block-editor").getBlockCount() > 0) {
31
+ if (ready)
32
+ return;
33
+ ready = true;
30
34
  unsubscribe();
31
35
  resolve();
32
36
  }
33
37
  });
38
+ setTimeout(() => {
39
+ if (ready)
40
+ return;
41
+ unsubscribe();
42
+ resolve();
43
+ }, 1000);
34
44
  });
35
45
  }
36
46
  export function installEDGutenbergHooks() {
@@ -54,7 +64,9 @@ export function installEDGutenbergHooks() {
54
64
  wp.richText.unregisterFormatType("core/language");
55
65
  wp.richText.unregisterFormatType("core/keyboard");
56
66
  wp.richText.unregisterFormatType("core/text-color");
57
- whenEditorIsReady().then(() => watchEditorTemplate());
67
+ whenEditorIsReady().then(() => {
68
+ watchEditorTemplate();
69
+ });
58
70
  // Recalculate registered blocks when rootBlocks change
59
71
  rootBlocks.listen();
60
72
  wp.hooks.addFilter("blocks.registerBlockType", "ed", (item, name) => {
@@ -2,6 +2,7 @@ import { PropsWithChildren } from "react";
2
2
  import { type RouterAPI } from "../types.js";
3
3
  type Props = PropsWithChildren<{
4
4
  routerRef?: React.MutableRefObject<RouterAPI | null>;
5
+ onReady?: () => void;
5
6
  }>;
6
7
  export declare function BrowserRouter(props: Props): import("react/jsx-runtime").JSX.Element;
7
8
  export {};
@@ -423,5 +423,8 @@ export function BrowserRouter(props) {
423
423
  window.removeEventListener("popstate", onPopState);
424
424
  };
425
425
  }, []);
426
+ useEffect(() => {
427
+ props.onReady?.();
428
+ }, []);
426
429
  return (_jsx(RouterContext.Provider, { value: api, children: _jsx(RouterStateContext.Provider, { value: routerState, children: _jsx(AppRenderer, {}) }) }));
427
430
  }
@@ -15,6 +15,7 @@ export async function getSsrStream(args) {
15
15
  const stream = await new Promise(async (resolve, reject) => {
16
16
  // console.log("Rendering to pipable")
17
17
  const stream = renderToPipeableStream(jsx, {
18
+ identifierPrefix: "ed",
18
19
  onShellReady() {
19
20
  // console.log("Shell ready")
20
21
  resolve(stream);
@@ -3,6 +3,7 @@ import { RequestHeaders } from "vinxi/http";
3
3
  import type { EDConfig } from "../../node/project/config.js";
4
4
  import { TrackerTags } from "../lib/routing/types.js";
5
5
  import { UrlReplacerConf } from "./utils/replace-host.js";
6
+ import { QueryMonitor } from "../utils/query-monitor.js";
6
7
  export type ServerContextArgs = {
7
8
  dev: boolean;
8
9
  origin: string;
@@ -36,6 +37,7 @@ export declare class ServerContext {
36
37
  replaceUrls?: boolean;
37
38
  newOrigin?: string;
38
39
  }): Promise<Response>;
40
+ debugLogQueryMonitor(kind: "props" | "mutation" | "query" | "app", uri: string, monitor: QueryMonitor.Entry[]): void;
39
41
  fetchRouteData(req: {
40
42
  pathname: string;
41
43
  headers?: RequestHeaders;
@@ -3,6 +3,9 @@ import { fetchWP } from "../../node/utils/fetch-wp.js";
3
3
  import { filterHeader } from "./utils/headers.js";
4
4
  import { createUrlReplacer } from "./utils/replace-host.js";
5
5
  import { pageCache, queryCache, swr } from "./utils/swr-cache.js";
6
+ import { QueryMonitor } from "../utils/query-monitor.js";
7
+ import chalk from "chalk";
8
+ import { inspect } from "node:util";
6
9
  const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control", /woocommerce/, "location"];
7
10
  const PROXY_REQUEST_HEADERS = [
8
11
  "content-type",
@@ -82,6 +85,87 @@ export class ServerContext {
82
85
  headers,
83
86
  });
84
87
  }
88
+ debugLogQueryMonitor(kind, uri, monitor) {
89
+ if (!QueryMonitor.hasLogEntries(monitor))
90
+ return;
91
+ let indentLevel = 2;
92
+ const finalOutput = [];
93
+ let label = "";
94
+ if (kind === "props") {
95
+ label = "While fetching props for " + uri + "";
96
+ }
97
+ else if (kind === "query") {
98
+ label = "While querying " + uri + " via REST API";
99
+ }
100
+ else if (kind === "mutation") {
101
+ label = "While mutating " + uri + " via REST API";
102
+ }
103
+ else if (kind === "app") {
104
+ label = "While fetching app data";
105
+ }
106
+ finalOutput.push(chalk.whiteBright("➜ " + label));
107
+ function printEntry(entry) {
108
+ finalOutput.push(indent(indentLevel, chalk.whiteBright("➜ " + entry.file) + " " + chalk.gray(entry.label ? `(${entry.label})` : "")));
109
+ indentLevel += 2;
110
+ if (entry.log && entry.log.length) {
111
+ for (let item of entry.log) {
112
+ let output = "";
113
+ let prefix = "";
114
+ let message = item.message;
115
+ let stack = [];
116
+ if (item.type === "php_error") {
117
+ prefix = chalk.red("PHP Error:");
118
+ }
119
+ else if (item.type === "php_warning") {
120
+ prefix = chalk.yellow("PHP Warning:");
121
+ }
122
+ else if (item.type === "php_notice") {
123
+ prefix = chalk.yellow("PHP Notice:");
124
+ }
125
+ else if (item.type === "GRAPHQL_DEBUG") {
126
+ prefix = chalk.cyan("Debug:");
127
+ }
128
+ else if (item.type === "error" && item.extensions?.category === "user") {
129
+ prefix = chalk.red("UserError:");
130
+ }
131
+ else {
132
+ prefix = chalk.gray((item.type || "Log") + ":");
133
+ }
134
+ if (typeof message !== "string") {
135
+ message = inspect(message, { depth: 4 });
136
+ }
137
+ output += prefix + " " + message;
138
+ if (item.path) {
139
+ stack.push(chalk.gray(" at path " + JSON.stringify(item.path)));
140
+ }
141
+ if (item.file) {
142
+ stack.push(chalk.gray(`at ${chalk.white(item.file)} line ${item.line || "??"}`));
143
+ }
144
+ if (item.stack?.length) {
145
+ stack.push(item.stack
146
+ .filter((line) => {
147
+ return line !== item.file + ":" + item.line;
148
+ })
149
+ .slice(0, 4)
150
+ .map((line) => " " + chalk.gray(line))
151
+ .join("\n"));
152
+ }
153
+ if (stack.length > 0) {
154
+ output += indent(2, "\n" + stack.join("\n"));
155
+ }
156
+ finalOutput.push(indent(indentLevel, "➜ " + output));
157
+ }
158
+ }
159
+ for (let child of entry.children ?? []) {
160
+ printEntry(child);
161
+ }
162
+ indentLevel -= 2;
163
+ }
164
+ for (let entry of monitor) {
165
+ printEntry(entry);
166
+ }
167
+ console.debug(finalOutput.join("\n"));
168
+ }
85
169
  async fetchRouteData(req) {
86
170
  /**
87
171
  * Calculcate the cache key.
@@ -135,6 +219,9 @@ export class ServerContext {
135
219
  if (resultData && typeof resultData === "object") {
136
220
  resultData.__generated = new Date().toISOString();
137
221
  }
222
+ if (resultData.queryMonitor) {
223
+ this.debugLogQueryMonitor("props", req.pathname, resultData.queryMonitor);
224
+ }
138
225
  return {
139
226
  status: resultStatus,
140
227
  headers: resultHeaders,
@@ -165,6 +252,9 @@ export class ServerContext {
165
252
  if (isFinite(preferredCacheDuration)) {
166
253
  ctx.metadata.ttl = preferredCacheDuration * 1000;
167
254
  }
255
+ if (result.queryMonitor) {
256
+ this.debugLogQueryMonitor("app", "", result.queryMonitor);
257
+ }
168
258
  result.__generated = new Date().toISOString();
169
259
  return result;
170
260
  },
@@ -203,6 +293,9 @@ export class ServerContext {
203
293
  if (resultData && typeof resultData === "object") {
204
294
  resultData.__generated = new Date().toISOString();
205
295
  }
296
+ if (resultData.queryMonitor) {
297
+ this.debugLogQueryMonitor("query", req.name, resultData.queryMonitor);
298
+ }
206
299
  return {
207
300
  status: resultStatus,
208
301
  headers: resultHeaders,
@@ -281,3 +374,17 @@ export class ServerContext {
281
374
  return {};
282
375
  }
283
376
  }
377
+ function indent(count, str) {
378
+ const indent = " ".repeat(count);
379
+ return str
380
+ .split("\n")
381
+ .map((line) => indent + line)
382
+ .join("\n");
383
+ }
384
+ function indentAllButFirst(count, str) {
385
+ const indent = " ".repeat(count);
386
+ return str
387
+ .split("\n")
388
+ .map((line, i) => (i === 0 ? line : indent + line))
389
+ .join("\n");
390
+ }
@@ -0,0 +1,25 @@
1
+ export declare namespace QueryMonitor {
2
+ type LogEntry = {
3
+ type: "php_warning" | "php_error" | "php_notice" | "error" | "GRAPHQL_DEBUG" | (string & {});
4
+ message: any;
5
+ line?: number;
6
+ file?: string;
7
+ stack?: string[];
8
+ locations?: {
9
+ line: number;
10
+ column: number;
11
+ }[];
12
+ path?: string[];
13
+ extensions?: {
14
+ category?: string;
15
+ };
16
+ };
17
+ type Entry = {
18
+ file: string;
19
+ duration: number;
20
+ label?: "app" | "page" | "block" | "query" | "mutation" | (string & {});
21
+ log: LogEntry[];
22
+ children?: Entry[];
23
+ };
24
+ function hasLogEntries(entry: Entry[]): boolean;
25
+ }
@@ -0,0 +1,7 @@
1
+ export var QueryMonitor;
2
+ (function (QueryMonitor) {
3
+ function hasLogEntries(entry) {
4
+ return entry.some((e) => e.log.length > 0 || (e.children && hasLogEntries(e.children)));
5
+ }
6
+ QueryMonitor.hasLogEntries = hasLogEntries;
7
+ })(QueryMonitor || (QueryMonitor = {}));
@@ -79,12 +79,12 @@ program
79
79
  rootDir: process.cwd(),
80
80
  reportPluginCompatibility: true,
81
81
  });
82
- const result = await project.verifyOriginAccess();
83
- if (!result.success) {
84
- projectLog.fail(result.message);
85
- process.exit(1);
86
- return;
87
- }
82
+ // const result = await project.verifyOriginAccess()
83
+ // if (!result.success) {
84
+ // projectLog.fail(result.message)
85
+ // process.exit(1)
86
+ // return
87
+ // }
88
88
  const infoWriter = new BuildInfoWriter(project);
89
89
  infoWriter.watch();
90
90
  infoWriter.write();
@@ -122,6 +122,8 @@ program
122
122
  // We ignore SSL errors in dev mode.
123
123
  if (typeof args[0] === "string" && args[0].includes("NODE_TLS_REJECT_UNAUTHORIZED"))
124
124
  return;
125
+ if (typeof args[0] === "string" && args[0].includes("useLayoutEffect does nothing"))
126
+ return;
125
127
  serverlessLog.error(...args);
126
128
  };
127
129
  console.warn = (...args) => {
@@ -1 +1 @@
1
- export declare const VERSION = "2.0.0-beta.115";
1
+ export declare const VERSION = "2.0.0-beta.116";
@@ -1 +1 @@
1
- export const VERSION = "2.0.0-beta.115";
1
+ export const VERSION = "2.0.0-beta.116";
@@ -134,6 +134,9 @@ export function createVinxiCodegen(opts) {
134
134
  hydrateRoot(
135
135
  document.getElementById('root')!,
136
136
  <React.Suspense><SSRClientRoot assets={getAssets()} metaTags={window._PAGE_DATA.meta.head} /></React.Suspense>,
137
+ {
138
+ identifierPrefix: "ed",
139
+ }
137
140
  )
138
141
 
139
142
  if (import.meta.hot) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "2.0.0-beta.115",
3
+ "version": "2.0.0-beta.116",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",