eddev 2.0.0-beta.12 → 2.0.0-beta.120

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 (224) hide show
  1. package/css/editor-styles.css +4 -0
  2. package/dist/app/entry/HydrationOverlay.d.ts +1 -0
  3. package/dist/app/entry/HydrationOverlay.js +2 -0
  4. package/dist/app/entry/MetaTags.d.ts +7 -0
  5. package/dist/app/entry/MetaTags.js +17 -0
  6. package/dist/app/entry/boot-admin.js +9 -3
  7. package/dist/app/entry/hydration-script.d.ts +1 -0
  8. package/dist/app/entry/hydration-script.js +18 -0
  9. package/dist/app/entry/spa-root.js +3 -5
  10. package/dist/app/entry/ssr-root-client.d.ts +3 -1
  11. package/dist/app/entry/ssr-root-client.js +18 -6
  12. package/dist/app/entry/ssr-root.d.ts +3 -4
  13. package/dist/app/entry/ssr-root.js +19 -19
  14. package/dist/app/lib/admin/index.d.ts +2 -2
  15. package/dist/app/lib/admin/index.js +2 -2
  16. package/dist/app/lib/admin/installFieldTypes.js +1 -1
  17. package/dist/app/lib/admin/runWidgets.js +1 -1
  18. package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
  19. package/dist/app/lib/blocks/ContentBlocks.js +5 -5
  20. package/dist/app/lib/blocks/EditableText.d.ts +15 -2
  21. package/dist/app/lib/blocks/EditableText.js +10 -4
  22. package/dist/app/lib/blocks/InnerBlocks.d.ts +21 -7
  23. package/dist/app/lib/blocks/InnerBlocks.js +75 -28
  24. package/dist/app/lib/blocks/block-utils.d.ts +2 -2
  25. package/dist/app/lib/blocks/block-utils.js +2 -2
  26. package/dist/app/lib/blocks/defineBlock.d.ts +3 -0
  27. package/dist/app/lib/blocks/defineBlock.js +7 -0
  28. package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +7 -0
  29. package/dist/app/lib/blocks/editor/EditorHighlights.js +164 -0
  30. package/dist/app/lib/blocks/editor/EditorSupport.js +17 -12
  31. package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +1 -1
  32. package/dist/app/lib/blocks/editor/block-templates.d.ts +6 -0
  33. package/dist/app/lib/blocks/editor/block-templates.js +64 -0
  34. package/dist/app/lib/blocks/editor/create-block.d.ts +9 -0
  35. package/dist/app/lib/blocks/editor/create-block.js +13 -0
  36. package/dist/app/lib/blocks/editor/editor-config.d.ts +70 -7
  37. package/dist/app/lib/blocks/editor/editor-config.js +29 -62
  38. package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts +3 -0
  39. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +105 -16
  40. package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
  41. package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
  42. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  43. package/dist/app/lib/blocks/index.d.ts +10 -9
  44. package/dist/app/lib/blocks/index.js +10 -9
  45. package/dist/app/lib/blocks/inline-editing.d.ts +9 -1
  46. package/dist/app/lib/blocks/inline-editing.js +7 -5
  47. package/dist/app/lib/devtools/components/BreakpointIndicator.js +1 -1
  48. package/dist/app/lib/devtools/components/DevUI.js +4 -3
  49. package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
  50. package/dist/app/lib/devtools/components/GridIndicator.js +29 -0
  51. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
  52. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  53. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +2305 -1261
  54. package/dist/app/lib/devtools/hooks/useTailwind.js +1 -1
  55. package/dist/app/lib/devtools/index.d.ts +1 -1
  56. package/dist/app/lib/devtools/index.js +1 -1
  57. package/dist/app/lib/devtools/loader.js +8 -7
  58. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  59. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  60. package/dist/app/lib/dynamic/dynamic.d.ts +1 -1
  61. package/dist/app/lib/dynamic/dynamic.js +5 -1
  62. package/dist/app/lib/dynamic/index.d.ts +1 -1
  63. package/dist/app/lib/dynamic/index.js +1 -1
  64. package/dist/app/lib/hooks/index.d.ts +4 -5
  65. package/dist/app/lib/hooks/index.js +4 -5
  66. package/dist/app/lib/hooks/queryUtils.d.ts +37 -3
  67. package/dist/app/lib/hooks/queryUtils.js +66 -26
  68. package/dist/app/lib/hooks/useAppData.js +12 -1
  69. package/dist/app/lib/hooks/useRPC.d.ts +0 -4
  70. package/dist/app/lib/hooks/useRPC.js +1 -8
  71. package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
  72. package/dist/app/lib/internal/finalize-rpc.js +3 -0
  73. package/dist/app/lib/internal/index.d.ts +5 -4
  74. package/dist/app/lib/internal/index.js +5 -4
  75. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  76. package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
  77. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  78. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  79. package/dist/app/lib/legacy-stitches/index.js +1 -1
  80. package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
  81. package/dist/app/lib/routing/components/BackButton.js +47 -0
  82. package/dist/app/lib/routing/components/BrowserRouter.d.ts +5 -1
  83. package/dist/app/lib/routing/components/BrowserRouter.js +98 -19
  84. package/dist/app/lib/routing/components/ClientOnly.d.ts +1 -1
  85. package/dist/app/lib/routing/components/ClientOnly.js +2 -2
  86. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  87. package/dist/app/lib/routing/components/Link.js +11 -12
  88. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  89. package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
  90. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  91. package/dist/app/lib/routing/components/SSRRouter.js +5 -6
  92. package/dist/app/lib/routing/components/ScrollRestoration.js +5 -2
  93. package/dist/app/lib/routing/context.d.ts +8 -5
  94. package/dist/app/lib/routing/context.js +13 -96
  95. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
  96. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  97. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
  98. package/dist/app/lib/routing/hooks/useRoute.js +22 -1
  99. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
  100. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  101. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  102. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  103. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  104. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  105. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  106. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  107. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  108. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  109. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  110. package/dist/app/lib/routing/index.d.ts +14 -13
  111. package/dist/app/lib/routing/index.js +14 -13
  112. package/dist/app/lib/routing/loader.d.ts +2 -2
  113. package/dist/app/lib/routing/loader.js +20 -11
  114. package/dist/app/lib/routing/types.d.ts +37 -10
  115. package/dist/app/lib/routing/utils.d.ts +5 -2
  116. package/dist/app/lib/routing/utils.js +37 -4
  117. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
  118. package/dist/app/lib/runtime/apiConfig.js +6 -0
  119. package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
  120. package/dist/app/lib/runtime/errorHandling.js +6 -0
  121. package/dist/app/lib/runtime/index.d.ts +2 -0
  122. package/dist/app/lib/runtime/index.js +2 -0
  123. package/dist/app/lib/views/index.d.ts +1 -1
  124. package/dist/app/lib/views/index.js +1 -1
  125. package/dist/app/server/defineRouter.d.ts +2 -0
  126. package/dist/app/server/defineRouter.js +4 -0
  127. package/dist/app/server/index.d.ts +5 -3
  128. package/dist/app/server/index.js +5 -3
  129. package/dist/app/server/proxy-wp-admin.d.ts +1 -2
  130. package/dist/app/server/proxy-wp-admin.js +41 -14
  131. package/dist/app/server/render-ssr-page.d.ts +27 -2
  132. package/dist/app/server/render-ssr-page.js +192 -12
  133. package/dist/app/server/rpc.d.ts +56 -0
  134. package/dist/app/server/rpc.js +18 -0
  135. package/dist/app/server/server-context.d.ts +44 -4
  136. package/dist/app/server/server-context.js +302 -28
  137. package/dist/app/server/utils/replace-host.d.ts +1 -1
  138. package/dist/app/server/utils/replace-host.js +10 -2
  139. package/dist/app/server/utils/swr-cache.d.ts +4 -0
  140. package/dist/app/server/utils/swr-cache.js +31 -0
  141. package/dist/app/utils/APIProvider.d.ts +2 -0
  142. package/dist/app/utils/APIProvider.js +5 -0
  143. package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
  144. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  145. package/dist/app/utils/ErrorMessage.d.ts +5 -0
  146. package/dist/app/utils/ErrorMessage.js +14 -0
  147. package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
  148. package/dist/app/utils/RouteErrorBoundary.js +38 -0
  149. package/dist/app/utils/asset-capture.d.ts +2 -0
  150. package/dist/app/utils/asset-capture.js +5 -0
  151. package/dist/app/utils/hydration-debugger.d.ts +13 -0
  152. package/dist/app/utils/hydration-debugger.js +11 -0
  153. package/dist/app/utils/query-client.d.ts +2 -0
  154. package/dist/app/utils/query-client.js +5 -1
  155. package/dist/app/utils/query-monitor.d.ts +25 -0
  156. package/dist/app/utils/query-monitor.js +7 -0
  157. package/dist/app/utils/trpc-client.d.ts +2 -0
  158. package/dist/app/utils/trpc-client.js +39 -0
  159. package/dist/node/cli/cli-worker.js +10 -5
  160. package/dist/node/cli/cli.js +81 -11
  161. package/dist/node/cli/display/CLIApp.js +3 -6
  162. package/dist/node/cli/display/boot-cli-app.js +1 -1
  163. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
  164. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
  165. package/dist/node/cli/display/tools/cli-tools.js +9 -9
  166. package/dist/node/cli/version.d.ts +1 -1
  167. package/dist/node/cli/version.js +1 -1
  168. package/dist/node/compiler/build-vinxi.js +2 -1
  169. package/dist/node/compiler/bundler.admin.d.ts +1 -1
  170. package/dist/node/compiler/bundler.admin.js +1 -1
  171. package/dist/node/compiler/bundler.frontend.js +1 -1
  172. package/dist/node/compiler/dev-server.js +10 -0
  173. package/dist/node/compiler/get-vite-config.d.ts +7 -1
  174. package/dist/node/compiler/get-vite-config.js +96 -16
  175. package/dist/node/compiler/vinxi-app.d.ts +12 -0
  176. package/dist/node/compiler/vinxi-app.js +139 -32
  177. package/dist/node/compiler/vinxi-codegen.js +345 -112
  178. package/dist/node/graphql/graphql-codegen.d.ts +11 -1
  179. package/dist/node/graphql/graphql-codegen.js +210 -33
  180. package/dist/node/graphql/graphql-schema-loader.d.ts +2 -1
  181. package/dist/node/graphql/graphql-schema-loader.js +5 -16
  182. package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
  183. package/dist/node/graphql/query-files-loader.d.ts +3 -0
  184. package/dist/node/graphql/query-files-loader.js +5 -0
  185. package/dist/node/project/config.d.ts +159 -73
  186. package/dist/node/project/config.js +69 -20
  187. package/dist/node/project/env.d.ts +4 -0
  188. package/dist/node/project/env.js +1 -0
  189. package/dist/node/project/manifest/block-manifest.js +2 -1
  190. package/dist/node/project/manifest/manifest.d.ts +1 -0
  191. package/dist/node/project/manifest/manifest.js +14 -10
  192. package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
  193. package/dist/node/project/manifest/routes-manifest.js +74 -0
  194. package/dist/node/project/manifest/view-manifest.js +1 -1
  195. package/dist/node/project/project.d.ts +11 -1
  196. package/dist/node/project/project.js +61 -7
  197. package/dist/node/project/wp-info.d.ts +1 -0
  198. package/dist/node/project/wp-info.js +13 -1
  199. package/dist/node/storybook/index.d.ts +2 -0
  200. package/dist/node/storybook/index.js +13 -0
  201. package/dist/node/types/block-type.d.ts +25 -20
  202. package/dist/node/types/block-type.js +1 -0
  203. package/dist/node/types/view-type.d.ts +7 -7
  204. package/dist/node/utils/fetch-wp.d.ts +1 -0
  205. package/dist/node/utils/fetch-wp.js +27 -0
  206. package/dist/node/utils/fs-codegen.d.ts +2 -0
  207. package/dist/node/utils/fs-codegen.js +2 -1
  208. package/dist/node/utils/is-deploying.js +1 -1
  209. package/dist/node/utils/report-builder.d.ts +6 -6
  210. package/dist/node/utils/self-signed-cert.d.ts +2 -0
  211. package/dist/node/utils/self-signed-cert.js +10 -2
  212. package/dist/node/utils/stateful-log.js +2 -0
  213. package/dist/node/utils/watch-file-tree.d.ts +17 -3
  214. package/dist/node/utils/watch-file-tree.js +12 -5
  215. package/package.json +21 -12
  216. package/types.app.d.ts +4 -2
  217. package/types.app.internal.d.ts +2 -2
  218. package/types.meta.d.ts +105 -0
  219. package/types.node.d.ts +3 -3
  220. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  221. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  222. package/dist/app/lib/hooks/apiConfig.js +0 -4
  223. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  224. package/dist/app/lib/hooks/usePageLoad.js +0 -5
