eddev 2.0.0-beta.6 → 2.0.0-beta.61

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 (257) hide show
  1. package/dist/app/entry/MetaTags.d.ts +7 -0
  2. package/dist/app/entry/MetaTags.js +17 -0
  3. package/dist/app/entry/boot-admin.d.ts +1 -0
  4. package/dist/app/entry/boot-admin.js +14 -0
  5. package/dist/app/entry/spa-root.d.ts +1 -0
  6. package/dist/app/entry/spa-root.js +8 -0
  7. package/dist/app/entry/ssr-root-client.d.ts +6 -0
  8. package/dist/app/entry/ssr-root-client.js +26 -0
  9. package/dist/app/entry/ssr-root.d.ts +10 -0
  10. package/dist/app/entry/ssr-root.js +23 -0
  11. package/dist/app/lib/admin/index.d.ts +2 -2
  12. package/dist/app/lib/admin/index.js +2 -2
  13. package/dist/app/lib/admin/installFieldTypes.js +1 -1
  14. package/dist/app/lib/admin/runWidgets.js +1 -1
  15. package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
  16. package/dist/app/lib/blocks/ContentBlocks.js +5 -5
  17. package/dist/app/lib/blocks/EditableText.d.ts +1 -1
  18. package/dist/app/lib/blocks/EditableText.js +3 -3
  19. package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
  20. package/dist/app/lib/blocks/InnerBlocks.js +13 -5
  21. package/dist/app/lib/blocks/block-utils.d.ts +2 -2
  22. package/dist/app/lib/blocks/block-utils.js +2 -2
  23. package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
  24. package/dist/app/lib/blocks/editor/editor-config.d.ts +16 -3
  25. package/dist/app/lib/blocks/editor/editor-config.js +2 -4
  26. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +17 -13
  27. package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
  28. package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
  29. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  30. package/dist/app/lib/blocks/index.d.ts +9 -9
  31. package/dist/app/lib/blocks/index.js +9 -9
  32. package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
  33. package/dist/app/lib/blocks/inline-editing.js +7 -5
  34. package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
  35. package/dist/app/lib/devtools/components/DevUI.js +4 -3
  36. package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
  37. package/dist/app/lib/devtools/components/GridIndicator.js +24 -0
  38. package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
  39. package/dist/app/lib/devtools/dev-tools-store.js +8 -0
  40. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
  41. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  42. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1094 -1095
  43. package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
  44. package/dist/app/lib/devtools/index.d.ts +1 -0
  45. package/dist/app/lib/devtools/index.js +1 -1
  46. package/dist/app/lib/devtools/loader.js +8 -7
  47. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  48. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  49. package/dist/app/lib/dynamic/index.d.ts +1 -1
  50. package/dist/app/lib/dynamic/index.js +1 -1
  51. package/dist/app/lib/hooks/index.d.ts +4 -5
  52. package/dist/app/lib/hooks/index.js +4 -5
  53. package/dist/app/lib/hooks/queryUtils.d.ts +37 -3
  54. package/dist/app/lib/hooks/queryUtils.js +63 -26
  55. package/dist/app/lib/hooks/useAppData.js +1 -1
  56. package/dist/app/lib/hooks/useRPC.d.ts +0 -4
  57. package/dist/app/lib/hooks/useRPC.js +1 -8
  58. package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
  59. package/dist/app/lib/internal/finalize-rpc.js +3 -0
  60. package/dist/app/lib/internal/index.d.ts +5 -4
  61. package/dist/app/lib/internal/index.js +5 -4
  62. package/dist/app/lib/internal/internal-store.d.ts +0 -2
  63. package/dist/app/lib/internal/internal-store.js +1 -3
  64. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  65. package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
  66. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  67. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  68. package/dist/app/lib/legacy-stitches/index.js +1 -1
  69. package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
  70. package/dist/app/lib/routing/components/BackButton.js +47 -0
  71. package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
  72. package/dist/app/lib/routing/components/BrowserRouter.js +79 -11
  73. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  74. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  75. package/dist/app/lib/routing/components/Link.js +9 -10
  76. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  77. package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
  78. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  79. package/dist/app/lib/routing/components/SSRRouter.js +5 -6
  80. package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
  81. package/dist/app/lib/routing/context.d.ts +8 -5
  82. package/dist/app/lib/routing/context.js +13 -96
  83. package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
  84. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  85. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
  86. package/dist/app/lib/routing/hooks/useRoute.js +22 -1
  87. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
  88. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  89. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  90. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  91. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  92. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  93. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  94. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  95. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  96. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  97. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  98. package/dist/app/lib/routing/index.d.ts +14 -13
  99. package/dist/app/lib/routing/index.js +14 -13
  100. package/dist/app/lib/routing/loader.d.ts +2 -2
  101. package/dist/app/lib/routing/loader.js +7 -5
  102. package/dist/app/lib/routing/types.d.ts +35 -9
  103. package/dist/app/lib/routing/utils.d.ts +3 -1
  104. package/dist/app/lib/routing/utils.js +12 -1
  105. package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
  106. package/dist/app/lib/runtime/apiConfig.js +6 -0
  107. package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
  108. package/dist/app/lib/runtime/errorHandling.js +6 -0
  109. package/dist/app/lib/runtime/index.d.ts +2 -0
  110. package/dist/app/lib/runtime/index.js +2 -0
  111. package/dist/app/lib/views/index.d.ts +1 -1
  112. package/dist/app/lib/views/index.js +1 -1
  113. package/dist/app/server/defineRouter.d.ts +2 -0
  114. package/dist/app/server/defineRouter.js +4 -0
  115. package/dist/app/server/index.d.ts +5 -0
  116. package/dist/app/server/index.js +5 -0
  117. package/dist/app/server/proxy-wp-admin.d.ts +2 -0
  118. package/dist/app/server/proxy-wp-admin.js +112 -0
  119. package/dist/app/server/render-ssr-page.d.ts +11 -0
  120. package/dist/app/server/render-ssr-page.js +100 -0
  121. package/dist/app/server/rpc.d.ts +56 -0
  122. package/dist/app/server/rpc.js +18 -0
  123. package/dist/app/server/server-context.d.ts +53 -0
  124. package/dist/app/server/server-context.js +149 -0
  125. package/dist/app/server/utils/headers.d.ts +1 -0
  126. package/dist/app/server/utils/headers.js +17 -0
  127. package/dist/app/server/utils/replace-host.d.ts +6 -4
  128. package/dist/app/server/utils/replace-host.js +58 -11
  129. package/dist/app/utils/APIProvider.d.ts +2 -0
  130. package/dist/app/utils/APIProvider.js +5 -0
  131. package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
  132. package/dist/app/utils/BlockErrorBoundary.js +38 -0
  133. package/dist/app/utils/ErrorMessage.d.ts +5 -0
  134. package/dist/app/utils/ErrorMessage.js +14 -0
  135. package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
  136. package/dist/app/utils/RouteErrorBoundary.js +38 -0
  137. package/dist/app/utils/query-client.d.ts +2 -0
  138. package/dist/app/utils/query-client.js +5 -1
  139. package/dist/app/utils/trpc-client.d.ts +2 -0
  140. package/dist/app/utils/trpc-client.js +34 -0
  141. package/dist/node/cli/cli-worker.d.ts +1 -1
  142. package/dist/node/cli/cli-worker.js +12 -3
  143. package/dist/node/cli/cli.js +91 -13
  144. package/dist/node/cli/display/CLIApp.d.ts +1 -1
  145. package/dist/node/cli/display/CLIApp.js +4 -7
  146. package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
  147. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
  148. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
  149. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
  150. package/dist/node/cli/display/tools/cli-tools.js +9 -9
  151. package/dist/node/cli/display/util/colors.d.ts +2 -2
  152. package/dist/node/cli/version.d.ts +1 -1
  153. package/dist/node/cli/version.js +1 -1
  154. package/dist/node/compiler/build-vinxi.d.ts +8 -0
  155. package/dist/node/compiler/build-vinxi.js +38 -0
  156. package/dist/node/compiler/bundler.admin.d.ts +2 -2
  157. package/dist/node/compiler/bundler.admin.js +3 -4
  158. package/dist/node/compiler/bundler.frontend.d.ts +1 -1
  159. package/dist/node/compiler/bundler.frontend.js +3 -4
  160. package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
  161. package/dist/node/compiler/dev-server.js +106 -0
  162. package/dist/node/compiler/get-vite-config.d.ts +19 -0
  163. package/dist/node/compiler/get-vite-config.js +200 -0
  164. package/dist/node/compiler/vinxi-app.d.ts +20 -0
  165. package/dist/node/compiler/vinxi-app.js +186 -0
  166. package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
  167. package/dist/node/compiler/vinxi-codegen.js +515 -0
  168. package/dist/node/graphql/graphql-codegen.d.ts +12 -2
  169. package/dist/node/graphql/graphql-codegen.js +213 -36
  170. package/dist/node/graphql/graphql-schema-loader.js +15 -18
  171. package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
  172. package/dist/node/graphql/query-files-loader.d.ts +3 -0
  173. package/dist/node/graphql/query-files-loader.js +5 -0
  174. package/dist/node/project/config.d.ts +31 -37
  175. package/dist/node/project/config.js +13 -11
  176. package/dist/node/project/env.d.ts +1 -1
  177. package/dist/node/project/env.js +1 -1
  178. package/dist/node/project/manifest/block-manifest.js +3 -2
  179. package/dist/node/project/manifest/manifest.d.ts +2 -1
  180. package/dist/node/project/manifest/manifest.js +15 -11
  181. package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
  182. package/dist/node/project/manifest/routes-manifest.js +74 -0
  183. package/dist/node/project/manifest/view-manifest.js +2 -2
  184. package/dist/node/project/project.d.ts +5 -2
  185. package/dist/node/project/project.js +21 -20
  186. package/dist/node/project/wp-info.js +3 -2
  187. package/dist/node/types/block-type.d.ts +5 -0
  188. package/dist/node/types/block-type.js +1 -0
  189. package/dist/node/types/view-type.js +3 -4
  190. package/dist/node/utils/fs-codegen.d.ts +42 -0
  191. package/dist/node/utils/fs-codegen.js +98 -0
  192. package/dist/node/utils/fs.js +2 -0
  193. package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
  194. package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
  195. package/dist/node/utils/watch-file-tree.d.ts +25 -0
  196. package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +12 -5
  197. package/package.json +39 -32
  198. package/types.app.d.ts +4 -2
  199. package/types.app.internal.d.ts +2 -2
  200. package/types.node.d.ts +3 -3
  201. package/dist/app/entry/Root.d.ts +0 -1
  202. package/dist/app/entry/Root.js +0 -9
  203. package/dist/app/entry/main.admin.d.ts +0 -3
  204. package/dist/app/entry/main.admin.js +0 -10
  205. package/dist/app/entry/main.frontend.spa.d.ts +0 -3
  206. package/dist/app/entry/main.frontend.spa.js +0 -13
  207. package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
  208. package/dist/app/entry/main.frontend.ssr.js +0 -79
  209. package/dist/app/entry/main.serverless.dev.d.ts +0 -4
  210. package/dist/app/entry/main.serverless.dev.js +0 -21
  211. package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
  212. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
  213. package/dist/app/lib/hooks/apiConfig.js +0 -4
  214. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  215. package/dist/app/lib/hooks/usePageLoad.js +0 -5
  216. package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
  217. package/dist/app/server/create-api-builtin-hono.js +0 -80
  218. package/dist/app/server/create-ssr-hono.d.ts +0 -18
  219. package/dist/app/server/create-ssr-hono.js +0 -104
  220. package/dist/app/server/utils/index.html.d.ts +0 -2
  221. package/dist/app/server/utils/index.html.js +0 -14
  222. package/dist/node/compiler/index.html.d.ts +0 -2
  223. package/dist/node/compiler/index.html.js +0 -15
  224. package/dist/node/compiler/serverless.dev.js +0 -222
  225. package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
  226. package/dist/node/compiler/vite/get-vite-config.js +0 -315
  227. package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
  228. package/dist/node/compiler/vite/plugin-admin.js +0 -67
  229. package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
  230. package/dist/node/compiler/vite/plugin-blocks.js +0 -73
  231. package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
  232. package/dist/node/compiler/vite/plugin-entry.js +0 -16
  233. package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
  234. package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
  235. package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
  236. package/dist/node/compiler/vite/plugin-theme.js +0 -40
  237. package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
  238. package/dist/node/compiler/vite/plugin-views.js +0 -51
  239. package/dist/node/utils/console.d.ts +0 -21
  240. package/dist/node/utils/console.js +0 -28
  241. package/dist/node/utils/unsafe-fetch.d.ts +0 -2
  242. package/dist/node/utils/unsafe-fetch.js +0 -19
  243. package/dist/node/utils/watchFileTree.d.ts +0 -11
  244. package/tsup.config.ts +0 -40
  245. package/types.manifests.d.ts +0 -22
  246. /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
  247. /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
  248. /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
  249. /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
  250. /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
  251. /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
  252. /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
  253. /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
  254. /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
  255. /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
  256. /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
  257. /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useRef } from "react";
