eddev 2.0.0-beta.1 → 2.0.0-beta.100

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 (277) 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.d.ts +1 -0
  6. package/dist/app/entry/boot-admin.js +13 -0
  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.d.ts +1 -0
  10. package/dist/app/entry/spa-root.js +8 -0
  11. package/dist/app/entry/ssr-root-client.d.ts +6 -0
  12. package/dist/app/entry/ssr-root-client.js +20 -0
  13. package/dist/app/entry/ssr-root.d.ts +8 -0
  14. package/dist/app/entry/ssr-root.js +22 -0
  15. package/dist/app/lib/admin/index.d.ts +2 -2
  16. package/dist/app/lib/admin/index.js +2 -2
  17. package/dist/app/lib/admin/installFieldTypes.js +1 -1
  18. package/dist/app/lib/admin/runWidgets.js +1 -1
  19. package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
  20. package/dist/app/lib/blocks/ContentBlocks.js +5 -5
  21. package/dist/app/lib/blocks/EditableText.d.ts +1 -1
  22. package/dist/app/lib/blocks/EditableText.js +3 -3
  23. package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
  24. package/dist/app/lib/blocks/InnerBlocks.js +13 -5
  25. package/dist/app/lib/blocks/block-utils.d.ts +2 -2
  26. package/dist/app/lib/blocks/block-utils.js +2 -2
  27. package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +7 -0
  28. package/dist/app/lib/blocks/editor/EditorHighlights.js +130 -0
  29. package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
  30. package/dist/app/lib/blocks/editor/editor-config.d.ts +17 -4
  31. package/dist/app/lib/blocks/editor/editor-config.js +21 -9
  32. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +20 -14
  33. package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
  34. package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
  35. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  36. package/dist/app/lib/blocks/index.d.ts +9 -9
  37. package/dist/app/lib/blocks/index.js +9 -9
  38. package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
  39. package/dist/app/lib/blocks/inline-editing.js +7 -5
  40. package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
  41. package/dist/app/lib/devtools/components/DevUI.js +4 -3
  42. package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
  43. package/dist/app/lib/devtools/components/GridIndicator.js +29 -0
  44. package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
  45. package/dist/app/lib/devtools/dev-tools-store.js +8 -0
  46. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
  47. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  48. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1102 -1103
  49. package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
  50. package/dist/app/lib/devtools/index.d.ts +1 -0
  51. package/dist/app/lib/devtools/index.js +1 -1
  52. package/dist/app/lib/devtools/loader.js +8 -7
  53. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  54. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  55. package/dist/app/lib/dynamic/dynamic.d.ts +1 -1
  56. package/dist/app/lib/dynamic/dynamic.js +5 -1
  57. package/dist/app/lib/dynamic/index.d.ts +1 -1
  58. package/dist/app/lib/dynamic/index.js +1 -1
  59. package/dist/app/lib/hooks/index.d.ts +4 -5
  60. package/dist/app/lib/hooks/index.js +4 -5
  61. package/dist/app/lib/hooks/queryUtils.d.ts +41 -4
  62. package/dist/app/lib/hooks/queryUtils.js +74 -37
  63. package/dist/app/lib/hooks/useAppData.js +1 -1
  64. package/dist/app/lib/hooks/useRPC.d.ts +0 -4
  65. package/dist/app/lib/hooks/useRPC.js +1 -8
  66. package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
  67. package/dist/app/lib/internal/finalize-rpc.js +3 -0
  68. package/dist/app/lib/internal/index.d.ts +5 -4
  69. package/dist/app/lib/internal/index.js +5 -4
  70. package/dist/app/lib/internal/internal-store.d.ts +0 -2
  71. package/dist/app/lib/internal/internal-store.js +1 -3
  72. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  73. package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
  74. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  75. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  76. package/dist/app/lib/legacy-stitches/index.js +1 -1
  77. package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
  78. package/dist/app/lib/routing/components/BackButton.js +47 -0
  79. package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
  80. package/dist/app/lib/routing/components/BrowserRouter.js +95 -19
  81. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  82. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  83. package/dist/app/lib/routing/components/Link.js +11 -12
  84. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  85. package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
  86. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  87. package/dist/app/lib/routing/components/SSRRouter.js +5 -6
  88. package/dist/app/lib/routing/components/ScrollRestoration.js +5 -2
  89. package/dist/app/lib/routing/context.d.ts +8 -5
  90. package/dist/app/lib/routing/context.js +13 -96
  91. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
  92. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  93. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
  94. package/dist/app/lib/routing/hooks/useRoute.js +22 -1
  95. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
  96. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  97. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  98. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  99. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  100. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  101. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  102. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  103. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  104. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  105. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  106. package/dist/app/lib/routing/index.d.ts +14 -13
  107. package/dist/app/lib/routing/index.js +14 -13
  108. package/dist/app/lib/routing/loader.d.ts +2 -2
  109. package/dist/app/lib/routing/loader.js +26 -15
  110. package/dist/app/lib/routing/types.d.ts +36 -10
  111. package/dist/app/lib/routing/utils.d.ts +5 -2
  112. package/dist/app/lib/routing/utils.js +37 -4
  113. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
  114. package/dist/app/lib/runtime/apiConfig.js +6 -0
  115. package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
  116. package/dist/app/lib/runtime/errorHandling.js +6 -0
  117. package/dist/app/lib/runtime/index.d.ts +2 -0
  118. package/dist/app/lib/runtime/index.js +2 -0
  119. package/dist/app/lib/views/index.d.ts +1 -1
  120. package/dist/app/lib/views/index.js +1 -1
  121. package/dist/app/server/defineRouter.d.ts +2 -0
  122. package/dist/app/server/defineRouter.js +4 -0
  123. package/dist/app/server/index.d.ts +5 -0
  124. package/dist/app/server/index.js +5 -0
  125. package/dist/app/server/proxy-wp-admin.d.ts +2 -0
  126. package/dist/app/server/proxy-wp-admin.js +124 -0
  127. package/dist/app/server/render-ssr-page.d.ts +21 -0
  128. package/dist/app/server/render-ssr-page.js +166 -0
  129. package/dist/app/server/rpc.d.ts +56 -0
  130. package/dist/app/server/rpc.js +18 -0
  131. package/dist/app/server/server-context.d.ts +72 -0
  132. package/dist/app/server/server-context.js +283 -0
  133. package/dist/app/server/utils/headers.d.ts +1 -0
  134. package/dist/app/server/utils/headers.js +17 -0
  135. package/dist/app/server/utils/replace-host.d.ts +6 -4
  136. package/dist/app/server/utils/replace-host.js +66 -11
  137. package/dist/app/server/utils/swr-cache.d.ts +4 -0
  138. package/dist/app/server/utils/swr-cache.js +31 -0
  139. package/dist/app/utils/APIProvider.d.ts +2 -0
  140. package/dist/app/utils/APIProvider.js +5 -0
  141. package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
  142. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  143. package/dist/app/utils/ErrorMessage.d.ts +5 -0
  144. package/dist/app/utils/ErrorMessage.js +14 -0
  145. package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
  146. package/dist/app/utils/RouteErrorBoundary.js +38 -0
  147. package/dist/app/utils/asset-capture.d.ts +2 -0
  148. package/dist/app/utils/asset-capture.js +5 -0
  149. package/dist/app/utils/hydration-debugger.d.ts +13 -0
  150. package/dist/app/utils/hydration-debugger.js +11 -0
  151. package/dist/app/utils/query-client.d.ts +2 -0
  152. package/dist/app/utils/query-client.js +5 -1
  153. package/dist/app/utils/trpc-client.d.ts +2 -0
  154. package/dist/app/utils/trpc-client.js +39 -0
  155. package/dist/node/cli/cli-worker.d.ts +1 -1
  156. package/dist/node/cli/cli-worker.js +11 -3
  157. package/dist/node/cli/cli.js +112 -13
  158. package/dist/node/cli/display/CLIApp.d.ts +1 -1
  159. package/dist/node/cli/display/CLIApp.js +4 -7
  160. package/dist/node/cli/display/boot-cli-app.js +1 -1
  161. package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
  162. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +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/display/util/colors.d.ts +2 -2
  167. package/dist/node/cli/version.d.ts +1 -1
  168. package/dist/node/cli/version.js +1 -1
  169. package/dist/node/compiler/build-vinxi.d.ts +8 -0
  170. package/dist/node/compiler/build-vinxi.js +38 -0
  171. package/dist/node/compiler/bundler.admin.d.ts +2 -2
  172. package/dist/node/compiler/bundler.admin.js +4 -4
  173. package/dist/node/compiler/bundler.frontend.d.ts +1 -1
  174. package/dist/node/compiler/bundler.frontend.js +4 -4
  175. package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
  176. package/dist/node/compiler/dev-server.js +107 -0
  177. package/dist/node/compiler/get-vite-config.d.ts +20 -0
  178. package/dist/node/compiler/get-vite-config.js +207 -0
  179. package/dist/node/compiler/vinxi-app.d.ts +22 -0
  180. package/dist/node/compiler/vinxi-app.js +228 -0
  181. package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
  182. package/dist/node/compiler/vinxi-codegen.js +638 -0
  183. package/dist/node/graphql/graphql-codegen.d.ts +12 -2
  184. package/dist/node/graphql/graphql-codegen.js +213 -36
  185. package/dist/node/graphql/graphql-schema-loader.d.ts +2 -1
  186. package/dist/node/graphql/graphql-schema-loader.js +5 -19
  187. package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
  188. package/dist/node/graphql/query-files-loader.d.ts +3 -0
  189. package/dist/node/graphql/query-files-loader.js +5 -0
  190. package/dist/node/project/config.d.ts +159 -73
  191. package/dist/node/project/config.js +70 -21
  192. package/dist/node/project/env.d.ts +5 -1
  193. package/dist/node/project/env.js +2 -1
  194. package/dist/node/project/manifest/block-manifest.js +3 -2
  195. package/dist/node/project/manifest/manifest.d.ts +2 -1
  196. package/dist/node/project/manifest/manifest.js +15 -11
  197. package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
  198. package/dist/node/project/manifest/routes-manifest.js +74 -0
  199. package/dist/node/project/manifest/view-manifest.js +2 -2
  200. package/dist/node/project/project.d.ts +11 -2
  201. package/dist/node/project/project.js +49 -20
  202. package/dist/node/project/wp-info.d.ts +1 -0
  203. package/dist/node/project/wp-info.js +13 -3
  204. package/dist/node/types/block-type.d.ts +25 -20
  205. package/dist/node/types/block-type.js +1 -0
  206. package/dist/node/types/view-type.d.ts +7 -7
  207. package/dist/node/types/view-type.js +3 -4
  208. package/dist/node/utils/fetch-wp.d.ts +1 -0
  209. package/dist/node/utils/fetch-wp.js +27 -0
  210. package/dist/node/utils/fs-codegen.d.ts +42 -0
  211. package/dist/node/utils/fs-codegen.js +98 -0
  212. package/dist/node/utils/fs.js +2 -0
  213. package/dist/node/utils/{isDeploying.js → is-deploying.js} +1 -1
  214. package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
  215. package/dist/node/utils/{statefulLog.js → stateful-log.js} +3 -1
  216. package/dist/node/utils/watch-file-tree.d.ts +25 -0
  217. package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +12 -5
  218. package/package.json +40 -38
  219. package/types.app.d.ts +4 -2
  220. package/types.app.internal.d.ts +2 -2
  221. package/types.node.d.ts +3 -3
  222. package/dist/app/entry/Root.d.ts +0 -1
  223. package/dist/app/entry/Root.js +0 -9
  224. package/dist/app/entry/main.admin.d.ts +0 -3
  225. package/dist/app/entry/main.admin.js +0 -10
  226. package/dist/app/entry/main.frontend.spa.d.ts +0 -3
  227. package/dist/app/entry/main.frontend.spa.js +0 -13
  228. package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
  229. package/dist/app/entry/main.frontend.ssr.js +0 -79
  230. package/dist/app/entry/main.serverless.dev.d.ts +0 -4
  231. package/dist/app/entry/main.serverless.dev.js +0 -21
  232. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  233. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  234. package/dist/app/lib/hooks/apiConfig.js +0 -4
  235. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  236. package/dist/app/lib/hooks/usePageLoad.js +0 -5
  237. package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
  238. package/dist/app/server/create-api-builtin-hono.js +0 -80
  239. package/dist/app/server/create-ssr-hono.d.ts +0 -18
  240. package/dist/app/server/create-ssr-hono.js +0 -104
  241. package/dist/app/server/utils/index.html.d.ts +0 -2
  242. package/dist/app/server/utils/index.html.js +0 -14
  243. package/dist/node/compiler/index.html.d.ts +0 -2
  244. package/dist/node/compiler/index.html.js +0 -15
  245. package/dist/node/compiler/serverless.dev.js +0 -215
  246. package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
  247. package/dist/node/compiler/vite/get-vite-config.js +0 -315
  248. package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
  249. package/dist/node/compiler/vite/plugin-admin.js +0 -67
  250. package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
  251. package/dist/node/compiler/vite/plugin-blocks.js +0 -73
  252. package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
  253. package/dist/node/compiler/vite/plugin-entry.js +0 -16
  254. package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
  255. package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
  256. package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
  257. package/dist/node/compiler/vite/plugin-theme.js +0 -40
  258. package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
  259. package/dist/node/compiler/vite/plugin-views.js +0 -51
  260. package/dist/node/utils/console.d.ts +0 -21
  261. package/dist/node/utils/console.js +0 -28
  262. package/dist/node/utils/unsafe-fetch.d.ts +0 -2
  263. package/dist/node/utils/unsafe-fetch.js +0 -19
  264. package/dist/node/utils/watchFileTree.d.ts +0 -11
  265. package/tsup.config.ts +0 -40
  266. package/types.manifests.d.ts +0 -22
  267. /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
  268. /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
  269. /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
  270. /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
  271. /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
  272. /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
  273. /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
  274. /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
  275. /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
  276. /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
  277. /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
