houdini-react 1.2.8 → 1.2.10
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/build/plugin/codegen/entries.d.ts +1 -2
- package/build/plugin/codegen/index.d.ts +1 -2
- package/build/plugin/codegen/manifest.d.ts +4 -41
- package/build/plugin/codegen/router.d.ts +1 -2
- package/build/plugin/codegen/typeRoot.d.ts +1 -2
- package/build/plugin/index.d.ts +3 -1
- package/build/plugin/vite.d.ts +38 -1
- package/build/plugin-cjs/index.js +60265 -61245
- package/build/plugin-esm/index.js +60262 -61244
- package/build/runtime/index.d.ts +6 -3
- package/build/runtime/routing/components/Router.d.ts +4 -4
- package/build/runtime/routing/components/index.d.ts +0 -1
- package/build/runtime/routing/lib/cache.d.ts +1 -1
- package/build/runtime/routing/lib/types.d.ts +0 -4
- package/build/runtime/server/compat.d.ts +7 -0
- package/build/runtime/server/index.d.ts +17 -0
- package/build/runtime/server/session.d.ts +3 -0
- package/build/runtime-cjs/index.d.ts +6 -3
- package/build/runtime-cjs/index.js +22 -18
- package/build/runtime-cjs/routing/components/Router.d.ts +4 -4
- package/build/runtime-cjs/routing/components/Router.js +69 -39
- package/build/runtime-cjs/routing/components/index.d.ts +0 -1
- package/build/runtime-cjs/routing/components/index.js +0 -3
- package/build/runtime-cjs/routing/lib/cache.d.ts +1 -1
- package/build/runtime-cjs/routing/lib/cache.js +6 -2
- package/build/runtime-cjs/routing/lib/types.d.ts +0 -4
- package/build/runtime-cjs/server/compat.js +52 -0
- package/build/runtime-cjs/server/index.js +54 -0
- package/build/runtime-cjs/{routing/components/Link.js → server/session.js} +32 -22
- package/build/runtime-esm/index.d.ts +6 -3
- package/build/runtime-esm/index.js +22 -18
- package/build/runtime-esm/routing/components/Router.d.ts +4 -4
- package/build/runtime-esm/routing/components/Router.js +69 -38
- package/build/runtime-esm/routing/components/index.d.ts +0 -1
- package/build/runtime-esm/routing/components/index.js +0 -2
- package/build/runtime-esm/routing/lib/cache.d.ts +1 -1
- package/build/runtime-esm/routing/lib/cache.js +6 -2
- package/build/runtime-esm/routing/lib/types.d.ts +0 -4
- package/build/runtime-esm/server/compat.d.ts +7 -0
- package/build/runtime-esm/server/compat.js +28 -0
- package/build/runtime-esm/server/index.d.ts +17 -0
- package/build/runtime-esm/server/index.js +30 -0
- package/build/runtime-esm/server/session.d.ts +3 -0
- package/build/runtime-esm/server/session.js +30 -0
- package/package.json +3 -12
- package/build/plugin/conventions.d.ts +0 -24
- package/build/runtime/routing/components/Link.d.ts +0 -5
- package/build/runtime-cjs/routing/components/Link.d.ts +0 -5
- package/build/runtime-esm/routing/components/Link.d.ts +0 -5
- package/build/runtime-esm/routing/components/Link.js +0 -21
- package/build/server-cjs/index.js +0 -166712
- package/build/server-cjs/package.json +0 -1
- package/build/server-esm/index.js +0 -166703
- package/build/server-esm/package.json +0 -1
- /package/build/{server → runtime-cjs/server}/compat.d.ts +0 -0
- /package/build/{server → runtime-cjs/server}/index.d.ts +0 -0
- /package/build/{server → runtime-cjs/server}/session.d.ts +0 -0
package/build/runtime/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ import { PendingCache } from './routing/components/Router';
|
|
|
7
7
|
import { SuspenseCache } from './routing/lib/cache';
|
|
8
8
|
export * from './hooks';
|
|
9
9
|
export * from './routing';
|
|
10
|
-
export declare function Router({ cache,
|
|
11
|
-
|
|
10
|
+
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, loaded_queries, loaded_artifacts, session, assetPrefix, }: {
|
|
11
|
+
initialURL: string;
|
|
12
12
|
cache: Cache;
|
|
13
13
|
loaded_queries?: Record<string, {
|
|
14
14
|
data: GraphQLObject;
|
|
@@ -16,6 +16,7 @@ export declare function Router({ cache, intialURL, artifact_cache, component_cac
|
|
|
16
16
|
}>;
|
|
17
17
|
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
18
18
|
session?: App.Session;
|
|
19
|
+
assetPrefix: string;
|
|
19
20
|
} & RouterCache): JSX.Element;
|
|
20
21
|
type RouterCache = {
|
|
21
22
|
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
@@ -24,8 +25,10 @@ type RouterCache = {
|
|
|
24
25
|
last_variables: LRUCache<GraphQLVariables>;
|
|
25
26
|
pending_cache: PendingCache;
|
|
26
27
|
};
|
|
27
|
-
export declare function router_cache({ pending_queries, artifacts, components, }?: {
|
|
28
|
+
export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
|
|
28
29
|
pending_queries?: string[];
|
|
29
30
|
artifacts?: Record<string, QueryArtifact>;
|
|
30
31
|
components?: Record<string, (props: any) => React.ReactElement>;
|
|
32
|
+
initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
33
|
+
initialArtifacts?: Record<string, QueryArtifact>;
|
|
31
34
|
}): RouterCache;
|
|
@@ -5,22 +5,22 @@ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
|
5
5
|
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { SuspenseCache } from '../lib/cache';
|
|
8
|
-
import type {
|
|
8
|
+
import type { RouterManifest } from '../lib/types';
|
|
9
9
|
/**
|
|
10
10
|
* Router is the top level entry point for the filesystem-based router.
|
|
11
11
|
* It is responsible for loading various page sources (including API fetches) and
|
|
12
12
|
* then rendering when appropriate.
|
|
13
13
|
*/
|
|
14
|
-
export declare function Router({ manifest,
|
|
14
|
+
export declare function Router({ manifest, initialURL, loaded_queries, loaded_artifacts, assetPrefix, }: {
|
|
15
15
|
manifest: RouterManifest;
|
|
16
|
-
|
|
16
|
+
initialURL?: string;
|
|
17
17
|
loaded_queries?: Record<string, {
|
|
18
18
|
data: GraphQLObject;
|
|
19
19
|
variables: GraphQLVariables;
|
|
20
20
|
}>;
|
|
21
21
|
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
22
|
+
assetPrefix: string;
|
|
22
23
|
}): JSX.Element;
|
|
23
|
-
export declare function useNavigationContext(): NavigationContext;
|
|
24
24
|
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
|
|
25
25
|
children: React.ReactElement;
|
|
26
26
|
client: HoudiniClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
2
|
-
export declare function suspense_cache<T>(): SuspenseCache<T>;
|
|
2
|
+
export declare function suspense_cache<T>(initialData?: Record<string, T>): SuspenseCache<T>;
|
|
3
3
|
export declare class SuspenseCache<_Data> extends LRUCache<_Data> {
|
|
4
4
|
#private;
|
|
5
5
|
get(key: string): _Data;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Config } from 'houdini';
|
|
2
|
+
export declare function configure_server({ server, config }: {
|
|
3
|
+
server: Server;
|
|
4
|
+
config: Config;
|
|
5
|
+
}): void;
|
|
6
|
+
export type Server = {
|
|
7
|
+
use(fn: ServerMiddleware): void;
|
|
8
|
+
};
|
|
9
|
+
export type ServerMiddleware = (req: IncomingRequest, res: ServerResponse, next: () => void) => void;
|
|
10
|
+
export type IncomingRequest = {
|
|
11
|
+
url?: string;
|
|
12
|
+
headers: Headers;
|
|
13
|
+
};
|
|
14
|
+
export type ServerResponse = {
|
|
15
|
+
redirect(url: string, status?: number): void;
|
|
16
|
+
set_header(name: string, value: string): void;
|
|
17
|
+
};
|
|
@@ -7,8 +7,8 @@ import { PendingCache } from './routing/components/Router';
|
|
|
7
7
|
import { SuspenseCache } from './routing/lib/cache';
|
|
8
8
|
export * from './hooks';
|
|
9
9
|
export * from './routing';
|
|
10
|
-
export declare function Router({ cache,
|
|
11
|
-
|
|
10
|
+
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, loaded_queries, loaded_artifacts, session, assetPrefix, }: {
|
|
11
|
+
initialURL: string;
|
|
12
12
|
cache: Cache;
|
|
13
13
|
loaded_queries?: Record<string, {
|
|
14
14
|
data: GraphQLObject;
|
|
@@ -16,6 +16,7 @@ export declare function Router({ cache, intialURL, artifact_cache, component_cac
|
|
|
16
16
|
}>;
|
|
17
17
|
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
18
18
|
session?: App.Session;
|
|
19
|
+
assetPrefix: string;
|
|
19
20
|
} & RouterCache): JSX.Element;
|
|
20
21
|
type RouterCache = {
|
|
21
22
|
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
@@ -24,8 +25,10 @@ type RouterCache = {
|
|
|
24
25
|
last_variables: LRUCache<GraphQLVariables>;
|
|
25
26
|
pending_cache: PendingCache;
|
|
26
27
|
};
|
|
27
|
-
export declare function router_cache({ pending_queries, artifacts, components, }?: {
|
|
28
|
+
export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
|
|
28
29
|
pending_queries?: string[];
|
|
29
30
|
artifacts?: Record<string, QueryArtifact>;
|
|
30
31
|
components?: Record<string, (props: any) => React.ReactElement>;
|
|
32
|
+
initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
33
|
+
initialArtifacts?: Record<string, QueryArtifact>;
|
|
31
34
|
}): RouterCache;
|
|
@@ -29,7 +29,7 @@ __export(runtime_exports, {
|
|
|
29
29
|
router_cache: () => router_cache
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(runtime_exports);
|
|
32
|
-
var
|
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
33
|
var import_client2 = __toESM(require("./client"));
|
|
34
34
|
var import_manifest = __toESM(require("./manifest"));
|
|
35
35
|
var import_routing = require("./routing");
|
|
@@ -38,7 +38,7 @@ __reExport(runtime_exports, require("./hooks"), module.exports);
|
|
|
38
38
|
__reExport(runtime_exports, require("./routing"), module.exports);
|
|
39
39
|
function Router({
|
|
40
40
|
cache,
|
|
41
|
-
|
|
41
|
+
initialURL,
|
|
42
42
|
artifact_cache,
|
|
43
43
|
component_cache,
|
|
44
44
|
data_cache,
|
|
@@ -46,9 +46,10 @@ function Router({
|
|
|
46
46
|
last_variables,
|
|
47
47
|
loaded_queries,
|
|
48
48
|
loaded_artifacts,
|
|
49
|
-
session
|
|
49
|
+
session,
|
|
50
|
+
assetPrefix
|
|
50
51
|
}) {
|
|
51
|
-
return /* @__PURE__ */
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
52
53
|
import_routing.RouterContextProvider,
|
|
53
54
|
{
|
|
54
55
|
client: import_client2.default,
|
|
@@ -58,28 +59,31 @@ function Router({
|
|
|
58
59
|
data_cache,
|
|
59
60
|
pending_cache,
|
|
60
61
|
last_variables,
|
|
61
|
-
session
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
session,
|
|
63
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
import_routing.Router,
|
|
65
|
+
{
|
|
66
|
+
initialURL,
|
|
67
|
+
manifest: import_manifest.default,
|
|
68
|
+
loaded_queries,
|
|
69
|
+
loaded_artifacts,
|
|
70
|
+
assetPrefix
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
}
|
|
72
74
|
);
|
|
73
75
|
}
|
|
74
76
|
function router_cache({
|
|
75
77
|
pending_queries = [],
|
|
76
78
|
artifacts = {},
|
|
77
|
-
components = {}
|
|
79
|
+
components = {},
|
|
80
|
+
initialData = {},
|
|
81
|
+
initialArtifacts = {}
|
|
78
82
|
} = {}) {
|
|
79
83
|
const result = {
|
|
80
|
-
artifact_cache: (0, import_cache.suspense_cache)(),
|
|
84
|
+
artifact_cache: (0, import_cache.suspense_cache)(initialArtifacts),
|
|
81
85
|
component_cache: (0, import_cache.suspense_cache)(),
|
|
82
|
-
data_cache: (0, import_cache.suspense_cache)(),
|
|
86
|
+
data_cache: (0, import_cache.suspense_cache)(initialData),
|
|
83
87
|
pending_cache: (0, import_cache.suspense_cache)(),
|
|
84
88
|
last_variables: (0, import_cache.suspense_cache)()
|
|
85
89
|
};
|
|
@@ -5,22 +5,22 @@ import { GraphQLObject, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
|
5
5
|
import { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { SuspenseCache } from '../lib/cache';
|
|
8
|
-
import type {
|
|
8
|
+
import type { RouterManifest } from '../lib/types';
|
|
9
9
|
/**
|
|
10
10
|
* Router is the top level entry point for the filesystem-based router.
|
|
11
11
|
* It is responsible for loading various page sources (including API fetches) and
|
|
12
12
|
* then rendering when appropriate.
|
|
13
13
|
*/
|
|
14
|
-
export declare function Router({ manifest,
|
|
14
|
+
export declare function Router({ manifest, initialURL, loaded_queries, loaded_artifacts, assetPrefix, }: {
|
|
15
15
|
manifest: RouterManifest;
|
|
16
|
-
|
|
16
|
+
initialURL?: string;
|
|
17
17
|
loaded_queries?: Record<string, {
|
|
18
18
|
data: GraphQLObject;
|
|
19
19
|
variables: GraphQLVariables;
|
|
20
20
|
}>;
|
|
21
21
|
loaded_artifacts?: Record<string, QueryArtifact>;
|
|
22
|
+
assetPrefix: string;
|
|
22
23
|
}): JSX.Element;
|
|
23
|
-
export declare function useNavigationContext(): NavigationContext;
|
|
24
24
|
export declare function RouterContextProvider({ children, client, cache, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session: ssrSession, }: {
|
|
25
25
|
children: React.ReactElement;
|
|
26
26
|
client: HoudiniClient;
|
|
@@ -30,42 +30,40 @@ __export(Router_exports, {
|
|
|
30
30
|
useCache: () => useCache,
|
|
31
31
|
useClient: () => useClient,
|
|
32
32
|
useCurrentVariables: () => useCurrentVariables,
|
|
33
|
-
useNavigationContext: () => useNavigationContext,
|
|
34
33
|
useQueryResult: () => useQueryResult,
|
|
35
34
|
useRouterContext: () => useRouterContext,
|
|
36
35
|
useSession: () => useSession
|
|
37
36
|
});
|
|
38
37
|
module.exports = __toCommonJS(Router_exports);
|
|
38
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
39
|
var import_deepEquals = require("$houdini/runtime/lib/deepEquals");
|
|
40
40
|
var import_react = __toESM(require("react"));
|
|
41
41
|
var import_react_streaming = require("react-streaming");
|
|
42
42
|
var import_useDocumentStore = require("../../hooks/useDocumentStore");
|
|
43
43
|
var import_match = require("../lib/match");
|
|
44
|
-
const NavContext = import_react.default.createContext({
|
|
45
|
-
currentRoute: "/",
|
|
46
|
-
goto: () => {
|
|
47
|
-
throw new Error("NOT FOUND");
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
44
|
function Router({
|
|
51
45
|
manifest,
|
|
52
|
-
|
|
46
|
+
initialURL,
|
|
53
47
|
loaded_queries,
|
|
54
|
-
loaded_artifacts
|
|
48
|
+
loaded_artifacts,
|
|
49
|
+
assetPrefix
|
|
55
50
|
}) {
|
|
56
51
|
const [current, setCurrent] = import_react.default.useState(() => {
|
|
57
|
-
return
|
|
52
|
+
return initialURL || window.location.pathname;
|
|
58
53
|
});
|
|
59
54
|
const [page, variables] = (0, import_match.find_match)(manifest, current);
|
|
60
|
-
|
|
55
|
+
usePageData({ page, variables, loaded_queries, loaded_artifacts, assetPrefix });
|
|
61
56
|
const { component_cache } = useRouterContext();
|
|
62
57
|
const PageComponent = component_cache.get(page.id);
|
|
63
58
|
import_react.default.useEffect(() => {
|
|
64
|
-
if (window.location.pathname !== current) {
|
|
59
|
+
if (globalThis.window && window.location.pathname !== current) {
|
|
65
60
|
window.history.pushState({}, "", current);
|
|
66
61
|
}
|
|
67
62
|
}, [current]);
|
|
68
63
|
import_react.default.useEffect(() => {
|
|
64
|
+
if (!globalThis.window) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
69
67
|
const onChange = (evt) => {
|
|
70
68
|
setCurrent(window.location.pathname);
|
|
71
69
|
};
|
|
@@ -74,22 +72,15 @@ function Router({
|
|
|
74
72
|
window.removeEventListener("popstate", onChange);
|
|
75
73
|
};
|
|
76
74
|
}, []);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
value: {
|
|
81
|
-
currentRoute: current,
|
|
82
|
-
goto: setCurrent
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
/* @__PURE__ */ import_react.default.createElement(VariableContext.Provider, { value: variables }, /* @__PURE__ */ import_react.default.createElement(PageComponent, { url: current }))
|
|
86
|
-
);
|
|
75
|
+
useAnchorIntercept({ goto: setCurrent });
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VariableContext.Provider, { value: variables, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageComponent, { url: current }) });
|
|
87
77
|
}
|
|
88
|
-
function
|
|
78
|
+
function usePageData({
|
|
89
79
|
page,
|
|
90
80
|
variables,
|
|
91
81
|
loaded_queries,
|
|
92
|
-
loaded_artifacts
|
|
82
|
+
loaded_artifacts,
|
|
83
|
+
assetPrefix
|
|
93
84
|
}) {
|
|
94
85
|
const {
|
|
95
86
|
client,
|
|
@@ -131,17 +122,38 @@ function useLoadPage({
|
|
|
131
122
|
<script>
|
|
132
123
|
window.__houdini__cache__?.hydrate(${cache.serialize()}, window.__houdini__hydration__layer)
|
|
133
124
|
|
|
134
|
-
|
|
125
|
+
const artifactName = "${artifact.name}"
|
|
126
|
+
const value = ${JSON.stringify(observer.state.data)}
|
|
127
|
+
|
|
128
|
+
// if the data is pending, we need to resolve it
|
|
129
|
+
if (window.__houdini__nav_caches__?.data_cache.has(artifactName)) {
|
|
135
130
|
// before we resolve the pending signals,
|
|
136
131
|
// fill the data cache with values we got on the server
|
|
137
132
|
const new_store = window.__houdini__client__.observe({
|
|
138
|
-
artifact: window.__houdini__nav_caches__.artifact_cache.get(
|
|
133
|
+
artifact: window.__houdini__nav_caches__.artifact_cache.get(artifactName),
|
|
139
134
|
cache: window.__houdini__cache__,
|
|
140
|
-
initialValue:
|
|
135
|
+
initialValue: value
|
|
141
136
|
})
|
|
142
137
|
|
|
143
|
-
window.__houdini__nav_caches__
|
|
138
|
+
window.__houdini__nav_caches__?.data_cache.set(artifactName, new_store)
|
|
139
|
+
}
|
|
140
|
+
|
|
144
141
|
|
|
142
|
+
// if there are no data caches available we need to populate the pending one instead
|
|
143
|
+
if (!window.__houdini__nav_caches__) {
|
|
144
|
+
if (!window.__houdini__pending_data__) {
|
|
145
|
+
window.__houdini__pending_data__ = {}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!window.__houdini__pending_artifacts__) {
|
|
149
|
+
window.__houdini__pending_artifacts__ = {}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
window.__houdini__pending_data__[artifactName] = value
|
|
153
|
+
window.__houdini__pending_artifacts__[artifactName] = ${JSON.stringify(artifact)}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (window.__houdini__nav_caches__?.pending_cache.has(artifactName)) {
|
|
145
157
|
// we're pushing this store onto the client, it should be initialized
|
|
146
158
|
new_store.send({
|
|
147
159
|
setup: true,
|
|
@@ -149,8 +161,8 @@ function useLoadPage({
|
|
|
149
161
|
})
|
|
150
162
|
|
|
151
163
|
// notify anyone waiting on the pending cache
|
|
152
|
-
window.__houdini__nav_caches__.pending_cache.get(
|
|
153
|
-
window.__houdini__nav_caches__.pending_cache.delete(
|
|
164
|
+
window.__houdini__nav_caches__.pending_cache.get(artifactName).resolve()
|
|
165
|
+
window.__houdini__nav_caches__.pending_cache.delete(artifactName)
|
|
154
166
|
}
|
|
155
167
|
<\/script>
|
|
156
168
|
`);
|
|
@@ -182,7 +194,7 @@ function useLoadPage({
|
|
|
182
194
|
loaded_artifacts[artifact.name] = artifact;
|
|
183
195
|
}
|
|
184
196
|
stream?.injectToStream(`
|
|
185
|
-
<script type="module" src="
|
|
197
|
+
<script type="module" src="${assetPrefix}/artifacts/${artifact.name}.js" async=""><\/script>
|
|
186
198
|
`);
|
|
187
199
|
load_query({ id: artifact.name, artifact });
|
|
188
200
|
}).catch((err) => {
|
|
@@ -203,9 +215,6 @@ function useLoadPage({
|
|
|
203
215
|
});
|
|
204
216
|
}
|
|
205
217
|
}
|
|
206
|
-
function useNavigationContext() {
|
|
207
|
-
return import_react.default.useContext(NavContext);
|
|
208
|
-
}
|
|
209
218
|
function RouterContextProvider({
|
|
210
219
|
children,
|
|
211
220
|
client,
|
|
@@ -227,7 +236,7 @@ function RouterContextProvider({
|
|
|
227
236
|
window.removeEventListener("_houdini_session_", handleNewSession);
|
|
228
237
|
};
|
|
229
238
|
}, []);
|
|
230
|
-
return /* @__PURE__ */
|
|
239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
231
240
|
Context.Provider,
|
|
232
241
|
{
|
|
233
242
|
value: {
|
|
@@ -239,9 +248,9 @@ function RouterContextProvider({
|
|
|
239
248
|
pending_cache,
|
|
240
249
|
last_variables,
|
|
241
250
|
session
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
251
|
+
},
|
|
252
|
+
children
|
|
253
|
+
}
|
|
245
254
|
);
|
|
246
255
|
}
|
|
247
256
|
const Context = import_react.default.createContext(null);
|
|
@@ -281,6 +290,28 @@ function useQueryResult(name) {
|
|
|
281
290
|
});
|
|
282
291
|
return [data, observer];
|
|
283
292
|
}
|
|
293
|
+
function useAnchorIntercept({ goto }) {
|
|
294
|
+
const [pending, startTransition] = import_react.default.useTransition();
|
|
295
|
+
import_react.default.useEffect(() => {
|
|
296
|
+
let onClick = (e) => {
|
|
297
|
+
let link = e.target?.closest("a");
|
|
298
|
+
if (link && link instanceof HTMLAnchorElement && link.href && (!link.target || link.target === "_self") && link.origin === location.origin && !link.hasAttribute("download") && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.defaultPrevented) {
|
|
299
|
+
const target = link.attributes.getNamedItem("href")?.value;
|
|
300
|
+
if (!target || !target.startsWith("/")) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
e.preventDefault();
|
|
304
|
+
startTransition(() => {
|
|
305
|
+
goto(target);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
document.addEventListener("click", onClick);
|
|
310
|
+
return () => {
|
|
311
|
+
document.removeEventListener("click", onClick);
|
|
312
|
+
};
|
|
313
|
+
}, []);
|
|
314
|
+
}
|
|
284
315
|
// Annotate the CommonJS export names for ESM import in node:
|
|
285
316
|
0 && (module.exports = {
|
|
286
317
|
Router,
|
|
@@ -289,7 +320,6 @@ function useQueryResult(name) {
|
|
|
289
320
|
useCache,
|
|
290
321
|
useClient,
|
|
291
322
|
useCurrentVariables,
|
|
292
|
-
useNavigationContext,
|
|
293
323
|
useQueryResult,
|
|
294
324
|
useRouterContext,
|
|
295
325
|
useSession
|
|
@@ -18,18 +18,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var components_exports = {};
|
|
20
20
|
__export(components_exports, {
|
|
21
|
-
Link: () => import_Link.Link,
|
|
22
21
|
Router: () => import_Router.Router,
|
|
23
22
|
RouterContextProvider: () => import_Router.RouterContextProvider,
|
|
24
23
|
updateLocalSession: () => import_Router.updateLocalSession,
|
|
25
24
|
useClient: () => import_Router.useClient
|
|
26
25
|
});
|
|
27
26
|
module.exports = __toCommonJS(components_exports);
|
|
28
|
-
var import_Link = require("./Link");
|
|
29
27
|
var import_Router = require("./Router");
|
|
30
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
29
|
0 && (module.exports = {
|
|
32
|
-
Link,
|
|
33
30
|
Router,
|
|
34
31
|
RouterContextProvider,
|
|
35
32
|
updateLocalSession,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
2
|
-
export declare function suspense_cache<T>(): SuspenseCache<T>;
|
|
2
|
+
export declare function suspense_cache<T>(initialData?: Record<string, T>): SuspenseCache<T>;
|
|
3
3
|
export declare class SuspenseCache<_Data> extends LRUCache<_Data> {
|
|
4
4
|
#private;
|
|
5
5
|
get(key: string): _Data;
|
|
@@ -23,8 +23,12 @@ __export(cache_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(cache_exports);
|
|
25
25
|
var import_lru = require("$houdini/runtime/lib/lru");
|
|
26
|
-
function suspense_cache() {
|
|
27
|
-
|
|
26
|
+
function suspense_cache(initialData) {
|
|
27
|
+
const cache = new SuspenseCache();
|
|
28
|
+
for (const [key, value] of Object.entries(initialData ?? {})) {
|
|
29
|
+
cache.set(key, value);
|
|
30
|
+
}
|
|
31
|
+
return cache;
|
|
28
32
|
}
|
|
29
33
|
class SuspenseCache extends import_lru.LRUCache {
|
|
30
34
|
#callbacks = /* @__PURE__ */ new Map();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var compat_exports = {};
|
|
20
|
+
__export(compat_exports, {
|
|
21
|
+
dev_server: () => dev_server
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(compat_exports);
|
|
24
|
+
function dev_server({ server, config }) {
|
|
25
|
+
return {
|
|
26
|
+
use(fn) {
|
|
27
|
+
server.use((req, res, next) => {
|
|
28
|
+
fn(
|
|
29
|
+
{
|
|
30
|
+
url: req.url,
|
|
31
|
+
headers: new Headers(req.headers)
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
...res,
|
|
35
|
+
redirect(url, status = 307) {
|
|
36
|
+
res.statusCode = status;
|
|
37
|
+
res.setHeader("location", url);
|
|
38
|
+
res.setHeader("content-length", "0");
|
|
39
|
+
return res.end();
|
|
40
|
+
},
|
|
41
|
+
set_header: res.setHeader.bind(res)
|
|
42
|
+
},
|
|
43
|
+
next
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
dev_server
|
|
52
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var server_exports = {};
|
|
20
|
+
__export(server_exports, {
|
|
21
|
+
configure_server: () => configure_server
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(server_exports);
|
|
24
|
+
var import_config = require("../../plugin/config");
|
|
25
|
+
var import_session = require("./session");
|
|
26
|
+
function configure_server({ server, config }) {
|
|
27
|
+
server.use(server_handler({ config }));
|
|
28
|
+
}
|
|
29
|
+
function server_handler({ config }) {
|
|
30
|
+
const plugin_config = (0, import_config.plugin_config)(config);
|
|
31
|
+
return (req, res, next) => {
|
|
32
|
+
if (!req.url) {
|
|
33
|
+
next();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (plugin_config.auth && "redirect" in plugin_config.auth && req.url.startsWith(plugin_config.auth.redirect)) {
|
|
37
|
+
return redirect_auth(req, res, next);
|
|
38
|
+
}
|
|
39
|
+
next();
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const redirect_auth = (req, res, next) => {
|
|
43
|
+
const { searchParams } = new URL(req.url, `http://${req.headers.get("host")}`);
|
|
44
|
+
const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
|
|
45
|
+
(0, import_session.set_session)(res, session);
|
|
46
|
+
if (redirectTo) {
|
|
47
|
+
return res.redirect(redirectTo);
|
|
48
|
+
}
|
|
49
|
+
next();
|
|
50
|
+
};
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
configure_server
|
|
54
|
+
});
|