@@ -92,3 +92,7 @@
92
92
  .acf-block-panel .acf-empty-block-fields {
93
93
  display: none;
94
94
  }
95
+
96
+ .simple-appender {
97
+ display: inline-flex !important;
98
+ }
@@ -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
+ }
@@ -2,7 +2,13 @@ import { installFieldTypes } from "../lib/admin/installFieldTypes.js";
2
2
  import { runWidgets } from "../lib/admin/runWidgets.js";
3
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", window.name);
6
+ if (window.name === "editor-canvas") {
7
+ console.log("Running in the editor canvas");
8
+ }
9
+ else {
10
+ installEDGutenbergHooks();
11
+ installFieldTypes();
12
+ runWidgets();
13
+ }
8
14
  }
@@ -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,7 @@
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.js";
4
- import { getQueryClient } from "../utils/query-client.js";
5
2
  import { DevUILoader } from "../lib/devtools/loader.js";
6
- import { Suspense } from "react";
3
+ import { BrowserRouter } from "../lib/routing/components/BrowserRouter.js";
4
+ import { APIProvider } from "../utils/APIProvider.js";
7
5
  export function SPARoot() {
8
- return (_jsxs(QueryClientProvider, { client: getQueryClient(), children: [_jsx(Suspense, { children: _jsx(BrowserRouter, {}) }), _jsx(DevUILoader, {})] }));
6
+ return (_jsxs(APIProvider, { children: [_jsx(BrowserRouter, {}), _jsx(DevUILoader, {})] }));
9
7
  }