@@ -1,6 +1,9 @@
1
- import "@manifest/tailwind";
2
1
  import { useSnapshot } from "valtio";
3
- import { internalStore } from "../../internal";
2
+ import { devToolsStore } from "../dev-tools-store.js";
3
+ import { useEffect } from "react";
4
4
  export function useTailwindConfig() {
5
- return useSnapshot(internalStore).tailwindConfig;
5
+ useEffect(() => {
6
+ devToolsStore.loadTailwindConfig();
7
+ }, []);
8
+ return useSnapshot(devToolsStore).tailwindConfig;
6
9
  }
@@ -0,0 +1 @@
1
+ export * from "./dev-tools-store.js";
@@ -1 +1 @@
1
- "use strict";
1
+ export * from "./dev-tools-store.js";
@@ -1,14 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect } from "react";
3
- import { dynamic } from "../dynamic";
4
- import { usePersistState } from "./hooks/usePersistState";
5
- import { useIsSSR } from "../routing";
6
- const DevUI = dynamic(() => import("./components/DevUI"));
2
+ import { lazy, useEffect } from "react";
3
+ import { usePersistState } from "./hooks/usePersistState.js";
4
+ import { useIsSSR } from "../routing/hooks/useIsSSR.js";
5
+ const DevUI = lazy(() => import("./components/DevUI.js"));
7
6
  export function DevUILoader() {
8
7
  const ssr = useIsSSR();
9
- const [render, setRender] = usePersistState("enable_devui", typeof window !== "undefined" && (env.dev || window["ENABLE_DEV_UI"]));
8
+ const [render, setRender] = usePersistState("enable_devui", false);
10
9
  useEffect(() => {
11
- if (document.location.search.includes("activate-dev-ui")) {
10
+ if (document.location.search.includes("activate-dev-ui") ||
11
+ window["ENABLE_DEV_UI"] ||
12
+ (env.client && env.dev)) {
12
13
  setRender(true);
13
14
  }
14
15
  }, []);
@@ -6,4 +6,10 @@ export type QueryDebugItem = {
6
6
  children: QueryDebugItem[];
7
7
  };
8
8
  export declare function setQueryDebug(value: QueryDebugItem | undefined): void;
9
- export declare function useQueryDebugData(): QueryDebugItem | undefined;
9
+ export declare function useQueryDebugData(): {
10
+ readonly file: string;
11
+ readonly errors: readonly string[];
12
+ readonly duration: number;
13
+ readonly label: string;
14
+ readonly children: readonly any[];
15
+ } | undefined;
@@ -1,13 +1,10 @@
1
- import { create } from "zustand";
2
- const useQueryDebug = create((set) => ({
1
+ import { proxy, useSnapshot } from "valtio";
2
+ const store = proxy({
3
3
  value: undefined,
4
- set: (value) => {
5
- set({ value });
6
- },
7
- }));
4
+ });
8
5
  export function setQueryDebug(value) {
9
- useQueryDebug.setState({ value });
6
+ store.value = value;
10
7
  }
11
8
  export function useQueryDebugData() {
12
- return useQueryDebug((store) => store.value);
9
+ return useSnapshot(store).value;
13
10
  }
@@ -4,5 +4,5 @@ export type DynamicComponent<T extends ComponentType<any>> = T & {
4
4
  };
5
5
  export declare function dynamic<T extends ComponentType<any>>(factory: () => Promise<{
6
6
  default: T;
7
- }>): DynamicComponent<T>;
7
+ }>, name?: string): DynamicComponent<T>;
8
8
  export default dynamic;
