eddev 2.0.0-beta.4 → 2.0.0-beta.41

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 (218) 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/{main.admin.js → boot-admin.js} +3 -5
  5. package/dist/app/entry/spa-root.d.ts +1 -0
  6. package/dist/app/entry/{Root.js → spa-root.js} +4 -4
  7. package/dist/app/entry/ssr-root-client.d.ts +6 -0
  8. package/dist/app/entry/ssr-root-client.js +16 -0
  9. package/dist/app/entry/ssr-root.d.ts +10 -0
  10. package/dist/app/entry/ssr-root.js +24 -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.js +4 -4
  16. package/dist/app/lib/blocks/EditableText.d.ts +1 -1
  17. package/dist/app/lib/blocks/EditableText.js +3 -3
  18. package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +1 -0
  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 +3 -3
  24. package/dist/app/lib/blocks/editor/editor-config.d.ts +1 -1
  25. package/dist/app/lib/blocks/editor/editor-config.js +1 -1
  26. package/dist/app/lib/blocks/editor/installGutenbergHooks.js +5 -5
  27. package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
  28. package/dist/app/lib/blocks/index.d.ts +9 -9
  29. package/dist/app/lib/blocks/index.js +9 -9
  30. package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
  31. package/dist/app/lib/blocks/inline-editing.js +7 -5
  32. package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
  33. package/dist/app/lib/devtools/components/DevUI.js +4 -3
  34. package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
  35. package/dist/app/lib/devtools/components/GridIndicator.js +24 -0
  36. package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
  37. package/dist/app/lib/devtools/dev-tools-store.js +8 -0
  38. package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
  39. package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
  40. package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1078 -1079
  41. package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
  42. package/dist/app/lib/devtools/index.d.ts +1 -0
  43. package/dist/app/lib/devtools/index.js +1 -1
  44. package/dist/app/lib/devtools/loader.js +8 -7
  45. package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
  46. package/dist/app/lib/devtools/useQueryDebug.js +5 -8
  47. package/dist/app/lib/dynamic/index.d.ts +1 -1
  48. package/dist/app/lib/dynamic/index.js +1 -1
  49. package/dist/app/lib/hooks/apiConfig.d.ts +3 -1
  50. package/dist/app/lib/hooks/apiConfig.js +9 -4
  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 +5 -2
  54. package/dist/app/lib/hooks/queryUtils.js +19 -20
  55. package/dist/app/lib/hooks/useAppData.js +1 -1
  56. package/dist/app/lib/internal/index.d.ts +4 -4
  57. package/dist/app/lib/internal/index.js +4 -4
  58. package/dist/app/lib/internal/internal-store.d.ts +0 -2
  59. package/dist/app/lib/internal/internal-store.js +1 -3
  60. package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
  61. package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
  62. package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
  63. package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
  64. package/dist/app/lib/legacy-stitches/index.js +1 -1
  65. package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
  66. package/dist/app/lib/routing/components/BackButton.js +47 -0
  67. package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
  68. package/dist/app/lib/routing/components/BrowserRouter.js +68 -11
  69. package/dist/app/lib/routing/components/ClientOnly.js +1 -1
  70. package/dist/app/lib/routing/components/Link.d.ts +1 -0
  71. package/dist/app/lib/routing/components/Link.js +9 -10
  72. package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
  73. package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
  74. package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
  75. package/dist/app/lib/routing/components/SSRRouter.js +5 -6
  76. package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
  77. package/dist/app/lib/routing/context.d.ts +2 -2
  78. package/dist/app/lib/routing/context.js +6 -96
  79. package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
  80. package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
  81. package/dist/app/lib/routing/hooks/useRoute.js +22 -1
  82. package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
  83. package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
  84. package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
  85. package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
  86. package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
  87. package/dist/app/lib/routing/hooks/useRouter.js +1 -1
  88. package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
  89. package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
  90. package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
  91. package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
  92. package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
  93. package/dist/app/lib/routing/index.d.ts +14 -13
  94. package/dist/app/lib/routing/index.js +14 -13
  95. package/dist/app/lib/routing/loader.d.ts +2 -2
  96. package/dist/app/lib/routing/loader.js +7 -5
  97. package/dist/app/lib/routing/types.d.ts +28 -8
  98. package/dist/app/lib/routing/utils.d.ts +3 -1
  99. package/dist/app/lib/routing/utils.js +11 -0
  100. package/dist/app/lib/views/index.d.ts +1 -1
  101. package/dist/app/lib/views/index.js +1 -1
  102. package/dist/app/server/defineRouter.d.ts +2 -0
  103. package/dist/app/server/defineRouter.js +4 -0
  104. package/dist/app/server/index.d.ts +4 -0
  105. package/dist/app/server/index.js +4 -0
  106. package/dist/app/server/proxy-wp-admin.d.ts +3 -0
  107. package/dist/app/server/proxy-wp-admin.js +105 -0
  108. package/dist/app/server/render-ssr-page.d.ts +5 -0
  109. package/dist/app/server/render-ssr-page.js +31 -0
  110. package/dist/app/server/server-context.d.ts +50 -0
  111. package/dist/app/server/server-context.js +145 -0
  112. package/dist/app/server/utils/headers.d.ts +1 -0
  113. package/dist/app/server/utils/headers.js +17 -0
  114. package/dist/app/server/utils/replace-host.d.ts +6 -4
  115. package/dist/app/server/utils/replace-host.js +58 -11
  116. package/dist/node/cli/cli-worker.d.ts +1 -1
  117. package/dist/node/cli/cli-worker.js +7 -2
  118. package/dist/node/cli/cli.js +84 -12
  119. package/dist/node/cli/display/CLIApp.d.ts +1 -1
  120. package/dist/node/cli/display/CLIApp.js +3 -6
  121. package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
  122. package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
  123. package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
  124. package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
  125. package/dist/node/cli/display/tools/cli-tools.js +9 -9
  126. package/dist/node/cli/display/util/colors.d.ts +2 -2
  127. package/dist/node/cli/version.d.ts +1 -1
  128. package/dist/node/cli/version.js +1 -1
  129. package/dist/node/compiler/build-vinxi.d.ts +8 -0
  130. package/dist/node/compiler/build-vinxi.js +37 -0
  131. package/dist/node/compiler/bundler.admin.d.ts +2 -2
  132. package/dist/node/compiler/bundler.admin.js +3 -4
  133. package/dist/node/compiler/bundler.frontend.d.ts +1 -1
  134. package/dist/node/compiler/bundler.frontend.js +3 -4
  135. package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
  136. package/dist/node/compiler/dev-server.js +105 -0
  137. package/dist/node/compiler/get-vite-config.d.ts +19 -0
  138. package/dist/node/compiler/get-vite-config.js +200 -0
  139. package/dist/node/compiler/vinxi-app.d.ts +19 -0
  140. package/dist/node/compiler/vinxi-app.js +159 -0
  141. package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
  142. package/dist/node/compiler/vinxi-codegen.js +464 -0
  143. package/dist/node/graphql/graphql-codegen.d.ts +1 -1
  144. package/dist/node/graphql/graphql-codegen.js +63 -16
  145. package/dist/node/graphql/graphql-schema-loader.js +15 -18
  146. package/dist/node/project/config.js +1 -1
  147. package/dist/node/project/env.d.ts +1 -1
  148. package/dist/node/project/env.js +1 -1
  149. package/dist/node/project/manifest/block-manifest.js +2 -2
  150. package/dist/node/project/manifest/manifest.d.ts +1 -1
  151. package/dist/node/project/manifest/manifest.js +1 -1
  152. package/dist/node/project/manifest/view-manifest.js +2 -2
  153. package/dist/node/project/project.d.ts +3 -2
  154. package/dist/node/project/project.js +18 -20
  155. package/dist/node/project/wp-info.js +3 -2
  156. package/dist/node/types/view-type.js +3 -4
  157. package/dist/node/utils/fs-codegen.d.ts +40 -0
  158. package/dist/node/utils/fs-codegen.js +97 -0
  159. package/dist/node/utils/fs.js +2 -0
  160. package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
  161. package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
  162. package/package.json +31 -32
  163. package/types.app.d.ts +2 -2
  164. package/types.app.internal.d.ts +2 -2
  165. package/types.node.d.ts +3 -3
  166. package/dist/app/entry/Root.d.ts +0 -1
  167. package/dist/app/entry/main.admin.d.ts +0 -3
  168. package/dist/app/entry/main.frontend.spa.d.ts +0 -3
  169. package/dist/app/entry/main.frontend.spa.js +0 -13
  170. package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
  171. package/dist/app/entry/main.frontend.ssr.js +0 -79
  172. package/dist/app/entry/main.serverless.dev.d.ts +0 -4
  173. package/dist/app/entry/main.serverless.dev.js +0 -21
  174. package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
  175. package/dist/app/lib/hooks/usePageLoad.js +0 -5
  176. package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
  177. package/dist/app/server/create-api-builtin-hono.js +0 -80
  178. package/dist/app/server/create-ssr-hono.d.ts +0 -18
  179. package/dist/app/server/create-ssr-hono.js +0 -104
  180. package/dist/app/server/utils/index.html.d.ts +0 -2
  181. package/dist/app/server/utils/index.html.js +0 -14
  182. package/dist/node/compiler/index.html.d.ts +0 -2
  183. package/dist/node/compiler/index.html.js +0 -15
  184. package/dist/node/compiler/serverless.dev.js +0 -215
  185. package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
  186. package/dist/node/compiler/vite/get-vite-config.js +0 -323
  187. package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
  188. package/dist/node/compiler/vite/plugin-admin.js +0 -67
  189. package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
  190. package/dist/node/compiler/vite/plugin-blocks.js +0 -73
  191. package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
  192. package/dist/node/compiler/vite/plugin-entry.js +0 -16
  193. package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
  194. package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
  195. package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
  196. package/dist/node/compiler/vite/plugin-theme.js +0 -40
  197. package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
  198. package/dist/node/compiler/vite/plugin-views.js +0 -51
  199. package/dist/node/utils/console.d.ts +0 -21
  200. package/dist/node/utils/console.js +0 -28
  201. package/dist/node/utils/unsafe-fetch.d.ts +0 -2
  202. package/dist/node/utils/unsafe-fetch.js +0 -19
  203. package/tsup.config.ts +0 -40
  204. package/types.manifests.d.ts +0 -22
  205. /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
  206. /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
  207. /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
  208. /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
  209. /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
  210. /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
  211. /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
  212. /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
  213. /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
  214. /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
  215. /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
  216. /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
  217. /package/dist/node/utils/{watchFileTree.d.ts → watch-file-tree.d.ts} +0 -0
  218. /package/dist/node/utils/{watchFileTree.js → watch-file-tree.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
  }