@@ -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,21 @@
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.js";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import { useSnapshot } from "valtio";
5
4
  import { BrowserRouter } from "../lib/routing/components/BrowserRouter.js";
5
+ import { clientMetaTags } from "../lib/routing/context.js";
6
+ import { APIProvider } from "../utils/APIProvider.js";
6
7
  import { DevUILoader } from "../lib/devtools/loader.js";
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, {})] }) })] }));
8
+ export function SSRClientRoot(props) {
9
+ return (_jsxs(APIProvider, { children: [_jsx(BrowserRouter, {}), _jsxs(_Fragment, { children: [_jsx(DynamicMetaTags, {}), _jsx(DevUILoader, {})] })] }));
10
+ }
11
+ function DynamicMetaTags() {
12
+ const dynamicTags = useSnapshot(clientMetaTags).tags;
13
+ useEffect(() => {
14
+ dynamicTags?.forEach((tag) => {
15
+ if (tag.tagName === "title") {
16
+ document.title = tag.inner ?? "";
17
+ }
18
+ });
19
+ });
20
+ return null;
9
21
  }
@@ -1,9 +1,8 @@
1
- import type { ReactNode } from "react";
2
- import type { RouteData } from "../lib/routing";
3
1
  import type { RouteLoader } from "../lib/routing/loader.js";
