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.
- package/dist/app/entry/HydrationOverlay.d.ts +1 -0
- package/dist/app/entry/HydrationOverlay.js +2 -0
- package/dist/app/entry/MetaTags.d.ts +7 -0
- package/dist/app/entry/MetaTags.js +17 -0
- package/dist/app/entry/boot-admin.d.ts +1 -0
- package/dist/app/entry/boot-admin.js +13 -0
- package/dist/app/entry/hydration-script.d.ts +1 -0
- package/dist/app/entry/hydration-script.js +18 -0
- package/dist/app/entry/spa-root.d.ts +1 -0
- package/dist/app/entry/spa-root.js +8 -0
- package/dist/app/entry/ssr-root-client.d.ts +6 -0
- package/dist/app/entry/ssr-root-client.js +20 -0
- package/dist/app/entry/ssr-root.d.ts +8 -0
- package/dist/app/entry/ssr-root.js +22 -0
- package/dist/app/lib/admin/index.d.ts +2 -2
- package/dist/app/lib/admin/index.js +2 -2
- package/dist/app/lib/admin/installFieldTypes.js +1 -1
- package/dist/app/lib/admin/runWidgets.js +1 -1
- package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
- package/dist/app/lib/blocks/ContentBlocks.js +5 -5
- package/dist/app/lib/blocks/EditableText.d.ts +1 -1
- package/dist/app/lib/blocks/EditableText.js +3 -3
- package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
- package/dist/app/lib/blocks/InnerBlocks.js +13 -5
- package/dist/app/lib/blocks/block-utils.d.ts +2 -2
- package/dist/app/lib/blocks/block-utils.js +2 -2
- package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +7 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.js +130 -0
- package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
- package/dist/app/lib/blocks/editor/editor-config.d.ts +17 -4
- package/dist/app/lib/blocks/editor/editor-config.js +21 -9
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +20 -14
- package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
- package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
- package/dist/app/lib/blocks/index.d.ts +9 -9
- package/dist/app/lib/blocks/index.js +9 -9
- package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
- package/dist/app/lib/blocks/inline-editing.js +7 -5
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
- package/dist/app/lib/devtools/components/DevUI.js +4 -3
- package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
- package/dist/app/lib/devtools/components/GridIndicator.js +29 -0
- package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
- package/dist/app/lib/devtools/dev-tools-store.js +8 -0
- package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
- package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1102 -1103
- package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
- package/dist/app/lib/devtools/index.d.ts +1 -0
- package/dist/app/lib/devtools/index.js +1 -1
- package/dist/app/lib/devtools/loader.js +8 -7
- package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
- package/dist/app/lib/devtools/useQueryDebug.js +5 -8
- package/dist/app/lib/dynamic/dynamic.d.ts +1 -1
- package/dist/app/lib/dynamic/dynamic.js +5 -1
- package/dist/app/lib/dynamic/index.d.ts +1 -1
- package/dist/app/lib/dynamic/index.js +1 -1
- package/dist/app/lib/hooks/index.d.ts +4 -5
- package/dist/app/lib/hooks/index.js +4 -5
- package/dist/app/lib/hooks/queryUtils.d.ts +41 -4
- package/dist/app/lib/hooks/queryUtils.js +74 -37
- package/dist/app/lib/hooks/useAppData.js +1 -1
- package/dist/app/lib/hooks/useRPC.d.ts +0 -4
- package/dist/app/lib/hooks/useRPC.js +1 -8
- package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
- package/dist/app/lib/internal/finalize-rpc.js +3 -0
- package/dist/app/lib/internal/index.d.ts +5 -4
- package/dist/app/lib/internal/index.js +5 -4
- package/dist/app/lib/internal/internal-store.d.ts +0 -2
- package/dist/app/lib/internal/internal-store.js +1 -3
- package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
- package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
- package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/index.js +1 -1
- package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
- package/dist/app/lib/routing/components/BackButton.js +47 -0
- package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
- package/dist/app/lib/routing/components/BrowserRouter.js +95 -19
- package/dist/app/lib/routing/components/ClientOnly.js +1 -1
- package/dist/app/lib/routing/components/Link.d.ts +1 -0
- package/dist/app/lib/routing/components/Link.js +11 -12
- package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
- package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
- package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
- package/dist/app/lib/routing/components/SSRRouter.js +5 -6
- package/dist/app/lib/routing/components/ScrollRestoration.js +5 -2
- package/dist/app/lib/routing/context.d.ts +8 -5
- package/dist/app/lib/routing/context.js +13 -96
- package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
- package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
- package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
- package/dist/app/lib/routing/hooks/useRoute.js +22 -1
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
- package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
- package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouter.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
- package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
- package/dist/app/lib/routing/index.d.ts +14 -13
- package/dist/app/lib/routing/index.js +14 -13
- package/dist/app/lib/routing/loader.d.ts +2 -2
- package/dist/app/lib/routing/loader.js +26 -15
- package/dist/app/lib/routing/types.d.ts +36 -10
- package/dist/app/lib/routing/utils.d.ts +5 -2
- package/dist/app/lib/routing/utils.js +37 -4
- package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
- package/dist/app/lib/runtime/apiConfig.js +6 -0
- package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
- package/dist/app/lib/runtime/errorHandling.js +6 -0
- package/dist/app/lib/runtime/index.d.ts +2 -0
- package/dist/app/lib/runtime/index.js +2 -0
- package/dist/app/lib/views/index.d.ts +1 -1
- package/dist/app/lib/views/index.js +1 -1
- package/dist/app/server/defineRouter.d.ts +2 -0
- package/dist/app/server/defineRouter.js +4 -0
- package/dist/app/server/index.d.ts +5 -0
- package/dist/app/server/index.js +5 -0
- package/dist/app/server/proxy-wp-admin.d.ts +2 -0
- package/dist/app/server/proxy-wp-admin.js +124 -0
- package/dist/app/server/render-ssr-page.d.ts +21 -0
- package/dist/app/server/render-ssr-page.js +166 -0
- package/dist/app/server/rpc.d.ts +56 -0
- package/dist/app/server/rpc.js +18 -0
- package/dist/app/server/server-context.d.ts +72 -0
- package/dist/app/server/server-context.js +283 -0
- package/dist/app/server/utils/headers.d.ts +1 -0
- package/dist/app/server/utils/headers.js +17 -0
- package/dist/app/server/utils/replace-host.d.ts +6 -4
- package/dist/app/server/utils/replace-host.js +66 -11
- package/dist/app/server/utils/swr-cache.d.ts +4 -0
- package/dist/app/server/utils/swr-cache.js +31 -0
- package/dist/app/utils/APIProvider.d.ts +2 -0
- package/dist/app/utils/APIProvider.js +5 -0
- package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
- package/dist/app/utils/BlockErrorBoundary.js +38 -0
- package/dist/app/utils/ErrorMessage.d.ts +5 -0
- package/dist/app/utils/ErrorMessage.js +14 -0
- package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
- package/dist/app/utils/RouteErrorBoundary.js +38 -0
- package/dist/app/utils/asset-capture.d.ts +2 -0
- package/dist/app/utils/asset-capture.js +5 -0
- package/dist/app/utils/hydration-debugger.d.ts +13 -0
- package/dist/app/utils/hydration-debugger.js +11 -0
- package/dist/app/utils/query-client.d.ts +2 -0
- package/dist/app/utils/query-client.js +5 -1
- package/dist/app/utils/trpc-client.d.ts +2 -0
- package/dist/app/utils/trpc-client.js +39 -0
- package/dist/node/cli/cli-worker.d.ts +1 -1
- package/dist/node/cli/cli-worker.js +11 -3
- package/dist/node/cli/cli.js +112 -13
- package/dist/node/cli/display/CLIApp.d.ts +1 -1
- package/dist/node/cli/display/CLIApp.js +4 -7
- package/dist/node/cli/display/boot-cli-app.js +1 -1
- package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
- package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
- package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
- package/dist/node/cli/display/tools/cli-tools.js +9 -9
- package/dist/node/cli/display/util/colors.d.ts +2 -2
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/build-vinxi.d.ts +8 -0
- package/dist/node/compiler/build-vinxi.js +38 -0
- package/dist/node/compiler/bundler.admin.d.ts +2 -2
- package/dist/node/compiler/bundler.admin.js +4 -4
- package/dist/node/compiler/bundler.frontend.d.ts +1 -1
- package/dist/node/compiler/bundler.frontend.js +4 -4
- package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
- package/dist/node/compiler/dev-server.js +107 -0
- package/dist/node/compiler/get-vite-config.d.ts +20 -0
- package/dist/node/compiler/get-vite-config.js +207 -0
- package/dist/node/compiler/vinxi-app.d.ts +22 -0
- package/dist/node/compiler/vinxi-app.js +228 -0
- package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
- package/dist/node/compiler/vinxi-codegen.js +638 -0
- package/dist/node/graphql/graphql-codegen.d.ts +12 -2
- package/dist/node/graphql/graphql-codegen.js +213 -36
- package/dist/node/graphql/graphql-schema-loader.d.ts +2 -1
- package/dist/node/graphql/graphql-schema-loader.js +5 -19
- package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
- package/dist/node/graphql/query-files-loader.d.ts +3 -0
- package/dist/node/graphql/query-files-loader.js +5 -0
- package/dist/node/project/config.d.ts +159 -73
- package/dist/node/project/config.js +70 -21
- package/dist/node/project/env.d.ts +5 -1
- package/dist/node/project/env.js +2 -1
- package/dist/node/project/manifest/block-manifest.js +3 -2
- package/dist/node/project/manifest/manifest.d.ts +2 -1
- package/dist/node/project/manifest/manifest.js +15 -11
- package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
- package/dist/node/project/manifest/routes-manifest.js +74 -0
- package/dist/node/project/manifest/view-manifest.js +2 -2
- package/dist/node/project/project.d.ts +11 -2
- package/dist/node/project/project.js +49 -20
- package/dist/node/project/wp-info.d.ts +1 -0
- package/dist/node/project/wp-info.js +13 -3
- package/dist/node/types/block-type.d.ts +25 -20
- package/dist/node/types/block-type.js +1 -0
- package/dist/node/types/view-type.d.ts +7 -7
- package/dist/node/types/view-type.js +3 -4
- package/dist/node/utils/fetch-wp.d.ts +1 -0
- package/dist/node/utils/fetch-wp.js +27 -0
- package/dist/node/utils/fs-codegen.d.ts +42 -0
- package/dist/node/utils/fs-codegen.js +98 -0
- package/dist/node/utils/fs.js +2 -0
- package/dist/node/utils/{isDeploying.js → is-deploying.js} +1 -1
- package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
- package/dist/node/utils/{statefulLog.js → stateful-log.js} +3 -1
- package/dist/node/utils/watch-file-tree.d.ts +25 -0
- package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +12 -5
- package/package.json +40 -38
- package/types.app.d.ts +4 -2
- package/types.app.internal.d.ts +2 -2
- package/types.node.d.ts +3 -3
- package/dist/app/entry/Root.d.ts +0 -1
- package/dist/app/entry/Root.js +0 -9
- package/dist/app/entry/main.admin.d.ts +0 -3
- package/dist/app/entry/main.admin.js +0 -10
- package/dist/app/entry/main.frontend.spa.d.ts +0 -3
- package/dist/app/entry/main.frontend.spa.js +0 -13
- package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
- package/dist/app/entry/main.frontend.ssr.js +0 -79
- package/dist/app/entry/main.serverless.dev.d.ts +0 -4
- package/dist/app/entry/main.serverless.dev.js +0 -21
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
- package/dist/app/lib/hooks/apiConfig.js +0 -4
- package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
- package/dist/app/lib/hooks/usePageLoad.js +0 -5
- package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
- package/dist/app/server/create-api-builtin-hono.js +0 -80
- package/dist/app/server/create-ssr-hono.d.ts +0 -18
- package/dist/app/server/create-ssr-hono.js +0 -104
- package/dist/app/server/utils/index.html.d.ts +0 -2
- package/dist/app/server/utils/index.html.js +0 -14
- package/dist/node/compiler/index.html.d.ts +0 -2
- package/dist/node/compiler/index.html.js +0 -15
- package/dist/node/compiler/serverless.dev.js +0 -215
- package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
- package/dist/node/compiler/vite/get-vite-config.js +0 -315
- package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-admin.js +0 -67
- package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-blocks.js +0 -73
- package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
- package/dist/node/compiler/vite/plugin-entry.js +0 -16
- package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
- package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-theme.js +0 -40
- package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-views.js +0 -51
- package/dist/node/utils/console.d.ts +0 -21
- package/dist/node/utils/console.js +0 -28
- package/dist/node/utils/unsafe-fetch.d.ts +0 -2
- package/dist/node/utils/unsafe-fetch.js +0 -19
- package/dist/node/utils/watchFileTree.d.ts +0 -11
- package/tsup.config.ts +0 -40
- package/types.manifests.d.ts +0 -22
- /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
- /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
- /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
- /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
- /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
- /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
- /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
- /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
- /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
|
-
import { RouteLoader } from "./loader";
|
|
2
|
+
import { RouteLoader } from "./loader.js";
|
|
3
|
+
import { proxy } from "valtio";
|
|
3
4
|
const NOOP_ROUTE = {
|
|
4
5
|
component: () => null,
|
|
5
6
|
id: "initial",
|
|
@@ -12,6 +13,7 @@ const NOOP_ROUTE = {
|
|
|
12
13
|
search: "",
|
|
13
14
|
query: {},
|
|
14
15
|
returnState: undefined,
|
|
16
|
+
meta: {},
|
|
15
17
|
};
|
|
16
18
|
export const RouterContext = createContext({
|
|
17
19
|
loader: new RouteLoader(),
|
|
@@ -25,6 +27,10 @@ export const RouterContext = createContext({
|
|
|
25
27
|
replaceQuery(query) { },
|
|
26
28
|
handleClickEvent(e, originalHref) { },
|
|
27
29
|
emitEvent(event) { },
|
|
30
|
+
getState() {
|
|
31
|
+
return null;
|
|
32
|
+
},
|
|
33
|
+
restoreRoute(route) { },
|
|
28
34
|
});
|
|
29
35
|
export const RouterStateContext = createContext({
|
|
30
36
|
history: [NOOP_ROUTE],
|
|
@@ -32,98 +38,9 @@ export const RouterStateContext = createContext({
|
|
|
32
38
|
blockers: [],
|
|
33
39
|
});
|
|
34
40
|
export const RouteItemContext = createContext(NOOP_ROUTE);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// value: T
|
|
42
|
-
// update(next: T): void
|
|
43
|
-
// }
|
|
44
|
-
// function createStore<T>(initial: T): Store<T> {
|
|
45
|
-
// let value = initial
|
|
46
|
-
// const subscribers = new Set<(value: T) => void>()
|
|
47
|
-
// return {
|
|
48
|
-
// subscribe(sub: (value: T) => void) {
|
|
49
|
-
// subscribers.add(sub)
|
|
50
|
-
// return () => {
|
|
51
|
-
// subscribers.delete(sub)
|
|
52
|
-
// }
|
|
53
|
-
// },
|
|
54
|
-
// get value() {
|
|
55
|
-
// return value
|
|
56
|
-
// },
|
|
57
|
-
// update(nextValue: T) {
|
|
58
|
-
// value = nextValue
|
|
59
|
-
// if (subscribers.size) {
|
|
60
|
-
// console.log("UPDATE", value)
|
|
61
|
-
// startTransition(() => {
|
|
62
|
-
// for (let sub of subscribers) {
|
|
63
|
-
// sub(value)
|
|
64
|
-
// }
|
|
65
|
-
// })
|
|
66
|
-
// }
|
|
67
|
-
// },
|
|
68
|
-
// }
|
|
69
|
-
// }
|
|
70
|
-
// export function createStoreHook<T>(store: Store<T>): StoreHook<T> {
|
|
71
|
-
// const hook = (selector: any) => {
|
|
72
|
-
// const get = () => (selector ? selector(store.value) : store.value)
|
|
73
|
-
// return useSyncExternalStore(store.subscribe, get, get)
|
|
74
|
-
// }
|
|
75
|
-
// return hook as StoreHook<T>
|
|
76
|
-
// }
|
|
77
|
-
// export function createStoreContextHook<T>(ctx: Context<Store<T>>): StoreHook<T> {
|
|
78
|
-
// const hook = (selector: any) => {
|
|
79
|
-
// const store = useContext(ctx)
|
|
80
|
-
// const get = () => (selector ? selector(store.value) : store.value)
|
|
81
|
-
// return useSyncExternalStore(store.subscribe, get, get)
|
|
82
|
-
// }
|
|
83
|
-
// return hook as StoreHook<T>
|
|
84
|
-
// }
|
|
85
|
-
// export const RouterContext = createContext<Store<RouterAPI>>(null!)
|
|
86
|
-
// export const RouterStateContext = createContext<Store<RouterAPIState>>(null!)
|
|
87
|
-
// export const RouteContext = createContext<Store<RouteState>>(null!)
|
|
88
|
-
// const NOOP_ROUTE: RouteState = {
|
|
89
|
-
// component: () => null,
|
|
90
|
-
// id: "initial",
|
|
91
|
-
// hash: "",
|
|
92
|
-
// key: "initial",
|
|
93
|
-
// pathname: "",
|
|
94
|
-
// props: {},
|
|
95
|
-
// uri: "",
|
|
96
|
-
// view: "_unknown",
|
|
97
|
-
// search: "",
|
|
98
|
-
// query: {},
|
|
99
|
-
// returnState: undefined,
|
|
100
|
-
// }
|
|
101
|
-
// export const createRouteItemStore = (initial?: RouteState) => {
|
|
102
|
-
// return createStore<RouteState>(initial ?? NOOP_ROUTE)
|
|
103
|
-
// }
|
|
104
|
-
// export function createRouterAPIStore(initial?: RouterAPI) {
|
|
105
|
-
// return createStore<RouterAPI>(
|
|
106
|
-
// initial ?? {
|
|
107
|
-
// loader: new RouteLoader(),
|
|
108
|
-
// async navigate(url) {},
|
|
109
|
-
// async prefetch(url) {},
|
|
110
|
-
// async preload(url) {},
|
|
111
|
-
// subscribe(fn) {
|
|
112
|
-
// return () => {}
|
|
113
|
-
// },
|
|
114
|
-
// replaceHash(hash) {},
|
|
115
|
-
// replaceQuery(query) {},
|
|
116
|
-
// handleClickEvent(e, originalHref) {},
|
|
117
|
-
// emitEvent(event) {},
|
|
118
|
-
// },
|
|
119
|
-
// )
|
|
120
|
-
// }
|
|
121
|
-
// export function createRouterStateStore(initial?: RouterAPIState) {
|
|
122
|
-
// return createStore<RouterAPIState>(
|
|
123
|
-
// initial ?? {
|
|
124
|
-
// history: [],
|
|
125
|
-
// activeRoute: NOOP_ROUTE,
|
|
126
|
-
// blockers: [],
|
|
127
|
-
// },
|
|
128
|
-
// )
|
|
129
|
-
// }
|
|
41
|
+
export const clientMetaTags = proxy({
|
|
42
|
+
tags: null,
|
|
43
|
+
setMetaTags(tags) {
|
|
44
|
+
clientMetaTags.tags = tags;
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Dispatch } from "react";
|
|
1
2
|
/**
|
|
2
3
|
* Works exactly like useState, but allows back and forward navigation to restore the previous state.
|
|
3
4
|
* You must pass a unique ID as an additional first parameter to ensure the state is restored correctly.
|
|
4
5
|
*/
|
|
5
|
-
export declare function useRestorableState<T>(key: string, fallback
|
|
6
|
+
export declare function useRestorableState<T>(key: string, fallback: T): [T, Dispatch<T>];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useRouterEvents } from "./useRouterEvents.js";
|
|
3
|
+
import { useRoute } from "./useRoute.js";
|
|
3
4
|
/**
|
|
4
5
|
* Works exactly like useState, but allows back and forward navigation to restore the previous state.
|
|
5
6
|
* You must pass a unique ID as an additional first parameter to ensure the state is restored correctly.
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import { RouteState } from "../types";
|
|
1
|
+
import type { RouteState } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the current route object.
|
|
4
|
+
*
|
|
5
|
+
* In most circumstances, this will be the active top-level route.
|
|
6
|
+
*
|
|
7
|
+
* In cases where manual rendering of routes is taking place, such as during page transitions or in some modal cases.
|
|
8
|
+
*
|
|
9
|
+
* @returns The current route
|
|
10
|
+
*/
|
|
2
11
|
export declare function useRoute(): RouteState;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the current route, if it matches the specified view, otherwise null.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useViewRoute<V extends keyof ViewProps>(view: V): Extract<RouteState, {
|
|
16
|
+
view: V;
|
|
17
|
+
}> | null;
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import { RouteItemContext } from "../context";
|
|
2
|
+
import { RouteItemContext } from "../context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the current route object.
|
|
5
|
+
*
|
|
6
|
+
* In most circumstances, this will be the active top-level route.
|
|
7
|
+
*
|
|
8
|
+
* In cases where manual rendering of routes is taking place, such as during page transitions or in some modal cases.
|
|
9
|
+
*
|
|
10
|
+
* @returns The current route
|
|
11
|
+
*/
|
|
3
12
|
export function useRoute() {
|
|
4
13
|
return useContext(RouteItemContext);
|
|
5
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current route, if it matches the specified view, otherwise null.
|
|
17
|
+
*/
|
|
18
|
+
export function useViewRoute(view) {
|
|
19
|
+
const route = useContext(RouteItemContext);
|
|
20
|
+
if (route.view === view) {
|
|
21
|
+
return route;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RouteState } from "../types";
|
|
1
|
+
import type { RouteState } from "../types.js";
|
|
2
2
|
type TransitionFunction = (currentRoute: RouteState, nextRoute: RouteState) => void | Promise<any | void>;
|
|
3
3
|
export declare function useRouteTransition(func: TransitionFunction): void;
|
|
4
4
|
export {};
|
|
@@ -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,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,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,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 "./
|
|
7
|
-
export * from "./hooks/
|
|
8
|
-
export * from "./hooks/
|
|
9
|
-
export * from "./hooks/
|
|
10
|
-
export * from "./hooks/
|
|
11
|
-
export * from "./hooks/
|
|
12
|
-
export * from "./hooks/
|
|
13
|
-
export * from "./hooks/
|
|
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 "./
|
|
7
|
-
export * from "./hooks/
|
|
8
|
-
export * from "./hooks/
|
|
9
|
-
export * from "./hooks/
|
|
10
|
-
export * from "./hooks/
|
|
11
|
-
export * from "./hooks/
|
|
12
|
-
export * from "./hooks/
|
|
13
|
-
export * from "./hooks/
|
|
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 (
|
|
35
|
-
|
|
36
|
-
query
|
|
37
|
-
query["
|
|
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";
|
|
@@ -54,6 +56,7 @@ export class RouteLoader {
|
|
|
54
56
|
return this.entries.has(cacheKey);
|
|
55
57
|
}
|
|
56
58
|
async loadRouteData(pathname, withAppData = false) {
|
|
59
|
+
pathname = withTrailingSlash(pathname);
|
|
57
60
|
const cacheKey = this.getKey(pathname);
|
|
58
61
|
// Cached value?
|
|
59
62
|
if (this.entries.has(cacheKey))
|
|
@@ -63,27 +66,35 @@ export class RouteLoader {
|
|
|
63
66
|
serverless: env.serverless,
|
|
64
67
|
debug: env.dev,
|
|
65
68
|
});
|
|
66
|
-
const promise = this.fetchImpl(requestUrl
|
|
67
|
-
.then((response) =>
|
|
68
|
-
.
|
|
69
|
+
const promise = this.fetchImpl(requestUrl)
|
|
70
|
+
.then(async (response) => {
|
|
71
|
+
if (response.redirected) {
|
|
72
|
+
return { redirect: response.url };
|
|
73
|
+
}
|
|
74
|
+
let text = await response.text();
|
|
69
75
|
if (this.processProps) {
|
|
70
76
|
text = this.processProps(text);
|
|
71
77
|
}
|
|
72
78
|
try {
|
|
73
|
-
|
|
79
|
+
const payload = JSON.parse(text);
|
|
80
|
+
if (!payload.view) {
|
|
81
|
+
throw new RouteError(`Invalid route data for '${pathname}'`, 500);
|
|
82
|
+
}
|
|
83
|
+
return payload;
|
|
74
84
|
}
|
|
75
85
|
catch (err) {
|
|
76
86
|
throw new RouteError(`JSON parse error for route '${pathname}':\n${err?.message}`, 500);
|
|
77
87
|
}
|
|
78
88
|
})
|
|
79
|
-
.then((data) => {
|
|
89
|
+
.then(async (data) => {
|
|
80
90
|
if (data.redirect) {
|
|
81
|
-
const redirect = data.redirect;
|
|
82
|
-
data = this.loadRouteData(redirect)
|
|
83
|
-
|
|
84
|
-
return data;
|
|
85
|
-
});
|
|
91
|
+
const redirect = parseURL(data.redirect).pathname;
|
|
92
|
+
data = await this.loadRouteData(redirect);
|
|
93
|
+
data.canonical = redirect;
|
|
86
94
|
}
|
|
95
|
+
return data;
|
|
96
|
+
})
|
|
97
|
+
.then((data) => {
|
|
87
98
|
this.entries.set(cacheKey, new Promise((resolve) => resolve(data)));
|
|
88
99
|
return data;
|
|
89
100
|
});
|
|
@@ -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
|
|
5
|
-
|
|
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?: string;
|
|
11
|
+
body?: string;
|
|
12
|
+
footer?: string;
|
|
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:
|
|
17
|
-
footer:
|
|
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;
|
|
@@ -73,7 +83,7 @@ export type RouterEvent = {
|
|
|
73
83
|
data: RouteData;
|
|
74
84
|
} | {
|
|
75
85
|
type: "error";
|
|
76
|
-
critical:
|
|
86
|
+
critical: boolean;
|
|
77
87
|
error: Error;
|
|
78
88
|
};
|
|
79
89
|
export type RouterSubscriber = (event: RouterEvent) => void;
|
|
@@ -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
|
-
/**
|
|
103
|
-
|
|
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,15 +1,18 @@
|
|
|
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";
|
|
7
8
|
href?: string;
|
|
8
9
|
};
|
|
9
|
-
export declare function getLinkHandlerMode(e?: PointerOrMouseEvent, href?: string): LinkHandlerMode;
|
|
10
|
+
export declare function getLinkHandlerMode(e?: PointerOrMouseEvent, href?: string, currentRoute?: RouteState): LinkHandlerMode;
|
|
10
11
|
type Partialize<T, TKeys extends keyof T> = Partial<Pick<T, TKeys>> & Omit<T, TKeys>;
|
|
11
12
|
export declare function normalizeRoute(route: Partialize<RouteState, "uri" | "returnState" | "key">): RouteState;
|
|
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;
|
|
17
|
+
export declare function addTrailingSlash(path?: string | null): string;
|
|
15
18
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { parse as qsParse, stringify as qsStringify } from "qs";
|
|
2
|
+
import { parseURL, resolveURL, stringifyParsedURL, withoutTrailingSlash, withTrailingSlash } from "ufo";
|
|
3
3
|
export function isSameOrigin(url) {
|
|
4
4
|
if (typeof document === "undefined") {
|
|
5
5
|
return url.startsWith("/");
|
|
@@ -10,7 +10,12 @@ export function isSameOrigin(url) {
|
|
|
10
10
|
return parsed.protocol === document.location.protocol && parsed.host === document.location.host;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
export function
|
|
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
|
+
}
|
|
18
|
+
export function getLinkHandlerMode(e, href, currentRoute) {
|
|
14
19
|
try {
|
|
15
20
|
// Attempt to get the link element, if there is one
|
|
16
21
|
let eventTarget = null;
|
|
@@ -31,7 +36,11 @@ export function getLinkHandlerMode(e, href) {
|
|
|
31
36
|
if (!href)
|
|
32
37
|
return { mode: "native", href };
|
|
33
38
|
// Resolve the URL and check if it's the same origin
|
|
34
|
-
const resolved = href.startsWith("http")
|
|
39
|
+
const resolved = href.startsWith("http")
|
|
40
|
+
? href
|
|
41
|
+
: href.startsWith("/")
|
|
42
|
+
? resolveURL(document.location.origin, href)
|
|
43
|
+
: resolveURL(document.location.href, href);
|
|
35
44
|
const parsed = parseURL(resolved);
|
|
36
45
|
const isSameOrigin = parsed.host?.replace(/:.+/, "") === document.location.host.replace(/:.+/, "");
|
|
37
46
|
// External links should be handled natively
|
|
@@ -52,6 +61,17 @@ export function getLinkHandlerMode(e, href) {
|
|
|
52
61
|
// Starts with /wp-, use native (wp-content, wp-admin etc)
|
|
53
62
|
if (parsed.pathname.startsWith("/wp-"))
|
|
54
63
|
return { mode: "native", href };
|
|
64
|
+
// If pathname+query are identical, but the hash is different, then allow the browser to handle it
|
|
65
|
+
if (currentRoute &&
|
|
66
|
+
isSamePathname(currentRoute.pathname, parsed.pathname) &&
|
|
67
|
+
currentRoute.search === parsed.search) {
|
|
68
|
+
if (currentRoute.hash !== parsed.hash) {
|
|
69
|
+
return { mode: "native", href };
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return { mode: "ignore", href };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
55
75
|
return { mode: "navigate", href };
|
|
56
76
|
}
|
|
57
77
|
catch (err) {
|
|
@@ -76,6 +96,7 @@ export function normalizeRoute(route) {
|
|
|
76
96
|
export function stringifyRouteLink(route) {
|
|
77
97
|
return stringifyParsedURL({
|
|
78
98
|
...route,
|
|
99
|
+
pathname: withTrailingSlash(route.pathname),
|
|
79
100
|
search: stringifyQuery(route.query),
|
|
80
101
|
});
|
|
81
102
|
}
|
|
@@ -92,3 +113,15 @@ export function stringifyQuery(query) {
|
|
|
92
113
|
arrayFormat: "brackets",
|
|
93
114
|
});
|
|
94
115
|
}
|
|
116
|
+
export function getRouteMeta(data) {
|
|
117
|
+
return {
|
|
118
|
+
title: data.meta?.head.find((tag) => tag.tagName === "title")?.inner,
|
|
119
|
+
tags: data.meta?.head ?? [],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export function addTrailingSlash(path) {
|
|
123
|
+
if (path?.match(/\./)) {
|
|
124
|
+
return path;
|
|
125
|
+
}
|
|
126
|
+
return withTrailingSlash(path ?? undefined, true);
|
|
127
|
+
}
|
|
@@ -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
|
-
*
|
|
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
|
|
22
|
+
export declare const apiConfig: APIConfigStore;
|