@@ -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";
@@ -13,6 +13,8 @@ export type APIConfigStore = {
13
13
  /**
14
14
  * Update aspects of the API client
15
15
  */
16
+ onResponse?: (response: Response) => void;
16
17
  set: (config: Partial<APIConfigStore>) => void;
17
18
  };
18
- export declare const useAPIConfig: import("zustand").UseBoundStore<import("zustand").StoreApi<APIConfigStore>>;
19
+ export declare const apiConfig: APIConfigStore;
20
+ export declare function useAPIConfig(): APIConfigStore;
@@ -1,4 +1,9 @@
1
- import { create } from "zustand";
2
- export const useAPIConfig = create((set, get) => ({
3
- set: (config) => set(config),
4
- }));
1
+ import { proxy } from "valtio";
2
+ export const apiConfig = proxy({
3
+ set: (config) => {
4
+ Object.assign(apiConfig, config);
5
+ },
6
+ });
7
+ export function useAPIConfig() {
8
+ return apiConfig;
9
+ }
@@ -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 "./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 "./apiConfig.js";
@@ -1,4 +1,4 @@
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
2
  type OptionalMaybes<T> = T extends any[] ? T : T extends {
3
3
  [key: string]: any;
4
4
  } ? {
@@ -33,7 +33,10 @@ export type UseInfiniteQueryFunction<TData, TVars> = (args: OptionalMaybes<Omit<
33
33
  headers?: Record<string, string>;
34
34
  /** Initial data can be passed in, but should match the original GraphQL query in structure (including nodes/hasNextPage/endCursor) */
35
35
  initialData?: any;
36
- }) => UseInfiniteQueryResult<TData, QueryError>;
36
+ }) => UseInfiniteQueryResult<{
37
+ nodes: TData;
38
+ total?: number | null;
39
+ }, QueryError>;
37
40
  export declare function createUseInfiniteQuery<TData extends any, TVars extends MaybeVars>(init: CreateUseInfiniteQueryOptions): UseInfiniteQueryFunction<TData, TVars>;