4
- export declare function SSRRoot(args: {
2
+ import type { RouteData, RouteMetaTag } from "../lib/routing/types.js";
3
+ export declare function SSRRoot(props: {
5
4
  pathname: string;
6
5
  initialData: RouteData;
7
- assets: ReactNode;
8
6
  loader: RouteLoader;
7
+ metaTags: RouteMetaTag[];
9
8
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,21 +1,21 @@
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.js";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
4
2
  import { SSRRouter } from "../lib/routing/components/SSRRouter.js";
5
- import { normalizeRoute } from "../lib/routing/utils.js";
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
- }) }) }) })] }));
3
+ import { getRouteMeta, normalizeRoute } from "../lib/routing/utils.js";
4
+ import { APIProvider } from "../utils/APIProvider.js";
5
+ export function SSRRoot(props) {
6
+ const loader = props.loader;
7
+ loader.setAppData(props.initialData.appData.data);
8
+ loader.populateRouteData(props.pathname, props.initialData);
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
  }
@@ -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,12 +1,25 @@
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
+ type BuiltinFormats = "core/bold" | "core/code" | "core/italic" | "core/link" | "core/strikethrough" | "core/underline" | "core/subscript" | "core/superscript" | "core/unknown" | "core/non-breaking-space" | "core/footnote";
4
5
  type Props<T extends ElementType> = {
5
6
  /** Specify a tag name or React component */
6
7
  as?: T;
7
8
  /** Prevents this text element from being multi-line */
8
9
  disableLineBreaks?: boolean;
9
- /** Enables the rich text toolbar */
10
+ /**
11
+ * Specify which formatting options are allowed in this text element (bold, italics etc).
12
+ *
13
+ * By default, all options are enabled.
14
+ *
15
+ * Set to an empty array to disable formatting options.
16
+ *
17
+ * You can register new formats in `_editor.tsx` using the `defineEditorConfig` function.
18
+ **/
19
+ allowedFormats?: (BuiltinFormats | (string & {}))[];
20
+ /**
21
+ * @deprecated use `allowedFormats` instead
22
+ */
10
23
  inlineToolbar?: boolean;
11
24
  /** Specify default content to use on the frontend if nothing has been entered */
12
25
  defaultValue?: string;
@@ -1,13 +1,18 @@
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
+ // const defaultFormats = wp.data.useSelect((select) => {
10
+ // const formats = (select(wp.richText.store) as any).getFormatTypes()
11
+ // console.log("U", formats)
12
+ // return formats.map((f: any) => f.name)
13
+ // }, [])
9
14
  const appendBlocks = useBlockAppender();
10
- return (_jsx(wp.blockEditor.RichText, { ...props, tagName: as, value: value || "", onChange: setValue, disableLineBreaks: props.disableLineBreaks, onKeyDownCapture: (e) => {
15
+ return (_jsx(wp.blockEditor.RichText, { ...props, placeholder: props.placeholder ?? props.defaultValue, tagName: as, value: value || "", onChange: setValue, allowedFormats: props.inlineToolbar === false ? [] : props.allowedFormats, disableLineBreaks: props.disableLineBreaks, "data-allowed-formats": props.allowedFormats?.join(" "), onKeyDownCapture: (e) => {
11
16
  if (e.key === "Enter" && appendOnEnter && appendBlocks) {
12
17
  appendBlocks([
13
18
  wp.blocks.createBlock(typeof appendOnEnter === "string" ? appendOnEnter : "core/paragraph"),
@@ -21,11 +26,12 @@ export function EditableText({ id, as, appendOnEnter, store, ...props }) {
21
26
  let [value] = useValueStore(store ?? id);
22
27
  const handleClickEvent = useRouter((r) => r.handleClickEvent);
23
28
  const otherProps = { ...props };
24
- delete otherProps.inlineToolbar;
25
29
  delete otherProps.disableLineBreaks;
26
30
  delete otherProps.id;
27
31
  otherProps.as = otherProps.asProp ?? undefined;
28
32
  delete otherProps.asProp;
33
+ delete otherProps.allowedFormats;
34
+ delete otherProps.disableLineBreaks;
29
35
  delete otherProps.placeholder;
30
36
  if (value === "" || typeof value !== "string") {
31
37
  if (props.defaultValue) {
@@ -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" | "simple" | 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)[];
@@ -16,9 +26,13 @@ type InnerBlocksProps = {
16
26
  * NOTE: This will have no effect on the frontend, since no wrapper div is created on the frontend.
17
27
  **/
18
28
  adminClassName?: string;
19
- /**
20
- *
21
- */
29
+ /** The default blocks to insert when there are no (non-templated) blocks */
30
+ defaultBlocks?: BlockTemplate;
31
+ /** Blocks to ensure are inserted at the top of the page */
32
+ headerTemplate?: BlockTemplate;
33
+ /** Blocks to ensure are inserted at the bottom of the page */
34
+ footerTemplate?: BlockTemplate;
35
+ /** A full-page block template */
22
36
  template?: BlockTemplate;
23
37
  /**
24
38
  * `false` allows all operations
@@ -31,7 +45,7 @@ type InnerBlocksProps = {
31
45
  * @default false
32
46
  *
33
47
  */
34
- templateLock?: "all" | "insert" | "contentOnly" | false;
48
+ templateLock?: "all" | "insert" | "contentOnly" | "none" | false;
35
49
  appender?: AppenderConfig;
36
50
  prioritizedInserterBlocks?: ChildBlockTypeName[];
37
51
  } & ContentBlockLayoutProps;
@@ -1,53 +1,100 @@
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";
6
- const Appender = (props) => {
2
+ import { useEffect, useMemo } from "react";
3
+ import { ContentBlocks } from "./ContentBlocks.js";
4
+ import { applyTemplateBlocks, transformBlockTemplate } from "./editor/block-templates.js";
5
+ import { blocksByTag } from "./editor/blocks-by-tag.js";
6
+ import { useBlockContext, useInnerBlocks } from "./inline-editing.js";
7
+ import { hash } from "object-code";
8
+ const Appender = ({ config, ...props }) => {
7
9
  const clientId = useBlockContext()?.block[1].clientId;
8
- if (props.type === "button") {
9
- return _jsx(wp.blockEditor.ButtonBlockAppender, { className: props.className, rootClientId: clientId });
10
+ if (config?.type === "button") {
11
+ return _jsx(wp.blockEditor.ButtonBlockAppender, { ...props, rootClientId: clientId, className: config.className });
10
12
  }
11
- else if (typeof props.type === "function") {
12
- return props.type({});
13
+ else if (config?.type === "simple") {
14
+ return (_jsx(wp.blockEditor.ButtonBlockAppender, { ...props, rootClientId: clientId, className: (props.className || "") + " block-editor-inserter__toggle has-icon simple-appender" }));
15
+ }
16
+ else if (typeof config?.type === "function") {
17
+ const Type = config?.type;
18
+ return (_jsx(wp.blockEditor.Inserter, { rootClientId: clientId, renderToggle: (p) => {
19
+ return _jsx(Type, { ...p });
20
+ }, isAppender: true,
21
+ // @ts-ignore
22
+ __experimentalIsQuick: true }));
23
+ // } else if (config?.type === "simple") {
24
+ // return (
25
+ // <wp.blockEditor.Inserter
26
+ // clientId={clientId}
27
+ // rootClientId={clientId}
28
+ // renderToggle={(p: any) => {
29
+ // return (
30
+ // <button
31
+ // className="simple-appender components-button block-editor-inserter__toggle !inline-flex has-icon"
32
+ // onClick={() => p.onToggle()}
33
+ // >
34
+ // <svg
35
+ // xmlns="http://www.w3.org/2000/svg"
36
+ // viewBox="0 0 24 24"
37
+ // width="24"
38
+ // height="24"
39
+ // aria-hidden="true"
40
+ // focusable="false"
41
+ // >
42
+ // <path d="M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"></path>
43
+ // </svg>
44
+ // </button>
45
+ // )
46
+ // }}
47
+ // isAppender
48
+ // // @ts-ignore
49
+ // __experimentalIsQuick
50
+ // />
51
+ // )
13
52
  }
14
53
  else {
15
- return (_jsx(wp.blockEditor.DefaultBlockAppender
16
54
  // @ts-ignore
17
- , {
18
- // @ts-ignore
19
- className: props.className, rootClientId: clientId, lastBlockClientId: clientId }));
55
+ return _jsx(wp.blockEditor.InnerBlocks.DefaultBlockAppender, { ...props });
20
56
  }
21
57
  };
58
+ export function createAppender(comp) {
59
+ return {
60
+ type: comp,
61
+ };
62
+ }
22
63
  /**
23
64
  * Allows child blocks to be added to the current block context.
24
65
  */
25
66
  export function InnerBlocks(props) {
26
67
  if (env.admin) {
27
68
  const inlineContext = useBlockContext();
69
+ const appender = useMemo(() => {
70
+ return (p) => _jsx(Appender, { config: props.appender, ...p });
71
+ }, [props.appender]);
28
72
  if (!inlineContext?.readonly) {
29
73
  const innerBlocksProps = wp.blockEditor.useInnerBlocksProps({}, {
30
74
  orientation: props.orientation ?? "vertical",
31
75
  allowedBlocks: props.allowedBlocks ? blocksByTag.expand(props.allowedBlocks) : undefined,
32
76
  prioritizedInserterBlocks: props.prioritizedInserterBlocks,
33
- renderAppender: props.appender
34
- ? () => _jsx(Appender, { ...props.appender })
35
- : wp.blockEditor.InnerBlocks.ButtonBlockAppender,
36
- templateLock: props.templateLock ?? false,
77
+ renderAppender: appender,
78
+ templateLock: props.templateLock === "none" ? false : (props.templateLock ?? false),
37
79
  template: props.template ? transformBlockTemplate(props.template) : undefined,
38
80
  });
81
+ /**
82
+ * A little bit experimental
83
+ *
84
+ * Adds support for headerTemplate/defaultBlocks/footerTemplate, which was first introduced in `_editor.tsx` for generate templates.
85
+ */
86
+ const blockId = inlineContext?.block[1].clientId;
87
+ useEffect(() => {
88
+ if (props.defaultBlocks || props.headerTemplate || props.footerTemplate) {
89
+ const newBlocks = applyTemplateBlocks(inlineContext?.innerBlocks ?? [], props);
90
+ wp.data.dispatch(wp.blockEditor.store).replaceInnerBlocks(blockId, newBlocks);
91
+ }
92
+ }, [
93
+ hash(inlineContext?.innerBlocks.map((b) => [b.blockName, b.clientId])),
94
+ hash([props.template, props.defaultBlocks, props.headerTemplate, props.footerTemplate]),
95
+ blockId,
96
+ ]);
39
97
  return (_jsx("div", { ...innerBlocksProps, className: [innerBlocksProps.className, props.adminClassName].filter(Boolean).join(" ") }));
40
- // return (
41
- // <wp.blockEditor.InnerBlocks
42
- // // @ts-ignore
43
- // orientation={props.orientation}
44
- // prioritizedInserterBlocks={props.prioritizedInserterBlocks}
45
- // allowedBlocks={props.allowedBlocks ? blocksByTag.expand(props.allowedBlocks) : undefined}
46
- // renderAppender={props.appender ? () => <Appender {...props.appender!} /> : undefined}
47
- // templateLock={(props.templateLock as any) ?? false}
48
- // template={props.template ? transformBlockTemplate(props.template) : undefined}
49
- // />
50
- // )
51
98
  }
52
99
  }
53
100
  const blocks = useInnerBlocks();
@@ -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];
@@ -1,2 +1,5 @@
1
1
  import { ComponentType, ReactNode } from "react";
2
2
  export declare function defineBlock<TName extends keyof BlockProps>(name: TName, component: (props: BlockProps[TName]) => ReactNode): ComponentType<BlockProps[TName]>;
3
+ export declare namespace defineBlock {
4
+ var meta: (name: string, meta: any) => void;
5
+ }
@@ -1,3 +1,10 @@
1
+ import { blockMetaDescriptors } from "./editor/installGutenbergHooks";
2
+ import { resolveAcfBlockName } from "./editor/block-templates";
1
3
  export function defineBlock(name, component) {
2
4
  return component;
3
5
  }
6
+ defineBlock.meta = (name, meta) => {
7
+ if (env.admin) {
8
+ blockMetaDescriptors.set(resolveAcfBlockName(name), meta);
9
+ }
10
+ };
@@ -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 {};