@@ -1,9 +1,13 @@
1
1
  import { createElement, forwardRef, lazy, memo, useRef } from "react";
2
- export function dynamic(factory) {
2
+ import { useAssetCapture } from "../../utils/asset-capture";
3
+ export function dynamic(factory, name) {
3
4
  const ReactLazyComponent = lazy(factory);
4
5
  let PreloadedComponent;
5
6
  let factoryPromise;
6
7
  const Component = memo(forwardRef(function LazyWithPreload(props, ref) {
8
+ if (env.serverless && !env.client && name) {
9
+ useAssetCapture()?.add(name);
10
+ }
7
11
  // Once one of these is chosen, we must ensure that it continues to be
8
12
  // used for all subsequent renders, otherwise it can cause the
9
13
  // underlying component to be unmounted and remounted.
@@ -1 +1 @@
1
- export { dynamic, DynamicComponent } from "./dynamic";
1
+ export { dynamic, DynamicComponent } from "./dynamic.js";
@@ -1 +1 @@
1
- export { dynamic } from "./dynamic";
1
+ export { dynamic } from "./dynamic.js";
@@ -1,5 +1,4 @@
1
- export * from "./usePageLoad";
2
- export * from "./useAppData";
3
- export * from "./useRPC";
4
- export * from "./queryUtils";
5
- export * from "./apiConfig";
1
+ export * from "./useAppData.js";
2
+ export * from "./useRPC.js";
3
+ export * from "./queryUtils.js";
4
+ export * from "../runtime/apiConfig.js";
@@ -1,5 +1,4 @@
1
- export * from "./usePageLoad";
2
- export * from "./useAppData";
3
- export * from "./useRPC";
4
- export * from "./queryUtils";
5
- export * from "./apiConfig";
1
+ export * from "./useAppData.js";
2
+ export * from "./useRPC.js";
3
+ export * from "./queryUtils.js";
4
+ export * from "../runtime/apiConfig.js";
@@ -1,4 +1,5 @@
1
- import { FetchQueryOptions, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryResult, UseInfiniteQueryResult, UndefinedInitialDataInfiniteOptions } from "@tanstack/react-query";
1
+ import { FetchQueryOptions, UndefinedInitialDataInfiniteOptions, UndefinedInitialDataOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryResult } from "@tanstack/react-query";
2
+ import { TRPCClientError } from "@trpc/client";
2
3
  type OptionalMaybes<T> = T extends any[] ? T : T extends {
3
4
  [key: string]: any;
4
5
  } ? {
@@ -7,10 +8,17 @@ type OptionalMaybes<T> = T extends any[] ? T : T extends {
7
8
  type MaybeVars = {
8
9
  [key: string]: any;
9
10
  } | undefined;
10
- export type QueryError = Error & {
11
+ declare class QueryError extends Error {
12
+ name: string;
11
13
  messages: string[];
12
14
  statusCode: number;
13
- };
15
+ constructor(args: {
16
+ messages: string[];
17
+ statusCode: number;
18
+ type: "query" | "mutation";
19
+ queryName: string;
20
+ });
21
+ }
14
22
  /** Regular queries */
15
23
  type CreateUseQueryOptions = {
16
24
  name: string;
@@ -33,7 +41,10 @@ export type UseInfiniteQueryFunction<TData, TVars> = (args: OptionalMaybes<Omit<
33
41
  headers?: Record<string, string>;
34
42
  /** Initial data can be passed in, but should match the original GraphQL query in structure (including nodes/hasNextPage/endCursor) */
35
43
  initialData?: any;
36
- }) => UseInfiniteQueryResult<TData, QueryError>;
44
+ }) => UseInfiniteQueryResult<{
45
+ nodes: TData;
46
+ total?: number | null;
47
+ }, QueryError>;
37
48
  export declare function createUseInfiniteQuery<TData extends any, TVars extends MaybeVars>(init: CreateUseInfiniteQueryOptions): UseInfiniteQueryFunction<TData, TVars>;
38
49
  export type UseMutationFunction<TData, TArgs> = ((options?: Omit<UseMutationOptions<TData, QueryError, TArgs>, "mutationFn"> & {
39
50
  headers?: Record<string, string>;
@@ -43,4 +54,30 @@ export type UseMutationFunction<TData, TArgs> = ((options?: Omit<UseMutationOpti
43
54
  }) => Promise<TData>;
44
55
  };
45
56
  export declare function createUseMutation<TData extends any, TArgs extends MaybeVars>(init: CreateUseQueryOptions): UseMutationFunction<TData, TArgs>;
57
+ type RPCQueryName = RPCRouter["queries"]["key"];
58
+ type RPCQueryResult<T> = Extract<RPCRouter["queries"], {
59
+ key: T;
60
+ }>["output"];
61
+ type RPCQueryInput<T> = Extract<RPCRouter["queries"], {
62
+ key: T;
63
+ }>["input"];
64
+ type RPCQueryError<T> = TRPCClientError<Extract<RPCRouter["queries"], {
65
+ key: T;
66
+ }>["procedure"]>;
67
+ export declare function useRPCQuery<TName extends RPCQueryName>(key: TName, args: OptionalMaybes<RPCQueryInput<TName>>, options?: Omit<UndefinedInitialDataOptions<RPCQueryResult<TName>, RPCQueryError<TName>, RPCQueryResult<TName>>, "queryKey" | "queryFn"> & {
68
+ headers?: Record<string, string>;
69
+ }): UseQueryResult<RPCQueryResult<TName>, RPCQueryError<TName>>;
70
+ type RPCMutationName = RPCRouter["mutations"]["key"];
71
+ type RPCMutationResult<T> = Extract<RPCRouter["mutations"], {
72
+ key: T;
73
+ }>["output"];
74
+ type RPCMutationInput<T> = Extract<RPCRouter["mutations"], {
75
+ key: T;
76
+ }>["input"];
77
+ type RPCMutationError<T> = TRPCClientError<Extract<RPCRouter["mutations"], {
78
+ key: T;
79
+ }>["procedure"]>;
80
+ export declare function useRPCMutation<TName extends RPCMutationName>(key: TName, options?: Omit<UseMutationOptions<RPCMutationResult<TName>, RPCMutationError<TName>, RPCMutationInput<TName>>, "mutationFn"> & {
81
+ headers?: Record<string, string>;
82
+ }): UseMutationResult<RPCMutationResult<TName>, RPCMutationError<TName>, RPCMutationInput<TName>>;
46
83
  export {};
@@ -1,13 +1,22 @@
1
- import { useMutation, useQuery, useInfiniteQuery, } from "@tanstack/react-query";
2
- import { joinURL } from "ufo";
3
- import { getQueryClient } from "../../utils/query-client";
4
- import { useAPIConfig } from "./apiConfig";
1
+ import { useInfiniteQuery, useMutation, useQuery, useQueryClient, } from "@tanstack/react-query";
5
2
  import { useEffect, useState } from "react";
6
- function createQueryError(messages, statusCode) {
7
- const error = new Error(messages.join(", "));
8
- error.statusCode = statusCode;
9
- error.messages = messages;
10
- return error;
3
+ import { joinURL } from "ufo";
4
+ import { getQueryClient } from "../../utils/query-client.js";
5
+ import { getRPCClient } from "../../utils/trpc-client.js";
6
+ import { apiConfig } from "../runtime/apiConfig.js";
7
+ class QueryError extends Error {
8
+ name = "QueryError";
9
+ messages;
10
+ statusCode;
11
+ constructor(args) {
12
+ const msg = args.messages.join(", ");
13
+ super(msg);
14
+ this.statusCode = args.statusCode;
15
+ this.messages = args.messages;
16
+ }
17
+ }
18
+ function useFallbackClient() {
19
+ return useQueryClient(getQueryClient());
11
20
  }
12
21
  const fetchGETQuery = async (name, params, opts) => {
13
22
  let url;
@@ -15,7 +24,7 @@ const fetchGETQuery = async (name, params, opts) => {
15
24
  headers: opts?.headers,
16
25
  };
17
26
  if (env.serverless && env.client) {
18
- url = `/api/rest/query/${name}`;
27
+ url = `/_data/query/${name}`;
19
28
  }
20
29
  else if (env.serverless) {
21
30
  url = joinURL(env.origin ?? "", `/wp-json/ed/v1/query/${name}`);
@@ -26,33 +35,39 @@ const fetchGETQuery = async (name, params, opts) => {
26
35
  if (params)
27
36
  url += "?params=" + encodeURIComponent(params);
28
37
  // Apply API configuration
29
- const apiConfig = useAPIConfig.getState();
30
38
  if (apiConfig.customQueryFetchOptions) {
31
39
  options = await apiConfig.customQueryFetchOptions?.("query", name, params, url, options);
32
40
  }
33
41
  const response = await fetch(url, options);
42
+ if (apiConfig.onResponse)
43
+ apiConfig.onResponse(response, "query", name, params, url, options);
34
44
  const payload = await response.json();
35
45
  if (payload.errors?.length > 0) {
36
- throw createQueryError(payload.errors.map((e) => e.message), response.status);
46
+ throw new QueryError({
47
+ messages: payload.errors.map((e) => e.message),
48
+ statusCode: response.status,
49
+ queryName: name,
50
+ type: "query",
51
+ });
37
52
  }
38
53
  return payload.data;
39
54
  };
40
55
  export function createUseQuery(init) {
41
56
  const hook = (args, options) => {
42
- const customKey = useAPIConfig((state) => state.customQueryKey);
57
+ const customKey = apiConfig.customQueryKey;
43
58
  return useQuery({
44
- queryKey: [init.name, args, options?.headers, options?.headers, customKey],
45
- queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
59
+ queryKey: ["query", init.name, args, options?.headers, customKey],
60
+ queryFn: (args) => fetchGETQuery(init.name, args.queryKey[2] ? JSON.stringify(args.queryKey[2]) : "", {
46
61
  headers: options?.headers,
47
62
  }),
48
63
  ...options,
49
- });
64
+ }, useFallbackClient());
50
65
  };
51
66
  hook.fetch = async (args, options) => {
52
- const customKey = useAPIConfig.getState().customQueryKey;
67
+ const customKey = apiConfig.customQueryKey;
53
68
  return getQueryClient().fetchQuery({
54
- queryKey: [init.name, args, options?.headers, options?.headers, customKey],
55
- queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
69
+ queryKey: ["query", init.name, args, options?.headers, customKey],
70
+ queryFn: (args) => fetchGETQuery(init.name, args.queryKey[2] ? JSON.stringify(args.queryKey[2]) : "", {
56
71
  headers: options?.headers,
57
72
  }),
58
73
  ...options,
@@ -60,20 +75,12 @@ export function createUseQuery(init) {
60
75
  };
61
76
  return hook;
62
77
  }
63
- // & {
64
- // fetch: (
65
- // args: OptionalMaybes<TVars>,
66
- // options?: Omit<FetchInfiniteQueryOptions<TData, QueryError, InfiniteData<TData, string>>, "queryKey" | "queryFn"> & {
67
- // headers?: Record<string, string>
68
- // },
69
- // ) => Promise<TData>
70
- // }
71
78
  function selectByPath(data, path) {
72
79
  return path.reduce((acc, key) => (acc ? acc[key] : null), data);
73
80
  }
74
81
  export function createUseInfiniteQuery(init) {
75
82
  const hook = (args, options) => {
76
- const customKey = useAPIConfig((state) => state.customQueryKey);
83
+ const customKey = apiConfig.customQueryKey;
77
84
  const [initial, setInitial] = useState(() => {
78
85
  if (options?.initialData) {
79
86
  const data = options?.initialData;
@@ -96,11 +103,11 @@ export function createUseInfiniteQuery(init) {
96
103
  });
97
104
  }, []);
98
105
  return useInfiniteQuery({
99
- queryKey: [init.name, args, init.defaultLimit, options?.headers, options?.headers, customKey],
106
+ queryKey: ["query", init.name, args, init.defaultLimit, options?.headers, customKey],
100
107
  queryFn: async (args) => {
101
108
  const finalArgs = {
102
- limit: args.queryKey[2],
103
- ...(args.queryKey[1] ?? {}),
109
+ limit: args.queryKey[3],
110
+ ...(args.queryKey[2] ?? {}),
104
111
  cursor: args.pageParam,
105
112
  };
106
113
  const data = await fetchGETQuery(init.name, JSON.stringify(finalArgs), {
@@ -109,10 +116,12 @@ export function createUseInfiniteQuery(init) {
109
116
  const endCursor = selectByPath(data, init.paths.endCursorPath);
110
117
  const hasNextPage = selectByPath(data, init.paths.hasNextPagePath);
111
118
  const nodes = selectByPath(data, init.paths.nodesPath);
119
+ const total = selectByPath(data, [...init.paths.pageInfoPath, "total"]);
112
120
  return {
113
121
  nodes,
114
122
  hasNextPage,
115
123
  endCursor,
124
+ total,
116
125
  };
117
126
  },
118
127
  initialPageParam: "",
@@ -121,7 +130,10 @@ export function createUseInfiniteQuery(init) {
121
130
  return lastPage.hasNextPage ? lastPage.endCursor : undefined;
122
131
  },
123
132
  select(data) {
124
- return data.pages.flatMap((page) => page.nodes);
133
+ return {
134
+ nodes: data.pages.flatMap((page) => page.nodes),
135
+ total: data.pages[data.pages.length - 1]?.total,
136
+ };
125
137
  },
126
138
  ...options,
127
139
  ...initial,
@@ -142,7 +154,7 @@ const fetchMutation = async (name, params, opts) => {
142
154
  };
143
155
  if (env.serverless && env.client) {
144
156
  // Relative request (in browser)
145
- url = `/api/rest/mutation/${name}`;
157
+ url = `/_data/mutation/${name}`;
146
158
  }
147
159
  else if (env.serverless) {
148
160
  // Request to the origin server (server to server)
@@ -153,26 +165,32 @@ const fetchMutation = async (name, params, opts) => {
153
165
  url = `/wp-json/ed/v1/mutation/${name}`;
154
166
  }
155
167
  // Apply API configuration
156
- const apiConfig = useAPIConfig.getState();
157
168
  if (apiConfig.customQueryFetchOptions) {
158
169
  options = await apiConfig.customQueryFetchOptions?.("mutation", name, params, url, options);
159
170
  }
160
171
  const response = await fetch(url, options);
172
+ if (apiConfig.onResponse)
173
+ apiConfig.onResponse(response, "mutation", name, params, url, options);
161
174
  const payload = await response.json();
162
175
  if (payload.errors?.length > 0) {
163
- throw createQueryError(payload.errors.map((e) => e.message), response.status);
176
+ throw new QueryError({
177
+ messages: payload.errors.map((e) => e.message),
178
+ statusCode: response.status,
179
+ queryName: name,
180
+ type: "mutation",
181
+ });
164
182
  }
165
183
  return payload.data;
166
184
  };
167
185
  export function createUseMutation(init) {
168
186
  const hook = (options) => {
169
187
  return useMutation({
170
- mutationKey: [init.name],
188
+ mutationKey: ["mutation", init.name],
171
189
  mutationFn: (args) => fetchMutation(init.name, args, {
172
190
  headers: options?.headers,
173
191
  }),
174
192
  ...options,
175
- });
193
+ }, useFallbackClient());
176
194
  };
177
195
  hook.mutate = async (args, options) => {
178
196
  return fetchMutation(init.name, args, {
@@ -181,3 +199,22 @@ export function createUseMutation(init) {
181
199
  };
182
200
  return hook;
183
201
  }
202
+ // @ts-ignore
203
+ export function useRPCQuery(key, args, options) {
204
+ return useQuery({
205
+ queryKey: ["rpcQuery", key, args],
206
+ queryFn: async (args) => {
207
+ return getRPCClient().query(key, args.queryKey[2]);
208
+ },
209
+ ...options,
210
+ }, useFallbackClient());
211
+ }
212
+ export function useRPCMutation(key, options) {
213
+ return useMutation({
214
+ mutationKey: ["rpcMutation", key],
215
+ mutationFn: async (args) => {
216
+ return getRPCClient().mutation(key, args);
217
+ },
218
+ ...options,
219
+ }, useFallbackClient());
220
+ }
@@ -1,4 +1,4 @@
1
- import { useRouter } from "../routing";
1
+ import { useRouter } from "../routing/index.js";
2
2
  function useAppData(selector) {
3
3
  const loader = useRouter((r) => r.loader);
4
4
  if (selector) {
@@ -1,7 +1,3 @@
1
- export declare const useRPCQuery: RPCUseQuery;
2
- export declare const useRPCMutation: RPCUseMutation;
3
- export declare const useRPCInfiniteQuery: RPCUseInfiniteQuery;
4
- export declare const rpcClient: null;
5
1
  export type UseRPCMutationResult = any;
6
2
  export type UseRPCQueryResult = any;
7
3
  export type UseRPCInfiniteQueryResult = any;
@@ -1,9 +1,2 @@
1
- const trpc = {};
2
- // @ts-ignore
3
- export const useRPCQuery = trpc.useQuery;
4
- // @ts-ignore
5
- export const useRPCMutation = trpc.useMutation;
6
- // @ts-ignore
7
- export const useRPCInfiniteQuery = trpc.useInfiniteQuery;
8
- export const rpcClient = null;
1
+ // const trpc = {}
9
2
  export const RPCClientError = null;
@@ -0,0 +1,17 @@
1
+ import type { AnyTRPCMutationProcedure, AnyTRPCProcedure, AnyTRPCQueryProcedure, AnyTRPCSubscriptionProcedure, inferProcedureInput, inferProcedureOutput } from "@trpc/server";
2
+ type RouterTable = Record<string, Record<string, AnyTRPCProcedure> | AnyTRPCProcedure>;
3
+ type RouterEntry<T extends RouterTable, U extends AnyTRPCProcedure, P extends string = ""> = {
4
+ [K in keyof T]: K extends string ? T[K] extends U ? {
5
+ key: `${P}${K}`;
6
+ input: inferProcedureInput<T[K]>;
7
+ output: inferProcedureOutput<T[K]>;
8
+ procedure: T[K] extends AnyTRPCProcedure ? T[K] : never;
9
+ } : T[K] extends Record<string, AnyTRPCProcedure> ? RouterEntry<T[K], U, `${K}.`> : never : never;
10
+ }[keyof T];
11
+ type RouterTypes<T extends RouterTable> = {
12
+ queries: RouterEntry<T, AnyTRPCQueryProcedure>;
13
+ mutations: RouterEntry<T, AnyTRPCMutationProcedure>;
14
+ subscriptions: RouterEntry<T, AnyTRPCSubscriptionProcedure>;
15
+ };
16
+ export declare function finalizeRPCRouter<T extends RouterTable>(router: T): RouterTypes<T>;
17
+ export {};
@@ -0,0 +1,3 @@
1
+ export function finalizeRPCRouter(router) {
2
+ return router;
3
+ }
@@ -1,4 +1,5 @@
1
- export * from "./read-block-manifest";
2
- export * from "./read-view-manifest";
3
- export * from "./read-admin-manifest";
4
- export * from "./internal-store";
1
+ export * from "./read-block-manifest.js";
2
+ export * from "./read-view-manifest.js";
3
+ export * from "./read-admin-manifest.js";
4
+ export * from "./internal-store.js";
5
+ export * from "./finalize-rpc.js";
@@ -1,4 +1,5 @@
1
- export * from "./read-block-manifest";
2
- export * from "./read-view-manifest";
3
- export * from "./read-admin-manifest";
4
- export * from "./internal-store";
1
+ export * from "./read-block-manifest.js";
2
+ export * from "./read-view-manifest.js";
3
+ export * from "./read-admin-manifest.js";
4
+ export * from "./internal-store.js";
5
+ export * from "./finalize-rpc.js";
@@ -1,9 +1,7 @@
1
1
  import { FunctionComponent } from "react";
2
- import { Config as TailwindConfig } from "tailwindcss";
3
2
  type BlockManifest = Record<string, FunctionComponent<any>>;
4
3
  type Store = {
5
4
  blocks: BlockManifest;
6
- tailwindConfig: TailwindConfig | null;
7
5
  };
8
6
  export declare const internalStore: Store & {
9
7
  set<K extends keyof Store>(key: K, value: Store[K]): void;
@@ -1,9 +1,7 @@
1
1
  import { proxy, ref } from "valtio";
2
2
  export const internalStore = proxy({
3
3
  blocks: {},
4
- tailwindConfig: null,
5
4
  set(key, value) {
6
- ;
7
- internalStore[key] = value ? ref(value) : value;
5
+ internalStore[key] = (value ? ref(value) : value);
8
6
  },
9
7
  });
@@ -1,5 +1,5 @@
1
1
  import type { FunctionComponent } from "react";
2
- import { FieldTypeDefinition } from "../admin";
2
+ import { FieldTypeDefinition } from "../admin/index.js";
3
3
  /**
4
4
  * This file exists simply to prevent circular dependencies.
5
5
  * The manifest itself sets the value of this object directly.