eddev 2.0.0-beta.9 → 2.0.0-beta.91

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 (210) hide show
  1. package/dist/app/entry/HydrationOverlay.d.ts +1 -0
  2. package/dist/app/entry/HydrationOverlay.js +2 -0
  3. package/dist/app/entry/MetaTags.d.ts +7 -0
  4. package/dist/app/entry/MetaTags.js +17 -0
  5. package/dist/app/entry/boot-admin.js +11 -6
  6. package/dist/app/entry/hydration-script.d.ts +1 -0
  7. package/dist/app/entry/hydration-script.js +18 -0
  8. package/dist/app/entry/spa-root.js +4 -5
  9. package/dist/app/entry/ssr-root-client.d.ts +3 -1
  10. package/dist/app/entry/ssr-root-client.js +24 -8
  11. package/dist/app/entry/ssr-root.d.ts +5 -4
  12. package/dist/app/entry/ssr-root.js +21 -20
  13. package/dist/app/lib/admin/index.d.ts +2 -2
  14. package/dist/app/lib/admin/index.js +2 -2
  15. package/dist/app/lib/admin/installFieldTypes.js +1 -1
  16. package/dist/app/lib/admin/runWidgets.js +1 -1
  17. package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
  18. package/dist/app/lib/blocks/ContentBlocks.js +5 -5
  19. package/dist/app/lib/blocks/EditableText.d.ts +1 -1
  20. package/dist/app/lib/blocks/EditableText.js +3 -3
  21. package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
  22. package/dist/app/lib/blocks/InnerBlocks.js +13 -5
  23. package/dist/app/lib/blocks/block-utils.d.ts +2 -2
  24. package/dist/app/lib/blocks/block-utils.js +2 -2
  25. package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +7 -0
  26. package/dist/app/lib/blocks/editor/EditorHighlights.js +130 -0
  27. package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
  28. package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +1 -1
  29. package/dist/app/lib/blocks/editor/editor-config.d.ts +17 -4
  30. package/dist/app/lib/blocks/editor/editor-config.js +21 -9
  31. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +20 -14
  32. package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
  33. package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
  34. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  35. package/dist/app/lib/blocks/index.d.ts +9 -9
  36. package/dist/app/lib/blocks/index.js +9 -9
  37. package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
  38. package/dist/app/lib/blocks/inline-editing.js +7 -5
  39. package/dist/app/lib/devtools/components/BreakpointIndicator.js +1 -1
  40. package/dist/app/lib/devtools/components/DevUI.js +4 -3
  41. package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
  42. package/dist/app/lib/devtools/components/GridIndicator.js +29 -0
  43. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
  44. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  45. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1014 -1014
  46. package/dist/app/lib/devtools/hooks/useTailwind.js +1 -1
  47. package/dist/app/lib/devtools/index.d.ts +1 -1
  48. package/dist/app/lib/devtools/index.js +1 -1
  49. package/dist/app/lib/devtools/loader.js +8 -7
  50. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  51. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  52. package/dist/app/lib/dynamic/dynamic.d.ts +1 -1
  53. package/dist/app/lib/dynamic/dynamic.js +5 -1
  54. package/dist/app/lib/dynamic/index.d.ts +1 -1
  55. package/dist/app/lib/dynamic/index.js +1 -1
  56. package/dist/app/lib/hooks/index.d.ts +4 -5
  57. package/dist/app/lib/hooks/index.js +4 -5
  58. package/dist/app/lib/hooks/queryUtils.d.ts +37 -3
  59. package/dist/app/lib/hooks/queryUtils.js +66 -26
  60. package/dist/app/lib/hooks/useAppData.js +1 -1
  61. package/dist/app/lib/hooks/useRPC.d.ts +0 -4
  62. package/dist/app/lib/hooks/useRPC.js +1 -8
  63. package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
  64. package/dist/app/lib/internal/finalize-rpc.js +3 -0
  65. package/dist/app/lib/internal/index.d.ts +5 -4
  66. package/dist/app/lib/internal/index.js +5 -4
  67. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  68. package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
  69. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  70. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  71. package/dist/app/lib/legacy-stitches/index.js +1 -1
  72. package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
  73. package/dist/app/lib/routing/components/BackButton.js +47 -0
  74. package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
  75. package/dist/app/lib/routing/components/BrowserRouter.js +95 -19
  76. package/dist/app/lib/routing/components/ClientOnly.d.ts +1 -1
  77. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  78. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  79. package/dist/app/lib/routing/components/Link.js +11 -12
  80. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  81. package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
  82. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  83. package/dist/app/lib/routing/components/SSRRouter.js +5 -6
  84. package/dist/app/lib/routing/components/ScrollRestoration.js +5 -2
  85. package/dist/app/lib/routing/context.d.ts +8 -5
  86. package/dist/app/lib/routing/context.js +13 -96
  87. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
  88. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  89. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
  90. package/dist/app/lib/routing/hooks/useRoute.js +22 -1
  91. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
  92. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  93. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  94. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  95. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  96. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  97. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  98. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  99. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  100. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  101. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  102. package/dist/app/lib/routing/index.d.ts +14 -13
  103. package/dist/app/lib/routing/index.js +14 -13
  104. package/dist/app/lib/routing/loader.d.ts +2 -2
  105. package/dist/app/lib/routing/loader.js +20 -11
  106. package/dist/app/lib/routing/types.d.ts +36 -10
  107. package/dist/app/lib/routing/utils.d.ts +5 -2
  108. package/dist/app/lib/routing/utils.js +37 -4
  109. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
  110. package/dist/app/lib/runtime/apiConfig.js +6 -0
  111. package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
  112. package/dist/app/lib/runtime/errorHandling.js +6 -0
  113. package/dist/app/lib/runtime/index.d.ts +2 -0
  114. package/dist/app/lib/runtime/index.js +2 -0
  115. package/dist/app/lib/views/index.d.ts +1 -1
  116. package/dist/app/lib/views/index.js +1 -1
  117. package/dist/app/server/defineRouter.d.ts +2 -0
  118. package/dist/app/server/defineRouter.js +4 -0
  119. package/dist/app/server/index.d.ts +5 -3
  120. package/dist/app/server/index.js +5 -3
  121. package/dist/app/server/proxy-wp-admin.d.ts +1 -2
  122. package/dist/app/server/proxy-wp-admin.js +32 -14
  123. package/dist/app/server/render-ssr-page.d.ts +21 -2
  124. package/dist/app/server/render-ssr-page.js +143 -11
  125. package/dist/app/server/rpc.d.ts +56 -0
  126. package/dist/app/server/rpc.js +18 -0
  127. package/dist/app/server/server-context.d.ts +42 -4
  128. package/dist/app/server/server-context.js +196 -30
  129. package/dist/app/server/utils/replace-host.d.ts +1 -1
  130. package/dist/app/server/utils/replace-host.js +10 -2
  131. package/dist/app/server/utils/swr-cache.d.ts +4 -0
  132. package/dist/app/server/utils/swr-cache.js +31 -0
  133. package/dist/app/utils/APIProvider.d.ts +2 -0
  134. package/dist/app/utils/APIProvider.js +5 -0
  135. package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
  136. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  137. package/dist/app/utils/ErrorMessage.d.ts +5 -0
  138. package/dist/app/utils/ErrorMessage.js +14 -0
  139. package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
  140. package/dist/app/utils/RouteErrorBoundary.js +38 -0
  141. package/dist/app/utils/asset-capture.d.ts +2 -0
  142. package/dist/app/utils/asset-capture.js +5 -0
  143. package/dist/app/utils/hydration-debugger.d.ts +13 -0
  144. package/dist/app/utils/hydration-debugger.js +11 -0
  145. package/dist/app/utils/query-client.d.ts +2 -0
  146. package/dist/app/utils/query-client.js +5 -1
  147. package/dist/app/utils/trpc-client.d.ts +2 -0
  148. package/dist/app/utils/trpc-client.js +39 -0
  149. package/dist/node/cli/cli-worker.js +10 -5
  150. package/dist/node/cli/cli.js +79 -11
  151. package/dist/node/cli/display/CLIApp.js +3 -6
  152. package/dist/node/cli/display/boot-cli-app.js +1 -1
  153. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
  154. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
  155. package/dist/node/cli/display/tools/cli-tools.js +9 -9
  156. package/dist/node/cli/version.d.ts +1 -1
  157. package/dist/node/cli/version.js +1 -1
  158. package/dist/node/compiler/build-vinxi.js +3 -1
  159. package/dist/node/compiler/bundler.admin.d.ts +1 -1
  160. package/dist/node/compiler/bundler.admin.js +1 -1
  161. package/dist/node/compiler/bundler.frontend.js +1 -1
  162. package/dist/node/compiler/dev-server.js +10 -0
  163. package/dist/node/compiler/get-vite-config.d.ts +1 -0
  164. package/dist/node/compiler/get-vite-config.js +34 -11
  165. package/dist/node/compiler/vinxi-app.d.ts +12 -0
  166. package/dist/node/compiler/vinxi-app.js +139 -32
  167. package/dist/node/compiler/vinxi-codegen.js +321 -108
  168. package/dist/node/graphql/graphql-codegen.d.ts +11 -1
  169. package/dist/node/graphql/graphql-codegen.js +210 -33
  170. package/dist/node/graphql/graphql-schema-loader.d.ts +2 -1
  171. package/dist/node/graphql/graphql-schema-loader.js +5 -16
  172. package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
  173. package/dist/node/graphql/query-files-loader.d.ts +3 -0
  174. package/dist/node/graphql/query-files-loader.js +5 -0
  175. package/dist/node/project/config.d.ts +159 -73
  176. package/dist/node/project/config.js +69 -20
  177. package/dist/node/project/env.d.ts +4 -0
  178. package/dist/node/project/env.js +1 -0
  179. package/dist/node/project/manifest/block-manifest.js +1 -0
  180. package/dist/node/project/manifest/manifest.d.ts +1 -0
  181. package/dist/node/project/manifest/manifest.js +14 -10
  182. package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
  183. package/dist/node/project/manifest/routes-manifest.js +74 -0
  184. package/dist/node/project/manifest/view-manifest.js +1 -1
  185. package/dist/node/project/project.d.ts +9 -1
  186. package/dist/node/project/project.js +37 -6
  187. package/dist/node/project/wp-info.d.ts +1 -0
  188. package/dist/node/project/wp-info.js +13 -1
  189. package/dist/node/types/block-type.d.ts +25 -20
  190. package/dist/node/types/block-type.js +1 -0
  191. package/dist/node/types/view-type.d.ts +7 -7
  192. package/dist/node/utils/fetch-wp.d.ts +1 -0
  193. package/dist/node/utils/fetch-wp.js +27 -0
  194. package/dist/node/utils/fs-codegen.d.ts +2 -0
  195. package/dist/node/utils/fs-codegen.js +2 -1
  196. package/dist/node/utils/is-deploying.js +1 -1
  197. package/dist/node/utils/stateful-log.js +2 -0
  198. package/dist/node/utils/watch-file-tree.d.ts +17 -3
  199. package/dist/node/utils/watch-file-tree.js +12 -5
  200. package/package.json +17 -13
  201. package/types.app.d.ts +4 -2
  202. package/types.app.internal.d.ts +2 -2
  203. package/types.node.d.ts +3 -3
  204. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  205. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  206. package/dist/app/lib/hooks/apiConfig.js +0 -4
  207. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  208. package/dist/app/lib/hooks/usePageLoad.js +0 -5
  209. package/dist/app/server/utils/index.html.d.ts +0 -2
  210. package/dist/app/server/utils/index.html.js +0 -14
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ // "use client"
2
+ export {};
@@ -0,0 +1,7 @@
1
+ import { RouteMetaTag } from "../lib/routing";
2
+ type Props = {
3
+ debugKey?: string;
4
+ tags: RouteMetaTag[];
5
+ };
6
+ export declare function MetaTags(props: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ export function MetaTags(props) {
3
+ return (_jsx(_Fragment, { children: props.tags?.map((tag, i) => {
4
+ const Tag = tag.tagName;
5
+ const tagProps = Array.isArray(tag.attributes) ? {} : { ...tag.attributes };
6
+ if (tag.tagName === "title") {
7
+ tagProps.children = tag.inner ?? "";
8
+ }
9
+ else if (tag.tagName === "script" || !!tag.inner) {
10
+ tagProps.dangerouslySetInnerHTML = { __html: tag.inner ?? "" };
11
+ }
12
+ if (tagProps.async === "") {
13
+ tagProps.async = true;
14
+ }
15
+ return _jsx(Tag, { ...tagProps }, i);
16
+ }) }));
17
+ }
@@ -1,8 +1,13 @@
1
- import { installFieldTypes } from "../lib/admin/installFieldTypes";
2
- import { runWidgets } from "../lib/admin/runWidgets";
3
- import { installEDGutenbergHooks } from "../lib/blocks/editor/installGutenbergHooks";
1
+ import { installFieldTypes } from "../lib/admin/installFieldTypes.js";
2
+ import { runWidgets } from "../lib/admin/runWidgets.js";
3
+ import { installEDGutenbergHooks } from "../lib/blocks/editor/installGutenbergHooks.js";
4
4
  export default function bootAdmin() {
5
- installEDGutenbergHooks();
6
- installFieldTypes();
7
- runWidgets();
5
+ console.log("Booting admin");
6
+ if (window.name === "editor-canvas") {
7
+ }
8
+ else {
9
+ installEDGutenbergHooks();
10
+ installFieldTypes();
11
+ runWidgets();
12
+ }
8
13
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { hydrationDebug } from "../utils/hydration-debugger";
2
+ //@ts-nocheck
3
+ // window.addEventListener("error", (event) => {
4
+ // const msg = event.message.toLowerCase()
5
+ // const isHydrationMsg = msg.includes("hydration") || msg.includes("hydrating")
6
+ // if (isHydrationMsg) {
7
+ // hydrationDebug.add({
8
+ // error: event.error,
9
+ // info: null,
10
+ // })
11
+ // }
12
+ // })
13
+ const root = document.getElementById("_app");
14
+ if (root) {
15
+ hydrationDebug.initialHTML = root.innerHTML;
16
+ }
17
+ // @ts-ignore
18
+ window.hydrationDebug = hydrationDebug;
@@ -1,9 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { QueryClientProvider } from "@tanstack/react-query";
3
- import { BrowserRouter } from "../lib/routing/components/BrowserRouter";
4
- import { getQueryClient } from "../utils/query-client";
5
- import { DevUILoader } from "../lib/devtools/loader";
6
2
  import { Suspense } from "react";
3
+ import { DevUILoader } from "../lib/devtools/loader.js";
4
+ import { BrowserRouter } from "../lib/routing/components/BrowserRouter.js";
5
+ import { APIProvider } from "../utils/APIProvider.js";
7
6
  export function SPARoot() {
8
- return (_jsxs(QueryClientProvider, { client: getQueryClient(), children: [_jsx(Suspense, { children: _jsx(BrowserRouter, {}) }), _jsx(DevUILoader, {})] }));
7
+ return (_jsxs(APIProvider, { children: [_jsx(Suspense, { children: _jsx(BrowserRouter, {}) }), _jsx(DevUILoader, {})] }));
9
8
  }
@@ -1,4 +1,6 @@
1
1
  import { ReactNode } from "react";
2
- export declare function SSRClientRoot({ assets }: {
2
+ import { RouteMetaTag } from "../lib/routing/types.js";
3
+ export declare function SSRClientRoot(props: {
3
4
  assets: ReactNode;
5
+ metaTags: RouteMetaTag[];
4
6
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,25 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { QueryClientProvider } from "@tanstack/react-query";
3
- import { Suspense } from "react";
4
- import { getQueryClient } from "../utils/query-client";
5
- import { BrowserRouter } from "../lib/routing/components/BrowserRouter";
6
- import { DevUILoader } from "../lib/devtools/loader";
7
- export function SSRClientRoot({ assets }) {
8
- return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("link", { rel: "icon", href: "/favicon.ico" }), assets] }), _jsx("body", { children: _jsxs(QueryClientProvider, { client: getQueryClient(), children: [_jsx(Suspense, { children: _jsx(BrowserRouter, {}) }), _jsx(DevUILoader, {})] }) })] }));
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Suspense, useEffect, useState } from "react";
3
+ import { useSnapshot } from "valtio";
4
+ import { BrowserRouter } from "../lib/routing/components/BrowserRouter.js";
5
+ import { clientMetaTags } from "../lib/routing/context.js";
6
+ import { APIProvider } from "../utils/APIProvider.js";
7
+ import { MetaTags } from "./MetaTags.js";
8
+ export function SSRClientRoot(props) {
9
+ return (_jsx(APIProvider, { children: _jsx(Suspense, { children: _jsx(BrowserRouter, {}) }) }));
10
+ }
11
+ function DynamicMetaTags(props) {
12
+ const dynamicTags = useSnapshot(clientMetaTags).tags;
13
+ return _jsx(MetaTags, { tags: dynamicTags ?? props.tags ?? [] });
14
+ }
15
+ function Trackers(props) {
16
+ const [render, setRender] = useState(false);
17
+ // @ts-ignore
18
+ const trackers = window._TRACKERS;
19
+ useEffect(() => {
20
+ setRender(true);
21
+ }, []);
22
+ if (!render || !trackers || typeof trackers !== "object")
23
+ return null;
24
+ return (_jsx(_Fragment, { children: _jsx(MetaTags, { tags: trackers[props.position] ?? [] }) }));
9
25
  }