38
41
  export type UseMutationFunction<TData, TArgs> = ((options?: Omit<UseMutationOptions<TData, QueryError, TArgs>, "mutationFn"> & {
39
42
  headers?: Record<string, string>;
@@ -1,8 +1,8 @@
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, } from "@tanstack/react-query";
5
2
  import { useEffect, useState } from "react";
3
+ import { joinURL } from "ufo";
4
+ import { getQueryClient } from "../../utils/query-client.js";
5
+ import { apiConfig } from "./apiConfig.js";
6
6
  function createQueryError(messages, statusCode) {
7
7
  const error = new Error(messages.join(", "));
8
8
  error.statusCode = statusCode;
@@ -15,7 +15,7 @@ const fetchGETQuery = async (name, params, opts) => {
15
15
  headers: opts?.headers,
16
16
  };
17
17
  if (env.serverless && env.client) {
18
- url = `/api/rest/query/${name}`;
18
+ url = `/_data/query/${name}`;
19
19
  }
20
20
  else if (env.serverless) {
21
21
  url = joinURL(env.origin ?? "", `/wp-json/ed/v1/query/${name}`);
@@ -26,11 +26,12 @@ const fetchGETQuery = async (name, params, opts) => {
26
26
  if (params)
27
27
  url += "?params=" + encodeURIComponent(params);
28
28
  // Apply API configuration
29
- const apiConfig = useAPIConfig.getState();
30
29
  if (apiConfig.customQueryFetchOptions) {
31
30
  options = await apiConfig.customQueryFetchOptions?.("query", name, params, url, options);
32
31
  }
33
32
  const response = await fetch(url, options);
33
+ if (apiConfig.onResponse)
34
+ apiConfig.onResponse(response);
34
35
  const payload = await response.json();
35
36
  if (payload.errors?.length > 0) {
36
37
  throw createQueryError(payload.errors.map((e) => e.message), response.status);
@@ -39,7 +40,7 @@ const fetchGETQuery = async (name, params, opts) => {
39
40
  };
40
41
  export function createUseQuery(init) {
41
42
  const hook = (args, options) => {
42
- const customKey = useAPIConfig((state) => state.customQueryKey);
43
+ const customKey = apiConfig.customQueryKey;
43
44
  return useQuery({
44
45
  queryKey: [init.name, args, options?.headers, options?.headers, customKey],
45
46
  queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
@@ -49,7 +50,7 @@ export function createUseQuery(init) {
49
50
  });
50
51
  };
51
52
  hook.fetch = async (args, options) => {
52
- const customKey = useAPIConfig.getState().customQueryKey;
53
+ const customKey = apiConfig.customQueryKey;
53
54
  return getQueryClient().fetchQuery({
54
55
  queryKey: [init.name, args, options?.headers, options?.headers, customKey],
55
56
  queryFn: (args) => fetchGETQuery(init.name, args.queryKey[1] ? JSON.stringify(args.queryKey[1]) : "", {
@@ -60,20 +61,12 @@ export function createUseQuery(init) {
60
61
  };
61
62
  return hook;
62
63
  }
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
64
  function selectByPath(data, path) {
72
65
  return path.reduce((acc, key) => (acc ? acc[key] : null), data);
73
66
  }
74
67
  export function createUseInfiniteQuery(init) {
75
68
  const hook = (args, options) => {
76
- const customKey = useAPIConfig((state) => state.customQueryKey);
69
+ const customKey = apiConfig.customQueryKey;
77
70
  const [initial, setInitial] = useState(() => {
78
71
  if (options?.initialData) {
79
72
  const data = options?.initialData;
@@ -109,10 +102,12 @@ export function createUseInfiniteQuery(init) {
109
102
  const endCursor = selectByPath(data, init.paths.endCursorPath);
110
103
  const hasNextPage = selectByPath(data, init.paths.hasNextPagePath);
111
104
  const nodes = selectByPath(data, init.paths.nodesPath);
105
+ const total = selectByPath(data, [...init.paths.pageInfoPath, "total"]);
112
106
  return {
113
107
  nodes,
114
108
  hasNextPage,
115
109
  endCursor,
110
+ total,
116
111
  };
117
112
  },
118
113
  initialPageParam: "",
@@ -121,7 +116,10 @@ export function createUseInfiniteQuery(init) {
121
116
  return lastPage.hasNextPage ? lastPage.endCursor : undefined;
122
117
  },
123
118
  select(data) {
124
- return data.pages.flatMap((page) => page.nodes);
119
+ return {
120
+ nodes: data.pages.flatMap((page) => page.nodes),
121
+ total: data.pages[data.pages.length - 1]?.total,
122
+ };
125
123
  },
126
124
  ...options,
127
125
  ...initial,
@@ -142,7 +140,7 @@ const fetchMutation = async (name, params, opts) => {
142
140
  };
143
141
  if (env.serverless && env.client) {
144
142
  // Relative request (in browser)
145
- url = `/api/rest/mutation/${name}`;
143
+ url = `/_data/mutation/${name}`;
146
144
  }
147
145
  else if (env.serverless) {
148
146
  // Request to the origin server (server to server)
@@ -153,11 +151,12 @@ const fetchMutation = async (name, params, opts) => {
153
151
  url = `/wp-json/ed/v1/mutation/${name}`;
154
152
  }
155
153
  // Apply API configuration
156
- const apiConfig = useAPIConfig.getState();
157
154
  if (apiConfig.customQueryFetchOptions) {
158
155
  options = await apiConfig.customQueryFetchOptions?.("mutation", name, params, url, options);
159
156
  }
160
157
  const response = await fetch(url, options);
158
+ if (apiConfig.onResponse)
159
+ apiConfig.onResponse(response);
161
160
  const payload = await response.json();
162
161
  if (payload.errors?.length > 0) {
163
162
  throw createQueryError(payload.errors.map((e) => e.message), response.status);
@@ -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,4 +1,4 @@
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";
@@ -1,4 +1,4 @@
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";
@@ -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.
@@ -1,5 +1,5 @@
1
- import type { ConfigType } from "../../../../stitches-archive/config";
2
- import { DefaultThemeMap } from "../../../../stitches-archive";
1
+ import type { ConfigType } from "../../../../stitches-archive/config.js";
2
+ import { DefaultThemeMap } from "../../../../stitches-archive/index.js";
3
3
  import { Properties as CSS } from "csstype";
4
4
  type UtilValue<Theme extends ConfigType.Theme<any>, Scale extends string, CSSValue> = Scale extends keyof Theme ? `$${Exclude<keyof Theme[Scale], symbol>}` | CSSValue : CSSValue;
5
5
  type AtMedias<T extends any> = T extends string ? `@${T}` : never;
@@ -202,8 +202,8 @@ export declare function createStitches<Prefix extends string = "", Media extends
202
202
  }>(...styles: ({
203
203
  '@import'?: unknown;
204
204
  '@font-face'?: unknown;
205
- } & { [K in keyof Styles]: K extends "@import" ? string | string[] : K extends "@font-face" ? import("../../../../stitches-archive/css").AtRule.FontFace | import("../../../../stitches-archive/css").AtRule.FontFace[] : K extends `@keyframes ${string}` ? {
206
- [x: string]: import("../../../../stitches-archive/css-util").CSS<{
205
+ } & { [K in keyof Styles]: K extends "@import" ? string | string[] : K extends "@font-face" ? import("../../../../stitches-archive/css.js").AtRule.FontFace | import("../../../../stitches-archive/css.js").AtRule.FontFace[] : K extends `@keyframes ${string}` ? {
206
+ [x: string]: import("../../../../stitches-archive/css-util.js").CSS<{
207
207
  initial: "";
208
208
  } & Media, Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; }, ThemeMap, {
209
209
  typography: (key: keyof Typography) => { [key in keyof TypographyConfig<Theme, Media & {
@@ -261,7 +261,7 @@ export declare function createStitches<Prefix extends string = "", Media extends
261
261
  "--grid-columns": number;
262
262
  };
263
263
  }>;
264
- } : K extends `@property ${string}` ? import("../../../../stitches-archive/css").AtRule.Property : import("../../../../stitches-archive/css-util").CSS<{
264
+ } : K extends `@property ${string}` ? import("../../../../stitches-archive/css.js").AtRule.Property : import("../../../../stitches-archive/css-util.js").CSS<{
265
265
  initial: "";
266
266
  } & Media, Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; }, ThemeMap, {
267
267
  typography: (key: keyof Typography) => { [key in keyof TypographyConfig<Theme, Media & {
@@ -322,7 +322,7 @@ export declare function createStitches<Prefix extends string = "", Media extends
322
322
  (): string;
323
323
  };
324
324
  keyframes: (style: {
325
- [offset: string]: import("../../../../stitches-archive/css-util").CSS<{
325
+ [offset: string]: import("../../../../stitches-archive/css-util.js").CSS<{
326
326
  initial: "";
327
327
  } & Media, Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; }, ThemeMap, {
328
328
  typography: (key: keyof Typography) => { [key in keyof TypographyConfig<Theme, Media & {
@@ -397,20 +397,20 @@ export declare function createStitches<Prefix extends string = "", Media extends
397
397
  })>(nameOrScalesArg0: Argument0, nameOrScalesArg1?: Argument1 | undefined) => string & {
398
398
  className: string;
399
399
  selector: string;
400
- } & (Argument0 extends string ? import("../../../../stitches-archive/stitches").ThemeTokens<Argument1, ""> : import("../../../../stitches-archive/stitches").ThemeTokens<Argument0, "">);
400
+ } & (Argument0 extends string ? import("../../../../stitches-archive/stitches.js").ThemeTokens<Argument1, ""> : import("../../../../stitches-archive/stitches.js").ThemeTokens<Argument0, "">);
401
401
  theme: string & {
402
402
  className: string;
403
403
  selector: string;
404
- } & (Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; } extends infer T_2 extends {} ? { [Scale_2 in keyof T_2]: { [Token in keyof (Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; })[Scale_2]]: import("../../../../stitches-archive/theme").Token<Extract<Token, string | number>, string, Extract<Scale_2, string | void>, "">; }; } : never);
404
+ } & (Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; } extends infer T_2 extends {} ? { [Scale_2 in keyof T_2]: { [Token in keyof (Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; })[Scale_2]]: import("../../../../stitches-archive/theme.js").Token<Extract<Token, string | number>, string, Extract<Scale_2, string | void>, "">; }; } : never);
405
405
  reset: {
406
406
  (): void;
407
407
  };
408
408
  getCssText: {
409
409
  (): string;
410
410
  };
411
- css: <Composers extends (string | React.ExoticComponent<any> | React.JSXElementConstructor<any> | import("../../../../stitches-archive/util").Function | {
411
+ css: <Composers extends (string | React.ExoticComponent<any> | React.JSXElementConstructor<any> | import("../../../../stitches-archive/util.js").Function | {
412
412
  [name: string]: unknown;
413
- })[], CSS = import("../../../../stitches-archive/css-util").CSS<{
413
+ })[], CSS = import("../../../../stitches-archive/css-util.js").CSS<{
414
414
  initial: "";
415
415
  } & Media, Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; }, ThemeMap, {
416
416
  typography: (key: keyof Typography) => { [key in keyof TypographyConfig<Theme, Media & {
@@ -467,23 +467,23 @@ export declare function createStitches<Prefix extends string = "", Media extends
467
467
  gridColumn: string;
468
468
  "--grid-columns": number;
469
469
  };
470
- }>>(...composers: { [K in keyof Composers]: string extends Composers[K] ? Composers[K] : Composers[K] extends string | import("react").JSXElementConstructor<any> | import("react").ExoticComponent<any> | import("../../../../stitches-archive/util").Function ? Composers[K] : import("../../../../stitches-archive/stitches").RemoveIndex<CSS> & {
470
+ }>>(...composers: { [K in keyof Composers]: string extends Composers[K] ? Composers[K] : Composers[K] extends string | import("react").JSXElementConstructor<any> | import("react").ExoticComponent<any> | import("../../../../stitches-archive/util.js").Function ? Composers[K] : import("../../../../stitches-archive/stitches.js").RemoveIndex<CSS> & {
471
471
  variants?: {
472
472
  [x: string]: {
473
473
  [x: string]: CSS;
474
474
  [x: number]: CSS;
475
475
  };
476
476
  } | undefined;
477
- compoundVariants?: (("variants" extends keyof Composers[K] ? { [Name in keyof Composers[K][keyof Composers[K] & "variants"]]?: import("../../../../stitches-archive/util").String | import("../../../../stitches-archive/util").Widen<keyof Composers[K][keyof Composers[K] & "variants"][Name]> | undefined; } : import("../../../../stitches-archive/util").WideObject) & {
477
+ compoundVariants?: (("variants" extends keyof Composers[K] ? { [Name in keyof Composers[K][keyof Composers[K] & "variants"]]?: import("../../../../stitches-archive/util.js").String | import("../../../../stitches-archive/util.js").Widen<keyof Composers[K][keyof Composers[K] & "variants"][Name]> | undefined; } : import("../../../../stitches-archive/util.js").WideObject) & {
478
478
  css: CSS;
479
479
  })[] | undefined;
480
- defaultVariants?: ("variants" extends keyof Composers[K] ? { [Name_1 in keyof Composers[K][keyof Composers[K] & "variants"]]?: import("../../../../stitches-archive/util").String | import("../../../../stitches-archive/util").Widen<keyof Composers[K][keyof Composers[K] & "variants"][Name_1]> | undefined; } : import("../../../../stitches-archive/util").WideObject) | undefined;
481
- } & CSS & { [K2 in keyof Composers[K]]: K2 extends "variants" | "compoundVariants" | "defaultVariants" ? unknown : K2 extends keyof CSS ? CSS[K2] : unknown; }; }) => import("../../../../stitches-archive/styled-component").CssComponent<import("../../../../stitches-archive/styled-component").StyledComponentType<Composers>, import("../../../../stitches-archive/styled-component").StyledComponentProps<Composers>, {
480
+ defaultVariants?: ("variants" extends keyof Composers[K] ? { [Name_1 in keyof Composers[K][keyof Composers[K] & "variants"]]?: import("../../../../stitches-archive/util.js").String | import("../../../../stitches-archive/util.js").Widen<keyof Composers[K][keyof Composers[K] & "variants"][Name_1]> | undefined; } : import("../../../../stitches-archive/util.js").WideObject) | undefined;
481
+ } & CSS & { [K2 in keyof Composers[K]]: K2 extends "variants" | "compoundVariants" | "defaultVariants" ? unknown : K2 extends keyof CSS ? CSS[K2] : unknown; }; }) => import("../../../../stitches-archive/styled-component.js").CssComponent<import("../../../../stitches-archive/styled-component.js").StyledComponentType<Composers>, import("../../../../stitches-archive/styled-component.js").StyledComponentProps<Composers>, {
482
482
  initial: "";
483
483
  } & Media, CSS>;
484
- styled: <Type extends keyof JSX.IntrinsicElements | React.ComponentType<any> | import("../../../../stitches-archive/util").Function, Composers extends (string | React.ComponentType<any> | import("../../../../stitches-archive/util").Function | {
484
+ styled: <Type extends keyof JSX.IntrinsicElements | React.ComponentType<any> | import("../../../../stitches-archive/util.js").Function, Composers extends (string | React.ComponentType<any> | import("../../../../stitches-archive/util.js").Function | {
485
485
  [name: string]: unknown;
486
- })[], CSS = import("../../../../stitches-archive/css-util").CSS<{
486
+ })[], CSS = import("../../../../stitches-archive/css-util.js").CSS<{
487
487
  initial: "";
488
488
  } & Media, Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; }, ThemeMap, {
489
489
  typography: (key: keyof Typography) => { [key in keyof TypographyConfig<Theme, Media & {
@@ -540,20 +540,20 @@ export declare function createStitches<Prefix extends string = "", Media extends
540
540
  gridColumn: string;
541
541
  "--grid-columns": number;
542
542
  };
543
- }>>(type: Type, ...composers: { [K in keyof Composers]: string extends Composers[K] ? Composers[K] : Composers[K] extends string | import("react").ComponentType<any> | import("../../../../stitches-archive/util").Function ? Composers[K] : import("../../../../stitches-archive/stitches").RemoveIndex<CSS> & {
543
+ }>>(type: Type, ...composers: { [K in keyof Composers]: string extends Composers[K] ? Composers[K] : Composers[K] extends string | import("react").ComponentType<any> | import("../../../../stitches-archive/util.js").Function ? Composers[K] : import("../../../../stitches-archive/stitches.js").RemoveIndex<CSS> & {
544
544
  variants?: {
545
545
  [x: string]: {
546
546
  [x: string]: CSS;
547
547
  [x: number]: CSS;
548
548
  };
549
549
  } | undefined;
550
- compoundVariants?: (("variants" extends keyof Composers[K] ? { [Name in keyof Composers[K][keyof Composers[K] & "variants"]]?: import("../../../../stitches-archive/util").String | import("../../../../stitches-archive/util").Widen<keyof Composers[K][keyof Composers[K] & "variants"][Name]> | undefined; } : import("../../../../stitches-archive/util").WideObject) & {
550
+ compoundVariants?: (("variants" extends keyof Composers[K] ? { [Name in keyof Composers[K][keyof Composers[K] & "variants"]]?: import("../../../../stitches-archive/util.js").String | import("../../../../stitches-archive/util.js").Widen<keyof Composers[K][keyof Composers[K] & "variants"][Name]> | undefined; } : import("../../../../stitches-archive/util.js").WideObject) & {
551
551
  css: CSS;
552
552
  })[] | undefined;
553
- defaultVariants?: ("variants" extends keyof Composers[K] ? { [Name_1 in keyof Composers[K][keyof Composers[K] & "variants"]]?: import("../../../../stitches-archive/util").String | import("../../../../stitches-archive/util").Widen<keyof Composers[K][keyof Composers[K] & "variants"][Name_1]> | undefined; } : import("../../../../stitches-archive/util").WideObject) | undefined;
554
- } & CSS & { [K2 in keyof Composers[K]]: K2 extends "variants" | "compoundVariants" | "defaultVariants" ? unknown : K2 extends keyof CSS ? CSS[K2] : unknown; }; }) => import("../../../../stitches-archive/styled-component").StyledComponent<Type, import("../../../../stitches-archive/styled-component").StyledComponentProps<Composers>, {
553
+ defaultVariants?: ("variants" extends keyof Composers[K] ? { [Name_1 in keyof Composers[K][keyof Composers[K] & "variants"]]?: import("../../../../stitches-archive/util.js").String | import("../../../../stitches-archive/util.js").Widen<keyof Composers[K][keyof Composers[K] & "variants"][Name_1]> | undefined; } : import("../../../../stitches-archive/util.js").WideObject) | undefined;
554
+ } & CSS & { [K2 in keyof Composers[K]]: K2 extends "variants" | "compoundVariants" | "defaultVariants" ? unknown : K2 extends keyof CSS ? CSS[K2] : unknown; }; }) => import("../../../../stitches-archive/styled-component.js").StyledComponent<Type, import("../../../../stitches-archive/styled-component.js").StyledComponentProps<Composers>, {
555
555
  initial: "";
556
- } & Media, import("../../../../stitches-archive/css-util").CSS<{
556
+ } & Media, import("../../../../stitches-archive/css-util.js").CSS<{
557
557
  initial: "";
558
558
  } & Media, Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; }, ThemeMap, {
559
559
  typography: (key: keyof Typography) => { [key in keyof TypographyConfig<Theme, Media & {
@@ -1,4 +1,4 @@
1
- import { createStitches as createBaseStitches } from "../../../../stitches-archive";
1
+ import { createStitches as createBaseStitches, } from "../../../../stitches-archive/index.js";
2
2
  const typeKeyMap = {
3
3
  fontSize: "fontSizes",
4
4
  fontFamily: "fonts",
@@ -1 +1 @@
1
- export * from "./createStitches";
1
+ export * from "./createStitches.js";
@@ -1 +1 @@
1
- export * from "./createStitches";
1
+ export * from "./createStitches.js";
@@ -0,0 +1,49 @@
1
+ import { ReactNode } from "react";
2
+ import { RouteState } from "../types";
3
+ type BackButtonProps = {
4
+ /**
5
+ * An optional matching function, which will stop the render button from appearing unless the function returns true.
6
+ *
7
+ * The below example will only render a back button if the last route was a project archive.
8
+ *
9
+ * eg. `filter={(route) => route.view === 'archive-projects'}`
10
+ *
11
+ * @param route The last route in the history stack.
12
+ */
13
+ filter?: (route: RouteState) => boolean;
14
+ /**
15
+ * Whether to use the top-most "global" route, or the "context" route.
16
+ *
17
+ * The "global" route is the top-most route, reflected in the URL bar.
18
+ *
19
+ * The "context" route will be the route that is currently being rendered, which may be different to the global route when using modals/overlays/route stacks/transitions.
20
+ *
21
+ * @default "context"
22
+ */
23
+ mode?: "global" | "context";
24
+ /**
25
+ * An optional href, which will be used if no back route is found.
26
+ *
27
+ * When used, the back button will always render.
28
+ */
29
+ fallbackHref?: string;
30
+ /**
31
+ * A function to render the back button, if one should be rendered.
32
+ *
33
+ * Receives a `route` prop to further inspect the route, and an `onClick` function to navigate back.
34
+ *
35
+ * @param props
36
+ * @returns
37
+ */
38
+ render: (props: {
39
+ route: RouteState;
40
+ onClick: (e?: any) => void;
41
+ }) => ReactNode;
42
+ };
43
+ /**
44
+ * Display a back button that will navigate to the previous page in the router's history.
45
+ *
46
+ * This will allow you to render a back button on the condition that the back button will not send the user to a different website.
47
+ */
48
+ export declare function BackButton(props: BackButtonProps): ReactNode;
49
+ export {};
@@ -0,0 +1,47 @@
1
+ import { useMemo } from "react";
2
+ import { useRouter } from "../hooks/useRouter";
3
+ import { useRouterState } from "../hooks/useRouterState";
4
+ import { getLinkHandlerMode } from "../utils";
5
+ import { useRoute } from "../hooks/useRoute";
6
+ /**
7
+ * Display a back button that will navigate to the previous page in the router's history.
8
+ *
9
+ * This will allow you to render a back button on the condition that the back button will not send the user to a different website.
10
+ */
11
+ export function BackButton(props) {
12
+ const router = useRouter();
13
+ const prevRoute = useRouterState((state) => state.history[state.history.length - 2]);
14
+ const contextRoute = useRoute();
15
+ const activeRoute = useRouterState((state) => state.activeRoute);
16
+ const route = props.mode === "global" ? activeRoute : contextRoute;
17
+ const backAction = useMemo(() => {
18
+ if (prevRoute && (!props.filter || props.filter(prevRoute))) {
19
+ return (e) => {
20
+ const { mode } = getLinkHandlerMode(e, prevRoute.uri);
21
+ if (mode === "navigate") {
22
+ e.preventDefault();
23
+ history.back();
24
+ // history.length
25
+ }
26
+ else if (mode === "ignore") {
27
+ e.preventDefault();
28
+ }
29
+ };
30
+ }
31
+ else if (props.fallbackHref) {
32
+ return (e) => {
33
+ const { mode } = getLinkHandlerMode(e, props.fallbackHref);
34
+ if (mode === "navigate") {
35
+ e.preventDefault();
36
+ router.navigate(props.fallbackHref);
37
+ }
38
+ else if (mode === "ignore") {
39
+ e.preventDefault();
40
+ }
41
+ };
42
+ }
43
+ }, [route, props.filter, props.fallbackHref]);
44
+ if (backAction) {
45
+ return props.render ? props.render({ route: prevRoute, onClick: backAction }) : null;
46
+ }
47
+ }
@@ -1,4 +1,7 @@
1
1
  import { PropsWithChildren } from "react";
2
- type Props = PropsWithChildren<{}>;
2
+ import { type RouterAPI } from "../types.js";
3
+ type Props = PropsWithChildren<{
4
+ routerRef?: React.MutableRefObject<RouterAPI | null>;
5
+ }>;
3
6
  export declare function BrowserRouter(props: Props): import("react/jsx-runtime").JSX.Element;
4
7
  export {};