2
- import { useRouter } from "./useRouter";
2
+ import { useRouter } from "./useRouter.js";
3
3
  export function useRouteTransition(func) {
4
4
  const subscribe = useRouter((r) => r.subscribe);
5
5
  const handler = useRef(func);
@@ -1,2 +1,2 @@
1
- import { RouterAPI } from "../types";
1
+ import { RouterAPI } from "../types.js";
2
2
  export declare function useRouter<T = RouterAPI>(selector?: (r: RouterAPI) => T): T;
@@ -1,5 +1,5 @@
1
1
  import { useContext } from "react";
2
- import { RouterContext } from "../context";
2
+ import { RouterContext } from "../context.js";
3
3
  export function useRouter(selector) {
4
4
  const router = useContext(RouterContext);
5
5
  if (selector) {
@@ -1,2 +1,2 @@
1
- import type { RouterEvent } from "../types";
1
+ import type { RouterEvent } from "../types.js";
2
2
  export declare function useRouterEvents(handler: (event: RouterEvent) => void): void;
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useRef } from "react";
2
- import { useRouter } from "./useRouter";
2
+ import { useRouter } from "./useRouter.js";
3
3
  export function useRouterEvents(handler) {
4
4
  const subscribe = useRouter((r) => r.subscribe);
5
5
  const ref = useRef(handler);
@@ -1,2 +1,2 @@
1
- import { RouterAPIState } from "../types";
1
+ import { RouterAPIState } from "../types.js";
2
2
  export declare function useRouterState<T = RouterAPIState>(selector?: (state: RouterAPIState) => T): T;
@@ -1,5 +1,5 @@
1
1
  import { useContext } from "react";
2
- import { RouterStateContext } from "../context";
2
+ import { RouterStateContext } from "../context.js";
3
3
  export function useRouterState(selector) {
4
4
  const ctx = useContext(RouterStateContext);
5
5
  if (selector)
@@ -1,6 +1,6 @@
1
1
  import { useMemo } from "react";
2
- import { useRoute } from "./useRoute";
3
- import { useRouter } from "./useRouter";
2
+ import { useRoute } from "./useRoute.js";
3
+ import { useRouter } from "./useRouter.js";
4
4
  export function useSearchParams(defaultValue) {
5
5
  const route = useRoute();
6
6
  const replaceQuery = useRouter((r) => r.replaceQuery);
@@ -1,13 +1,14 @@
1
- export * from "./types";
2
- export * from "./components/Link";
3
- export * from "./components/ScrollRestoration";
4
- export * from "./components/RouteRenderer";
5
- export * from "./components/ClientOnly";
6
- export * from "./hooks/useRoute";
7
- export * from "./hooks/useRouteTransition";
8
- export * from "./hooks/useRouter";
9
- export * from "./hooks/useRouterEvents";
10
- export * from "./hooks/useRouterState";
11
- export * from "./hooks/useRestorableState";
12
- export * from "./hooks/useIsSSR";
13
- export * from "./hooks/useSearchParams";
1
+ export * from "./types.js";
2
+ export * from "./components/Link.js";
3
+ export * from "./components/ScrollRestoration.js";
4
+ export * from "./components/RouteRenderer.js";
5
+ export * from "./components/ClientOnly.js";
6
+ export * from "./components/BackButton.js";
7
+ export * from "./hooks/useRoute.js";
8
+ export * from "./hooks/useRouteTransition.js";
9
+ export * from "./hooks/useRouter.js";
10
+ export * from "./hooks/useRouterEvents.js";
11
+ export * from "./hooks/useRouterState.js";
12
+ export * from "./hooks/useRestorableState.js";
13
+ export * from "./hooks/useIsSSR.js";
14
+ export * from "./hooks/useSearchParams.js";
@@ -1,13 +1,14 @@
1
- export * from "./types";
2
- export * from "./components/Link";
3
- export * from "./components/ScrollRestoration";
4
- export * from "./components/RouteRenderer";
5
- export * from "./components/ClientOnly";
6
- export * from "./hooks/useRoute";
7
- export * from "./hooks/useRouteTransition";
8
- export * from "./hooks/useRouter";
9
- export * from "./hooks/useRouterEvents";
10
- export * from "./hooks/useRouterState";
11
- export * from "./hooks/useRestorableState";
12
- export * from "./hooks/useIsSSR";
13
- export * from "./hooks/useSearchParams";
1
+ export * from "./types.js";
2
+ export * from "./components/Link.js";
3
+ export * from "./components/ScrollRestoration.js";
4
+ export * from "./components/RouteRenderer.js";
5
+ export * from "./components/ClientOnly.js";
6
+ export * from "./components/BackButton.js";
7
+ export * from "./hooks/useRoute.js";
8
+ export * from "./hooks/useRouteTransition.js";
9
+ export * from "./hooks/useRouter.js";
10
+ export * from "./hooks/useRouterEvents.js";
11
+ export * from "./hooks/useRouterState.js";
12
+ export * from "./hooks/useRestorableState.js";
13
+ export * from "./hooks/useIsSSR.js";
14
+ export * from "./hooks/useSearchParams.js";
@@ -1,6 +1,6 @@
1
1
  import { FunctionComponent, PropsWithChildren } from "react";
2
- import { DynamicComponent } from "../dynamic/dynamic";
3
- import { RouteData } from "./types";
2
+ import { DynamicComponent } from "../dynamic/dynamic.js";
3
+ import { RouteData } from "./types.js";
4
4
  export type RouteCacheEntry = {
5
5
  data: RouteData;
6
6
  component: FunctionComponent;
@@ -1,5 +1,5 @@
1
1
  import { parseURL, stringifyParsedURL, stringifyQuery, withTrailingSlash } from "ufo";
2
- import { viewManifestReader } from "../internal";
2
+ import { viewManifestReader } from "../internal/read-view-manifest.js";
3
3
  export class RouteError extends Error {
4
4
  message;
5
5
  statusCode;
@@ -31,10 +31,12 @@ export class RouteLoader {
31
31
  const origin = parseURL(sampleUrl);
32
32
  let propsPath = withTrailingSlash(pathname);
33
33
  let query = {};
34
- if (opts.serverless) {
35
- query["_debug"] = opts.debug ? "1" : "0";
36
- query["_props"] = opts.appData ? "all" : "1";
37
- query["_ssr"] = "1";
34
+ if (env.serverless && env.client) {
35
+ propsPath = "/_data/route" + propsPath;
36
+ query = {};
37
+ // query["_debug"] = opts.debug ? "1" : "0"
38
+ // query["_props"] = opts.appData ? "all" : "1"
39
+ // query["_ssr"] = "1"
38
40
  }
39
41
  else {
40
42
  query["_debug"] = opts.debug ? "1" : "0";
@@ -1,9 +1,16 @@
1
1
  import { FunctionComponent } from "react";
2
- import type { RouteLoader } from "./loader";
3
- import { LinkHandlerMode, PointerOrMouseEvent } from "./utils";
4
- export type ParsedRouteTags = Record<"title" | "meta" | "script" | "style" | "link", {
5
- [key: string]: string;
6
- }[]>;
2
+ import type { RouteLoader } from "./loader.js";
3
+ import { LinkHandlerMode, PointerOrMouseEvent } from "./utils.js";
4
+ export type RouteMetaTag = {
5
+ tagName: string;
6
+ attributes: Record<string, string>;
7
+ inner?: string;
8
+ };
9
+ export type TrackerTags = {
10
+ head?: RouteMetaTag[];
11
+ body?: RouteMetaTag[];
12
+ footer?: RouteMetaTag[];
13
+ };
7
14
  export interface RouteData {
8
15
  view: string;
9
16
  editLink?: string;
@@ -13,10 +20,13 @@ export interface RouteData {
13
20
  redirect?: string;
14
21
  canonical?: string;
15
22
  meta?: {
16
- head: ParsedRouteTags;
17
- footer: ParsedRouteTags;
23
+ head: RouteMetaTag[];
24
+ footer: RouteMetaTag[];
18
25
  };
19
26
  }
27
+ export interface RouteDataWithTrackers extends RouteData {
28
+ trackers?: TrackerTags;
29
+ }
20
30
  export type RouteReturnState<T = {}> = {
21
31
  scrollTop: number;
22
32
  scrollLeft: number;
@@ -99,14 +109,24 @@ export type RouterAPI = {
99
109
  replaceQuery: (search: Record<string, string | string[]>) => void;
100
110
  /** Replace the hash */
101
111
  replaceHash: (hash: string) => void;
102
- /** Handle link clicking events */
103
- handleClickEvent(e: PointerOrMouseEvent, href?: string): void;
112
+ /**
113
+ * Handle a click event, potentially triggering a route change.
114
+ *
115
+ * @param e A pointer or mouse event.
116
+ * @param href An optional URL. This must be provided if no `href` property exists on the clicked element
117
+ * @param preferBack If set, clicking this link will send the user 'back', when clicking a link to the previous history item.
118
+ */
119
+ handleClickEvent(e: PointerOrMouseEvent, href?: string, preferBack?: boolean | "exact"): void;
104
120
  /** A reference to the route loader (mostly for internal use) */
105
121
  loader: RouteLoader;
106
122
  /** Subscribe to events */
107
123
  subscribe: (subscribe: RouterSubscriber) => () => void;
108
124
  /** This function is used by the routing system automatically */
109
125
  emitEvent: (event: RouterEvent) => void;
126
+ /** Returns the current RouterAPIState */
127
+ getState: () => RouterAPIState | null;
128
+ /** Go back to a previous route in the history stack, or push it onto the stack if it isn't currently on the stack. */
129
+ restoreRoute: (route: RouteState) => void;
110
130
  };
111
131
  export type TypedRouteState<T, TProps> = {
112
132
  /** A unique ID, representing this history item. */
@@ -131,6 +151,12 @@ export type TypedRouteState<T, TProps> = {
131
151
  component: FunctionComponent<TProps>;
132
152
  /** The props for this route, to be passed to the component. */
133
153
  props: TProps;
154
+ /** Loaded metadata for this route */
155
+ meta: RouteMeta;
156
+ };
157
+ export type RouteMeta = {
158
+ title?: string;
159
+ tags?: RouteMetaTag[];
134
160
  };
135
161
  export type RouteState = {
136
162
  [K in keyof ViewProps]: TypedRouteState<K, ViewProps[K]>;
@@ -1,6 +1,7 @@
1
1
  import { MouseEvent as ReactMouseEvent, PointerEvent as ReactPointerEvent } from "react";
2
- import { RouteLink, RouteState } from "./types";
2
+ import { RouteData, RouteLink, RouteMeta, RouteState } from "./types.js";
3
3
  export declare function isSameOrigin(url: string): boolean;
4
+ export declare function isSamePathname(a: string, b: string): boolean;
4
5
  export type PointerOrMouseEvent = MouseEvent | PointerEvent | ReactMouseEvent | ReactPointerEvent;
5
6
  export type LinkHandlerMode = {
6
7
  mode: "ignore" | "navigate" | "native";
@@ -12,4 +13,5 @@ export declare function normalizeRoute(route: Partialize<RouteState, "uri" | "re
12
13
  export declare function stringifyRouteLink(route: RouteLink): string;
13
14
  export declare function parseQuery(query: string): Record<string, string | string[]>;
14
15
  export declare function stringifyQuery(query: any): string;
16
+ export declare function getRouteMeta(data: RouteData): RouteMeta;
15
17
  export {};
@@ -1,5 +1,5 @@
1
+ import { parse as qsParse, stringify as qsStringify } from "qs";
1
2
  import { parseURL, resolveURL, stringifyParsedURL, withoutTrailingSlash } from "ufo";
2
- import { stringify as qsStringify, parse as qsParse } from "qs";
3
3
  export function isSameOrigin(url) {
4
4
  if (typeof document === "undefined") {
5
5
  return url.startsWith("/");
@@ -10,6 +10,11 @@ export function isSameOrigin(url) {
10
10
  return parsed.protocol === document.location.protocol && parsed.host === document.location.host;
11
11
  }
12
12
  }
13
+ export function isSamePathname(a, b) {
14
+ const left = parseURL(a).pathname.replace(/\/$/, "").toLocaleLowerCase();
15
+ const right = parseURL(b).pathname.replace(/\/$/, "").toLocaleLowerCase();
16
+ return left === right;
17
+ }
13
18
  export function getLinkHandlerMode(e, href) {
14
19
  try {
15
20
  // Attempt to get the link element, if there is one
@@ -92,3 +97,9 @@ export function stringifyQuery(query) {
92
97
  arrayFormat: "brackets",
93
98
  });
94
99
  }
100
+ export function getRouteMeta(data) {
101
+ return {
102
+ title: data.meta?.head.find((tag) => tag.tagName === "title")?.inner,
103
+ tags: data.meta?.head ?? [],
104
+ };
105
+ }
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Configuration options for manipulating how the client interacts with the GraphQL API
3
+ */
1
4
  export type APIConfigStore = {
2
5
  /**
3
6
  * Any value, which will be used as part of the cache key for each query.
@@ -11,8 +14,9 @@ export type APIConfigStore = {
11
14
  */
12
15
  customQueryFetchOptions?: (type: "query" | "mutation", queryName: string, queryArgs: any, url: string, opts: RequestInit) => RequestInit | Promise<RequestInit>;
13
16
  /**
14
- * Update aspects of the API client
17
+ * Allows you to hook into the response of a query or mutation.
15
18
  */
19
+ onResponse?: (response: Response, type: "query" | "mutation", queryName: string, queryArgs: any, url: string, opts: RequestInit) => void;
16
20
  set: (config: Partial<APIConfigStore>) => void;
17
21
  };
18
- export declare const useAPIConfig: import("zustand").UseBoundStore<import("zustand").StoreApi<APIConfigStore>>;
22
+ export declare const apiConfig: APIConfigStore;
@@ -0,0 +1,6 @@
1
+ import { proxy } from "valtio";
2
+ export const apiConfig = proxy({
3
+ set: (config) => {
4
+ Object.assign(apiConfig, config);
5
+ },
6
+ });
@@ -0,0 +1,39 @@
1
+ import { ContentBlock } from "../blocks";
2
+ import { ReactNode } from "react";
3
+ import { RouteState } from "../routing";
4
+ export type ErrorEvent = {
5
+ /** The runtime error that occurred */
6
+ error: Error;
7
+ /** The Component stack (not available in renderBlockError) */
8
+ componentStack?: string;
9
+ } & ({
10
+ type: "block";
11
+ /** The block which had an error, including it's type information, props, content and children */
12
+ block: ContentBlock;
13
+ } | {
14
+ type: "route";
15
+ /** The route which had an error */
16
+ route: RouteState;
17
+ });
18
+ /**
19
+ * Configuration options for manipulating how the client interacts with the GraphQL API
20
+ */
21
+ export type ErrorHandlingConfig = {
22
+ /**
23
+ * Triggered when a runtime error occurs in a block
24
+ * @param event The error event, containing the error and block information
25
+ **/
26
+ onReactError?(event: ErrorEvent): void;
27
+ /**
28
+ * Triggered when a React rendering error occurs, and allows you to return some JSX to render as a fallback.
29
+ * If not provided, the block will be hidden from the user.
30
+ * @param error The error event, containing the error and contextual information
31
+ * @param defaultDisplay The default display for the block — in development, this will display the error message. In production, this will be `null`.
32
+ */
33
+ renderFallback?(event: ErrorEvent, defaultDisplay: ReactNode): ReactNode;
34
+ /**
35
+ * Update the error handling configuration all at once
36
+ */
37
+ set: (config: Partial<ErrorHandlingConfig>) => void;
38
+ };
39
+ export declare const errorHandling: ErrorHandlingConfig;
@@ -0,0 +1,6 @@
1
+ import { proxy } from "valtio";
2
+ export const errorHandling = proxy({
3
+ set: (config) => {
4
+ Object.assign(errorHandling, config);
5
+ },
6
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./apiConfig";
2
+ export * from "./errorHandling";
@@ -0,0 +1,2 @@
1
+ export * from "./apiConfig";
2
+ export * from "./errorHandling";
@@ -1 +1 @@
1
- export * from "./defineView";
1
+ export * from "./defineView.js";
@@ -1 +1 @@
1
- export * from "./defineView";
1
+ export * from "./defineView.js";
@@ -0,0 +1,2 @@
1
+ import { Hono } from "hono";
2
+ export declare function defineRouter(): Hono;
@@ -0,0 +1,4 @@
1
+ import { Hono } from "hono";
2
+ export function defineRouter() {
3
+ return new Hono();
4
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./render-ssr-page.js";
2
+ export * from "./server-context.js";
3
+ export * from "./proxy-wp-admin.js";
4
+ export * from "./defineRouter.js";
5
+ export * from "./rpc.js";
@@ -0,0 +1,5 @@
1
+ export * from "./render-ssr-page.js";
2
+ export * from "./server-context.js";
3
+ export * from "./proxy-wp-admin.js";
4
+ export * from "./defineRouter.js";
5
+ export * from "./rpc.js";
@@ -0,0 +1,2 @@
1
+ import { EventHandlerRequest, H3Event } from "vinxi/http";
2
+ export declare function proxyWpAdmin(event: H3Event<EventHandlerRequest>): Promise<Response>;
@@ -0,0 +1,112 @@
1
+ /// <reference types="vinxi/types/server" />
2
+ import { splitSetCookieString } from "cookie-es";
3
+ import { getProxyRequestHeaders, getRequestURL, getWebRequest } from "vinxi/http";
4
+ import { ServerContext } from "./server-context.js";
5
+ export async function proxyWpAdmin(event) {
6
+ const serverContext = ServerContext.main;
7
+ const replaceUrls = serverContext.replaceUrls;
8
+ const req = getWebRequest(event);
9
+ const proxyUrl = serverContext.getOriginUrl(getRequestURL(event).href);
10
+ // Prepare request headers to be sent to the origin server
11
+ const proxyHeaders = getProxyRequestHeaders(event);
12
+ proxyHeaders["X-ED-Dev-Proxy"] = "true";
13
+ // Forward the request to the origin server
14
+ const response = await fetch(proxyUrl, {
15
+ method: req.method,
16
+ referrer: req.referrer,
17
+ referrerPolicy: req.referrerPolicy,
18
+ headers: proxyHeaders,
19
+ body: req.method.match(/get|head|options/i) ? undefined : await req.blob(),
20
+ redirect: "manual",
21
+ cache: "no-cache",
22
+ });
23
+ const contentType = response.headers.get("content-type");
24
+ let body;
25
+ let res = { status: response.status, statusText: response.statusText, headers: new Headers() };
26
+ const cookies = [];
27
+ response.headers.forEach((value, key) => {
28
+ if (key === "content-encoding" || key === "content-length" || key === "transfer-encoding") {
29
+ return;
30
+ }
31
+ if (key === "set-cookie") {
32
+ cookies.push(...splitSetCookieString(value));
33
+ return;
34
+ }
35
+ if (key === "location" && replaceUrls) {
36
+ value = replaceUrls(value);
37
+ }
38
+ res.headers.set(key, value);
39
+ });
40
+ // Set cookies in the response headers
41
+ // TODO: May need to rewrite cookie domain here before setting.
42
+ if (cookies.length > 0) {
43
+ for (const cookie of cookies) {
44
+ res.headers.append("set-cookie", cookie);
45
+ }
46
+ }
47
+ // Replace URLs pointing to the origin server from the response itself
48
+ // This is only done for text-based content types, like application/json, text/plain, text/html etc
49
+ if (contentType?.match(/(application|text)\//)) {
50
+ if (replaceUrls) {
51
+ body = replaceUrls((await response.text()) ?? "");
52
+ }
53
+ // If the content type is text/html, inject the Vite assets into the response — assuming the placeholder comments are found
54
+ if (contentType.startsWith("text/html")) {
55
+ const clientManifest = serverContext.runtime.getManifest("admin");
56
+ const assets = await clientManifest.inputs[clientManifest.handler].assets();
57
+ const getViteHeader = () => assets.map((asset) => renderAsset(asset)).join("\n");
58
+ const getViteFooter = () => renderAsset({
59
+ tag: "script",
60
+ attrs: {
61
+ type: "module",
62
+ src: clientManifest.inputs[clientManifest.handler].output.path,
63
+ },
64
+ children: "",
65
+ });
66
+ const encodeForJSON = (str) => JSON.stringify(str).slice(1, -1).replace(/\"/g, "'");
67
+ body = body.replace(/<!---VITE_HEADER--->/g, getViteHeader);
68
+ body = body.replace(/<!---VITE_FOOTER--->/g, getViteFooter);
69
+ body = body.replace(/<!---VITE_HEADER_ENCODED--->/g, encodeForJSON(getViteHeader()));
70
+ body = body.replace(/<!---VITE_FOOTER_ENCODED--->/g, encodeForJSON(getViteFooter()));
71
+ }
72
+ }
73
+ else {
74
+ // Otherwise just stream the response as is
75
+ body = response.body;
76
+ }
77
+ return new Response(body, res);
78
+ }
79
+ function printElement(element, props, innerText) {
80
+ if (typeof innerText === "string") {
81
+ return `<${element}${Object.entries(props)
82
+ .map(([key, value]) => ` ${key}="${value}"`)
83
+ .join("")}>${innerText}</${element}>`;
84
+ }
85
+ else {
86
+ return `<${element}${Object.entries(props)
87
+ .map(([key, value]) => ` ${key}="${value}"`)
88
+ .join("")} />`;
89
+ }
90
+ }
91
+ function renderAsset({ tag, attrs: { key, ...attrs } = {}, children, }) {
92
+ switch (tag) {
93
+ case "script":
94
+ if (attrs.src) {
95
+ return printElement("script", { ...attrs, key: attrs.src }, "");
96
+ }
97
+ else {
98
+ return printElement("script", {
99
+ ...attrs,
100
+ key: key,
101
+ }, children ?? "");
102
+ }
103
+ case "link":
104
+ return printElement("link", { ...attrs, key: key });
105
+ case "style":
106
+ return printElement("style", {
107
+ ...attrs,
108
+ key: key,
109
+ }, children ?? "");
110
+ }
111
+ return "";
112
+ }
@@ -0,0 +1,11 @@
1
+ import type { RouteDataWithTrackers } from "../lib/routing/types.js";
2
+ type SSRArgs = {
3
+ pathname: string;
4
+ initialData: RouteDataWithTrackers;
5
+ };
6
+ export declare function getSsrStream(args: SSRArgs): Promise<ReadableStream<Uint8Array>>;
7
+ type RenderArgs = {
8
+ pathname: string;
9
+ };
10
+ export declare function renderPage(args: RenderArgs): Promise<Response>;
11
+ export {};
@@ -0,0 +1,100 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { renderAsset } from "@vinxi/react";
3
+ import { Suspense } from "react";
4
+ import { renderToPipeableStream } from "react-dom/server";
5
+ import { SSRRoot } from "../entry/ssr-root.js";
6
+ import { RouteLoader } from "../lib/routing/loader.js";
7
+ import { ServerContext } from "./server-context.js";
8
+ import { Writable } from "stream";
9
+ export async function getSsrStream(args) {
10
+ const clientManifest = ServerContext.main.runtime.getManifest("client");
11
+ const assets = await clientManifest.inputs[clientManifest.handler].assets();
12
+ const jsx = (_jsx(SSRRoot, { assets: _jsx(Suspense, { children: assets.map((m) => renderAsset(m)) }), metaTags: args.initialData?.meta?.head || [], pathname: args.pathname, initialData: args.initialData, loader: new RouteLoader() }));
13
+ const stream = await new Promise(async (resolve, reject) => {
14
+ // console.log("Rendering to pipable")
15
+ const stream = renderToPipeableStream(jsx, {
16
+ onShellReady() {
17
+ // console.log("Shell ready")
18
+ resolve(stream);
19
+ },
20
+ onShellError(err) {
21
+ console.log("onShellError", err);
22
+ reject(err);
23
+ },
24
+ onError(err, errInfo) {
25
+ console.log("Error occurred after shell ready", err, errInfo);
26
+ console.error(err);
27
+ },
28
+ bootstrapModules: [clientManifest.inputs[clientManifest.handler].output.path],
29
+ bootstrapScriptContent: `window.manifest = ${JSON.stringify(await clientManifest.json())};\nwindow._PAGE_DATA = ${JSON.stringify(args.initialData)};\nwindow._TRACKERS = ${JSON.stringify(args.initialData.trackers)}`,
30
+ });
31
+ });
32
+ return new ReadableStream({
33
+ async start(controller) {
34
+ const writableStream = new Writable({
35
+ emitClose: true,
36
+ write(chunk, encoding, callback) {
37
+ controller.enqueue(chunk);
38
+ callback();
39
+ },
40
+ final(callback) {
41
+ controller.close();
42
+ callback();
43
+ },
44
+ });
45
+ stream.pipe(writableStream);
46
+ },
47
+ });
48
+ }
49
+ export async function renderPage(args) {
50
+ const serverContext = ServerContext.main;
51
+ let headers = new Headers();
52
+ let responseInit = {
53
+ headers,
54
+ };
55
+ try {
56
+ const [{ appData, trackers }, response] = await Promise.all([
57
+ serverContext.fetchAppData(),
58
+ serverContext.fetchRouteData({
59
+ pathname: args.pathname,
60
+ withAppData: false,
61
+ headers: {},
62
+ query: {},
63
+ }),
64
+ ]);
65
+ let data;
66
+ try {
67
+ data = await response.json();
68
+ data.appData = appData;
69
+ data.trackers = trackers;
70
+ }
71
+ catch (err) {
72
+ data = {
73
+ view: "_error",
74
+ viewType: "react",
75
+ viewData: {},
76
+ appData: appData,
77
+ };
78
+ console.error(err);
79
+ responseInit.status = 500;
80
+ }
81
+ headers.set("Content-Type", "text/html; charset=utf-8");
82
+ const stream = await getSsrStream({
83
+ ...args,
84
+ initialData: data,
85
+ });
86
+ return new Response(stream, responseInit);
87
+ }
88
+ catch (err) {
89
+ console.error(err);
90
+ return new Response('<!DOCTYPE html><html><head><title>500 Internal Server Error</title></head><body><h1>500 Internal Server Error</h1><p>"' +
91
+ String(err) +
92
+ '"</p></body></html>', {
93
+ status: 500,
94
+ statusText: "Internal Server Error",
95
+ headers: {
96
+ "Content-Type": "text/html; charset=utf-8",
97
+ },
98
+ });
99
+ }
100
+ }