@@ -1,9 +1,10 @@
1
- import type { ReactNode } from "react";
2
- import type { RouteData } from "../lib/routing";
3
- import type { RouteLoader } from "../lib/routing/loader";
4
- export declare function SSRRoot(args: {
1
+ import { type ReactNode } from "react";
2
+ import type { RouteLoader } from "../lib/routing/loader.js";
3
+ import type { RouteData, RouteMetaTag } from "../lib/routing/types.js";
4
+ export declare function SSRRoot(props: {
5
5
  pathname: string;
6
6
  initialData: RouteData;
7
7
  assets: ReactNode;
8
8
  loader: RouteLoader;
9
+ metaTags: RouteMetaTag[];
9
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,21 +1,22 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { QueryClientProvider } from "@tanstack/react-query";
3
- import { getQueryClient } from "../utils/query-client";
4
- import { SSRRouter } from "../lib/routing/components/SSRRouter";
5
- import { normalizeRoute } from "../lib/routing/utils";
6
- export function SSRRoot(args) {
7
- const loader = args.loader;
8
- loader.setAppData(args.initialData.appData.data);
9
- loader.populateRouteData(args.pathname, args.initialData);
10
- return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("link", { rel: "icon", href: "/favicon.ico" }), args.assets] }), _jsx("body", { children: _jsx(QueryClientProvider, { client: getQueryClient(), children: _jsx(SSRRouter, { loader: loader, route: normalizeRoute({
11
- id: "initial",
12
- component: loader.getRouteComponent(args.initialData.view),
13
- key: "",
14
- props: args.initialData.viewData.data,
15
- view: args.initialData.view,
16
- search: "",
17
- pathname: args.pathname,
18
- query: {},
19
- hash: "",
20
- }) }) }) })] }));
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Suspense } from "react";
3
+ import { SSRRouter } from "../lib/routing/components/SSRRouter.js";
4
+ import { getRouteMeta, normalizeRoute } from "../lib/routing/utils.js";
5
+ import { APIProvider } from "../utils/APIProvider.js";
6
+ export function SSRRoot(props) {
7
+ const loader = props.loader;
8
+ loader.setAppData(props.initialData.appData.data);
9
+ loader.populateRouteData(props.pathname, props.initialData);
10
+ return (_jsx(APIProvider, { children: _jsx(Suspense, { children: _jsx(SSRRouter, { loader: loader, route: normalizeRoute({
11
+ id: "initial",
12
+ component: loader.getRouteComponent(props.initialData.view),
13
+ key: "",
14
+ props: props.initialData.viewData.data,
15
+ view: props.initialData.view,
16
+ search: "",
17
+ pathname: props.pathname,
18
+ query: {},
19
+ hash: "",
20
+ meta: getRouteMeta(props.initialData),
21
+ }) }) }) }));
21
22
  }
@@ -1,2 +1,2 @@
1
- export * from "./defineField";
2
- export * from "./defineWidget";
1
+ export * from "./defineField.js";
2
+ export * from "./defineWidget.js";
@@ -1,2 +1,2 @@
1
- export * from "./defineField";
2
- export * from "./defineWidget";
1
+ export * from "./defineField.js";
2
+ export * from "./defineWidget.js";
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import * as ReactDOM from "react-dom/client";
4
- import { adminManifestReader } from "../internal";
4
+ import { adminManifestReader } from "../internal/read-admin-manifest.js";
5
5
  export function installFieldTypes() {
6
6
  // @ts-ignore
7
7
  const acf = window.acf;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import * as ReactDOM from "react-dom/client";
4
- import { adminManifestReader } from "../internal";
4
+ import { adminManifestReader } from "../internal/read-admin-manifest.js";
5
5
  export function runWidgets() {
6
6
  const elements = document.querySelectorAll("[data-widget]");
7
7
  setTimeout(() => {
@@ -20,7 +20,7 @@ export type ContentBlock = {
20
20
  /**
21
21
  * Represents a block instance's position in the hierarchy via relationships with other blocks.
22
22
  */
23
- type BlocksContext = {
23
+ export type BlocksContext = {
24
24
  ancestors: ContentBlock[];
25
25
  parent?: ContentBlock;
26
26
  prev?: ContentBlock;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Fragment, createContext, memo, useContext, useMemo } from "react";
3
- import { blockManifestReader } from "../internal/read-block-manifest";
4
- import { ErrorBoundaryFrontend } from "./ErrorBoundaryFrontend";
5
- import { InlineEditingContextProvider, ReadonlyInlineEditingProvider } from "./inline-editing";
6
- import { addBlockMetadata } from "./block-utils";
3
+ import { blockManifestReader } from "../internal/read-block-manifest.js";
4
+ import { BlockErrorBoundary } from "../../utils/BlockErrorBoundary.js";
5
+ import { InlineEditingContextProvider, ReadonlyInlineEditingProvider } from "./inline-editing.js";
6
+ import { addBlockMetadata } from "./block-utils.js";
7
7
  export const BlocksContext = createContext(undefined);
8
8
  /**
9
9
  * Render a set of Gutenberg blocks
@@ -63,7 +63,7 @@ export const ContentBlocks = memo((props) => {
63
63
  }
64
64
  }
65
65
  // Attempt to wrap the block
66
- return (_jsxs(Fragment, { children: [spaceBefore, _jsx(ErrorBoundaryFrontend, { children: blockNode }), spaceAfter] }, index));
66
+ return (_jsxs(Fragment, { children: [spaceBefore, _jsx(BlockErrorBoundary, { block: block, blockContext: ctx, children: blockNode }), spaceAfter] }, block.slug + "_" + index));
67
67
  });
68
68
  }, [blocks, props.wrapBlock, props.spacer]);
69
69
  if (env.admin) {
@@ -1,5 +1,5 @@
1
1
  import { ElementType } from "react";
2
- import { InlineValueStore } from "./inline-editing";
2
+ import { InlineValueStore } from "./inline-editing.js";
3
3
  export type InlineTextValueStore = InlineValueStore<string>;
4
4
  type Props<T extends ElementType> = {
5
5
  /** Specify a tag name or React component */
@@ -1,13 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useRouter } from "../routing";
3
- import { useBlockAppender, useBlockContext, useValueStore } from "./inline-editing";
2
+ import { useRouter } from "../routing/hooks/useRouter.js";
3
+ import { useBlockAppender, useBlockContext, useValueStore } from "./inline-editing.js";
4
4
  export function EditableText({ id, as, appendOnEnter, store, ...props }) {
5
5
  if (env.admin) {
6
6
  const readOnly = useBlockContext()?.readonly;
7
7
  if (!readOnly) {
8
8
  const [value, setValue] = useValueStore(store ?? id);
9
9
  const appendBlocks = useBlockAppender();
10
- return (_jsx(wp.blockEditor.RichText, { ...props, tagName: as, value: value || "", onChange: setValue, disableLineBreaks: props.disableLineBreaks, onKeyDownCapture: (e) => {
10
+ return (_jsx(wp.blockEditor.RichText, { ...props, placeholder: props.placeholder ?? props.defaultValue, tagName: as, value: value || "", onChange: setValue, inlineToolbar: props.inlineToolbar, disableLineBreaks: props.disableLineBreaks, onKeyDownCapture: (e) => {
11
11
  if (e.key === "Enter" && appendOnEnter && appendBlocks) {
12
12
  appendBlocks([
13
13
  wp.blocks.createBlock(typeof appendOnEnter === "string" ? appendOnEnter : "core/paragraph"),
@@ -1,10 +1,20 @@
1
1
  import { FunctionComponent } from "react";
2
- import { ContentBlockLayoutProps } from "./ContentBlocks";
3
- import { BlockTemplate } from "./editor/block-templates";
2
+ import { ContentBlockLayoutProps } from "./ContentBlocks.js";
3
+ import { BlockTemplate } from "./editor/block-templates.js";
4
4
  type AppenderConfig = {
5
- type: "default" | "button" | FunctionComponent<any>;
5
+ type: "default" | "button" | CustomBlockAppender;
6
6
  className?: string;
7
7
  };
8
+ export type CustomBlockAppender = FunctionComponent<{
9
+ onToggle: () => void;
10
+ disabled: boolean;
11
+ isOpen: boolean;
12
+ blockTitle: string;
13
+ hasSingleBlockType: boolean;
14
+ }>;
15
+ export declare function createAppender(comp: CustomBlockAppender): {
16
+ type: CustomBlockAppender;
17
+ };
8
18
  type InnerBlocksProps = {
9
19
  /** A list of allowed blocks, and/or block tags. */
10
20
  allowedBlocks?: (ChildBlockTypeName | BlockTagName)[];
@@ -1,15 +1,18 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ContentBlocks } from "./ContentBlocks";
3
- import { transformBlockTemplate } from "./editor/block-templates";
4
- import { blocksByTag } from "./editor/blocks-by-tag";
5
- import { useBlockContext, useInnerBlocks } from "./inline-editing";
2
+ import { ContentBlocks } from "./ContentBlocks.js";
3
+ import { transformBlockTemplate } from "./editor/block-templates.js";
4
+ import { blocksByTag } from "./editor/blocks-by-tag.js";
5
+ import { useBlockContext, useInnerBlocks } from "./inline-editing.js";
6
6
  const Appender = (props) => {
7
7
  const clientId = useBlockContext()?.block[1].clientId;
8
8
  if (props.type === "button") {
9
9
  return _jsx(wp.blockEditor.ButtonBlockAppender, { className: props.className, rootClientId: clientId });
10
10
  }
11
11
  else if (typeof props.type === "function") {
12
- return props.type({});
12
+ const Type = props.type;
13
+ return (_jsx(wp.blockEditor.Inserter, { renderToggle: (p) => {
14
+ return _jsx(Type, { ...p });
15
+ }, rootClientId: clientId }));
13
16
  }
14
17
  else {
15
18
  return (_jsx(wp.blockEditor.DefaultBlockAppender
@@ -19,6 +22,11 @@ const Appender = (props) => {
19
22
  className: props.className, rootClientId: clientId, lastBlockClientId: clientId }));
20
23
  }
21
24
  };
25
+ export function createAppender(comp) {
26
+ return {
27
+ type: comp,
28
+ };
29
+ }
22
30
  /**
23
31
  * Allows child blocks to be added to the current block context.
24
32
  */
@@ -1,4 +1,4 @@
1
- import { ContentBlock } from "./ContentBlocks";
1
+ import { ContentBlock } from "./ContentBlocks.js";
2
2
  /**
3
3
  * Returns some very basic info about blocks in the project.
4
4
  * This is purposely lean, to avoid bloated info.
@@ -12,7 +12,7 @@ export declare function getPublicBlockInfo(): {
12
12
  *
13
13
  * Note that this function mutates the existing block, adding new properties.
14
14
  */
15
- export declare function addBlockMetadata(blocks: ContentBlock[]): ContentBlock[];
15
+ export declare function addBlockMetadata(blocks: ContentBlock[] | null | undefined): ContentBlock[];
16
16
  export declare function getBlockMetadata(blockName: string): {
17
17
  slug: string;
18
18
  tags?: undefined;
@@ -1,4 +1,4 @@
1
- import { blockManifestReader } from "../internal";
1
+ import { blockManifestReader } from "../internal/read-block-manifest.js";
2
2
  /**
3
3
  * Returns some very basic info about blocks in the project.
4
4
  * This is purposely lean, to avoid bloated info.
@@ -13,7 +13,7 @@ export function getPublicBlockInfo() {
13
13
  * Note that this function mutates the existing block, adding new properties.
14
14
  */
15
15
  export function addBlockMetadata(blocks) {
16
- const out = blocks;
16
+ const out = (blocks ?? []);
17
17
  const infos = getPublicBlockInfo();
18
18
  for (let block of out) {
19
19
  const info = infos[block.blockName];
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from "react";
2
+ type Props = PropsWithChildren<{
3
+ enabled: boolean;
4
+ clientId: string;
5
+ }>;
6
+ export declare function EditorHighlights(props: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,130 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ export function EditorHighlights(props) {
4
+ const ref = useRef(null);
5
+ const [controller, setController] = useState(null);
6
+ // wp.data.select('core/editor').isBlockSelected
7
+ // const isSelected = wp.data.useSelect(
8
+ // (select) => (select("core/editor") as any).isBlockSelected(props.clientId),
9
+ // [props.clientId]
10
+ // )
11
+ useEffect(() => {
12
+ if (!props.enabled)
13
+ return;
14
+ const controller = new HighlightController(ref.current);
15
+ setController(controller);
16
+ return () => controller.teardown();
17
+ }, [props.enabled]);
18
+ useEffect(() => {
19
+ if (controller) {
20
+ controller.isSelected = false;
21
+ controller.updateClasses();
22
+ controller.update();
23
+ }
24
+ }, [controller, false]);
25
+ return (_jsx("div", { ref: ref, style: { display: "contents" }, onPointerEnter: () => controller?.enable(), onPointerLeave: () => controller?.disable(), children: props.children }));
26
+ }
27
+ class HighlightController {
28
+ root;
29
+ enabled = false;
30
+ disposers = [];
31
+ elements = new Map();
32
+ block = null;
33
+ isSelected = false;
34
+ constructor(root) {
35
+ this.root = root;
36
+ }
37
+ setup() {
38
+ this.teardown();
39
+ const updateElements = () => {
40
+ let editables = Array.from(this.root.querySelectorAll("[contenteditable=true], .editable-slot"));
41
+ let childBlocks = Array.from(this.root.querySelectorAll(".wp-block"));
42
+ const childIsSelected = this.root.querySelectorAll(".editor-highlighter-root-selected").length > 0;
43
+ this.block = childBlocks[0];
44
+ childBlocks = childBlocks.slice(1);
45
+ editables = childIsSelected
46
+ ? []
47
+ : editables.filter((element) => !childBlocks.some((block) => block.contains(element)));
48
+ let changed = false;
49
+ for (const [el, item] of this.elements) {
50
+ if (!editables.includes(el)) {
51
+ item.observer.disconnect();
52
+ item.overlay.remove();
53
+ this.elements.delete(el);
54
+ changed = true;
55
+ }
56
+ }
57
+ for (let el of editables) {
58
+ if (!this.elements.has(el)) {
59
+ const observer = new ResizeObserver(() => this.update());
60
+ observer.observe(el);
61
+ this.elements.set(el, {
62
+ observer,
63
+ bounds: el.getBoundingClientRect(),
64
+ overlay: this.createOverlay(el),
65
+ });
66
+ changed = true;
67
+ }
68
+ }
69
+ if (changed) {
70
+ this.update();
71
+ this.updateClasses();
72
+ }
73
+ };
74
+ const mutationObserver = new MutationObserver(() => {
75
+ updateElements();
76
+ });
77
+ updateElements();
78
+ mutationObserver.observe(this.root, { childList: true, subtree: true });
79
+ this.disposers.push(() => {
80
+ mutationObserver.disconnect();
81
+ for (const item of this.elements.values()) {
82
+ item.observer.disconnect();
83
+ item.overlay.remove();
84
+ }
85
+ this.elements = new Map();
86
+ });
87
+ }
88
+ updateClasses() {
89
+ for (const item of this.elements.values()) {
90
+ item.overlay.classList.toggle("editor-highlight-selected", this.isSelected);
91
+ }
92
+ this.root.classList.toggle("editor-highlighter-root-selected", this.enabled);
93
+ }
94
+ createOverlay(target) {
95
+ const el = document.createElement("div");
96
+ el.style.position = "absolute";
97
+ el.style.pointerEvents = "none";
98
+ el.style.zIndex = "20";
99
+ el.className = "editor-highlight";
100
+ this.block.appendChild(el);
101
+ return el;
102
+ }
103
+ teardown() {
104
+ this.disposers.forEach((dispose) => dispose());
105
+ }
106
+ enable() {
107
+ this.enabled = true;
108
+ this.setup();
109
+ this.update();
110
+ this.updateClasses();
111
+ }
112
+ disable() {
113
+ this.enabled = false;
114
+ this.teardown();
115
+ this.update();
116
+ this.updateClasses();
117
+ }
118
+ update() {
119
+ if (!this.block)
120
+ return;
121
+ const rootBounds = this.block.getBoundingClientRect();
122
+ for (const [el, item] of this.elements) {
123
+ const bounds = el.getBoundingClientRect();
124
+ item.overlay.style.left = bounds.left - rootBounds.left + "px";
125
+ item.overlay.style.top = bounds.top - rootBounds.top + "px";
126
+ item.overlay.style.width = bounds.width + "px";
127
+ item.overlay.style.height = bounds.height + "px";
128
+ }
129
+ }
130
+ }
@@ -1,9 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { QueryClientProvider } from "@tanstack/react-query";
3
2
  import { createContext, Suspense, useContext } from "react";
4
- import { getQueryClient } from "../../../utils/query-client";
5
- import { blockManifestReader } from "../../internal";
6
- import { ErrorBoundaryEditor } from "./ErrorBoundaryEditor";
3
+ import { blockManifestReader } from "../../internal/read-block-manifest.js";
4
+ import { APIProvider } from "../../../utils/APIProvider.js";
5
+ import { ErrorBoundaryEditor } from "./ErrorBoundaryEditor.js";
7
6
  export const BlockContext = createContext(undefined);
8
7
  export function EditableBlock({ payload }) {
9
8
  const block = useContext(BlockContext);
@@ -15,5 +14,5 @@ export function EditableBlock({ payload }) {
15
14
  const BlockComponent = getBlock();
16
15
  if (!BlockComponent)
17
16
  return _jsx("div", { children: "Unable to load block component" });
18
- return (_jsx(ErrorBoundaryEditor, { children: _jsx(QueryClientProvider, { client: getQueryClient(), children: _jsx(Suspense, { children: _jsx(BlockComponent, { ...payload }) }) }) }));
17
+ return (_jsx(ErrorBoundaryEditor, { children: _jsx(APIProvider, { children: _jsx(Suspense, { children: _jsx(BlockComponent, { ...payload }) }) }) }));
19
18
  }
@@ -10,6 +10,6 @@ export declare class ErrorBoundaryEditor extends Component<Props, State> {
10
10
  state: State;
11
11
  static getDerivedStateFromError(err: Error): State;
12
12
  componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
13
- render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | null | undefined;
13
+ render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
14
14
  }
15
15
  export {};
@@ -1,7 +1,20 @@
1
- import { BlockTemplate } from "./block-templates";
1
+ import { BlockTemplate } from "./block-templates.js";
2
2
  export type EditorConfigItem = {
3
- /** Optionally indicate that the post title field should be hidden. Use then when your header template includes a post title editor already. */
3
+ /**
4
+ * Optionally indicate that the post title field should be hidden. Use then when your header template includes a post title editor already.
5
+ * @default false
6
+ **/
4
7
  hideTitle?: boolean;
8
+ /**
9
+ * Override the blocks which are allowed to be added to the root of this post-type/template combination.
10
+ *
11
+ * You can specify one or more block names, or block tags.
12
+ *
13
+ * The default is "root".
14
+ *
15
+ * @default ["root"]
16
+ **/
17
+ rootBlocks?: (ChildBlockTypeName | BlockTagName)[];
5
18
  /** Allows you to add additional class names to blocks, depending on their type and state */
6
19
  generateBlockClassName?: BlockWrapperClassGenerator;
7
20
  /** The default blocks to insert when there are no (non-templated) blocks */
@@ -28,10 +41,10 @@ type BlockWrapperClassGenerator = (block: {
28
41
  }, post: PostInfo) => string | void;
29
42
  export declare const editorConfigStore: {
30
43
  config: EditorConfig | null;
31
- currentBlocksConfig: EditorConfigItem | null;
44
+ currentBlocksConfig: EditorConfigItem;
32
45
  };
33
46
  export declare function configureEditorBlocks(config: EditorConfigItem): void;
34
- export declare function transformTemplateToBlocks(template: BlockTemplate, locked?: boolean): any;
47
+ export declare function transformTemplateToBlocks(template: BlockTemplate, locked?: boolean, isFromTemplate?: boolean): any;
35
48
  type PostInfo = {
36
49
  template: TemplateName | "default";
37
50
  type: PostTypeName;