houdini-react 1.2.0-react.1 → 1.2.7
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/README.md +1 -1
- package/build/plugin/codegen/entries.d.ts +6 -0
- package/build/plugin/codegen/index.d.ts +14 -0
- package/build/plugin/codegen/manifest.d.ts +42 -0
- package/build/plugin/codegen/render.d.ts +2 -0
- package/build/plugin/codegen/router.d.ts +8 -0
- package/build/plugin/codegen/typeRoot.d.ts +6 -0
- package/build/plugin/config.d.ts +2 -1
- package/build/plugin/conventions.d.ts +24 -0
- package/build/plugin/dedent.d.ts +1 -0
- package/build/plugin/extract.d.ts +1 -1
- package/build/plugin/index.d.ts +16 -3
- package/build/plugin/vite.d.ts +19 -0
- package/build/plugin-cjs/index.js +132171 -43771
- package/build/plugin-esm/index.js +132162 -43765
- package/build/runtime/client.d.ts +3 -0
- package/build/runtime/clientPlugin.d.ts +3 -0
- package/build/runtime/hooks/useDocumentHandle.d.ts +4 -4
- package/build/runtime/hooks/useDocumentStore.d.ts +6 -5
- package/build/runtime/hooks/useDocumentSubscription.d.ts +4 -3
- package/build/runtime/hooks/useFragment.d.ts +3 -2
- package/build/runtime/hooks/useFragmentHandle.d.ts +2 -3
- package/build/runtime/hooks/useMutation.d.ts +2 -2
- package/build/runtime/hooks/useQuery.d.ts +3 -3
- package/build/runtime/hooks/useQueryHandle.d.ts +3 -3
- package/build/runtime/hooks/useSubscription.d.ts +2 -2
- package/build/runtime/hooks/useSubscriptionHandle.d.ts +3 -3
- package/build/runtime/index.d.ts +30 -1
- package/build/runtime/manifest.d.ts +3 -0
- package/build/runtime/routing/components/Link.d.ts +5 -0
- package/build/runtime/routing/components/Router.d.ts +56 -0
- package/build/runtime/routing/components/index.d.ts +2 -0
- package/build/runtime/routing/index.d.ts +3 -0
- package/build/runtime/routing/lib/cache.d.ts +7 -0
- package/build/runtime/routing/lib/match.d.ts +38 -0
- package/build/runtime/routing/lib/types.d.ts +23 -0
- package/build/runtime-cjs/client.d.ts +3 -0
- package/build/runtime-cjs/client.js +26 -0
- package/build/runtime-cjs/clientPlugin.d.ts +3 -0
- package/build/{next-cjs/index.js → runtime-cjs/clientPlugin.js} +15 -26
- package/build/runtime-cjs/hooks/useDocumentHandle.d.ts +4 -4
- package/build/runtime-cjs/hooks/useDocumentHandle.js +11 -7
- package/build/runtime-cjs/hooks/useDocumentStore.d.ts +6 -5
- package/build/runtime-cjs/hooks/useDocumentStore.js +9 -4
- package/build/runtime-cjs/hooks/useDocumentSubscription.d.ts +4 -3
- package/build/runtime-cjs/hooks/useDocumentSubscription.js +15 -8
- package/build/runtime-cjs/hooks/useFragment.d.ts +3 -2
- package/build/runtime-cjs/hooks/useFragment.js +9 -7
- package/build/runtime-cjs/hooks/useFragmentHandle.d.ts +2 -3
- package/build/runtime-cjs/hooks/useMutation.d.ts +2 -2
- package/build/runtime-cjs/hooks/useMutation.js +3 -1
- package/build/runtime-cjs/hooks/useQuery.d.ts +3 -3
- package/build/runtime-cjs/hooks/useQueryHandle.d.ts +3 -3
- package/build/runtime-cjs/hooks/useQueryHandle.js +4 -4
- package/build/runtime-cjs/hooks/useSubscription.d.ts +2 -2
- package/build/runtime-cjs/hooks/useSubscriptionHandle.d.ts +3 -3
- package/build/runtime-cjs/index.d.ts +30 -1
- package/build/runtime-cjs/index.js +89 -3
- package/build/runtime-cjs/manifest.d.ts +3 -0
- package/build/runtime-cjs/manifest.js +27 -0
- package/build/runtime-cjs/routing/components/Link.d.ts +5 -0
- package/build/runtime-cjs/{hooks/useHoudiniClient.js → routing/components/Link.js} +22 -13
- package/build/runtime-cjs/routing/components/Router.d.ts +56 -0
- package/build/runtime-cjs/routing/components/Router.js +296 -0
- package/build/runtime-cjs/routing/components/index.d.ts +2 -0
- package/build/runtime-cjs/{context.js → routing/components/index.js} +15 -19
- package/build/runtime-cjs/routing/index.d.ts +3 -0
- package/build/runtime-cjs/routing/index.js +30 -0
- package/build/runtime-cjs/routing/lib/cache.d.ts +7 -0
- package/build/runtime-cjs/{lib → routing/lib}/cache.js +23 -40
- package/build/runtime-cjs/routing/lib/match.d.ts +38 -0
- package/build/runtime-cjs/routing/lib/match.js +149 -0
- package/build/runtime-cjs/routing/lib/types.d.ts +23 -0
- package/build/runtime-cjs/routing/lib/types.js +16 -0
- package/build/runtime-esm/client.d.ts +3 -0
- package/build/runtime-esm/client.js +4 -0
- package/build/runtime-esm/clientPlugin.d.ts +3 -0
- package/build/runtime-esm/clientPlugin.js +17 -0
- package/build/runtime-esm/hooks/useDocumentHandle.d.ts +4 -4
- package/build/runtime-esm/hooks/useDocumentHandle.js +12 -10
- package/build/runtime-esm/hooks/useDocumentStore.d.ts +6 -5
- package/build/runtime-esm/hooks/useDocumentStore.js +9 -4
- package/build/runtime-esm/hooks/useDocumentSubscription.d.ts +4 -3
- package/build/runtime-esm/hooks/useDocumentSubscription.js +15 -8
- package/build/runtime-esm/hooks/useFragment.d.ts +3 -2
- package/build/runtime-esm/hooks/useFragment.js +9 -7
- package/build/runtime-esm/hooks/useFragmentHandle.d.ts +2 -3
- package/build/runtime-esm/hooks/useMutation.d.ts +2 -2
- package/build/runtime-esm/hooks/useMutation.js +3 -1
- package/build/runtime-esm/hooks/useQuery.d.ts +3 -3
- package/build/runtime-esm/hooks/useQueryHandle.d.ts +3 -3
- package/build/runtime-esm/hooks/useQueryHandle.js +4 -4
- package/build/runtime-esm/hooks/useSubscription.d.ts +2 -2
- package/build/runtime-esm/hooks/useSubscriptionHandle.d.ts +3 -3
- package/build/runtime-esm/index.d.ts +30 -1
- package/build/runtime-esm/index.js +81 -2
- package/build/runtime-esm/manifest.d.ts +3 -0
- package/build/runtime-esm/manifest.js +5 -0
- package/build/runtime-esm/routing/components/Link.d.ts +5 -0
- package/build/runtime-esm/routing/components/Link.js +21 -0
- package/build/runtime-esm/routing/components/Router.d.ts +56 -0
- package/build/runtime-esm/routing/components/Router.js +257 -0
- package/build/runtime-esm/routing/components/index.d.ts +2 -0
- package/build/runtime-esm/routing/components/index.js +9 -0
- package/build/runtime-esm/routing/index.d.ts +3 -0
- package/build/runtime-esm/routing/index.js +5 -0
- package/build/runtime-esm/routing/lib/cache.d.ts +7 -0
- package/build/runtime-esm/routing/lib/cache.js +29 -0
- package/build/runtime-esm/routing/lib/match.d.ts +38 -0
- package/build/runtime-esm/routing/lib/match.js +122 -0
- package/build/runtime-esm/routing/lib/types.d.ts +23 -0
- package/build/runtime-esm/routing/lib/types.js +0 -0
- package/build/server/compat.d.ts +7 -0
- package/build/server/index.d.ts +17 -0
- package/build/server/session.d.ts +3 -0
- package/build/server-cjs/index.js +166712 -0
- package/build/server-esm/index.js +166703 -0
- package/package.json +21 -10
- package/build/next/index.d.ts +0 -2
- package/build/next-esm/index.js +0 -26
- package/build/runtime/context.d.ts +0 -7
- package/build/runtime/hooks/useHoudiniClient.d.ts +0 -2
- package/build/runtime/lib/cache.d.ts +0 -62
- package/build/runtime-cjs/context.d.ts +0 -7
- package/build/runtime-cjs/hooks/useHoudiniClient.d.ts +0 -2
- package/build/runtime-cjs/lib/cache.d.ts +0 -62
- package/build/runtime-esm/context.d.ts +0 -7
- package/build/runtime-esm/context.js +0 -10
- package/build/runtime-esm/hooks/useHoudiniClient.d.ts +0 -2
- package/build/runtime-esm/hooks/useHoudiniClient.js +0 -12
- package/build/runtime-esm/lib/cache.d.ts +0 -62
- package/build/runtime-esm/lib/cache.js +0 -47
- /package/build/{next-cjs → server-cjs}/package.json +0 -0
- /package/build/{next-esm → server-esm}/package.json +0 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var Router_exports = {};
|
|
26
|
+
__export(Router_exports, {
|
|
27
|
+
Router: () => Router,
|
|
28
|
+
RouterContextProvider: () => RouterContextProvider,
|
|
29
|
+
updateLocalSession: () => updateLocalSession,
|
|
30
|
+
useCache: () => useCache,
|
|
31
|
+
useClient: () => useClient,
|
|
32
|
+
useCurrentVariables: () => useCurrentVariables,
|
|
33
|
+
useNavigationContext: () => useNavigationContext,
|
|
34
|
+
useQueryResult: () => useQueryResult,
|
|
35
|
+
useRouterContext: () => useRouterContext,
|
|
36
|
+
useSession: () => useSession
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(Router_exports);
|
|
39
|
+
var import_deepEquals = require("$houdini/runtime/lib/deepEquals");
|
|
40
|
+
var import_react = __toESM(require("react"));
|
|
41
|
+
var import_react_streaming = require("react-streaming");
|
|
42
|
+
var import_useDocumentStore = require("../../hooks/useDocumentStore");
|
|
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
|
+
function Router({
|
|
51
|
+
manifest,
|
|
52
|
+
intialURL,
|
|
53
|
+
loaded_queries,
|
|
54
|
+
loaded_artifacts
|
|
55
|
+
}) {
|
|
56
|
+
const [current, setCurrent] = import_react.default.useState(() => {
|
|
57
|
+
return intialURL || window.location.pathname;
|
|
58
|
+
});
|
|
59
|
+
const [page, variables] = (0, import_match.find_match)(manifest, current);
|
|
60
|
+
useLoadPage({ page, variables, loaded_queries, loaded_artifacts });
|
|
61
|
+
const { component_cache } = useRouterContext();
|
|
62
|
+
const PageComponent = component_cache.get(page.id);
|
|
63
|
+
import_react.default.useEffect(() => {
|
|
64
|
+
if (window.location.pathname !== current) {
|
|
65
|
+
window.history.pushState({}, "", current);
|
|
66
|
+
}
|
|
67
|
+
}, [current]);
|
|
68
|
+
import_react.default.useEffect(() => {
|
|
69
|
+
const onChange = (evt) => {
|
|
70
|
+
setCurrent(window.location.pathname);
|
|
71
|
+
};
|
|
72
|
+
window.addEventListener("popstate", onChange);
|
|
73
|
+
return () => {
|
|
74
|
+
window.removeEventListener("popstate", onChange);
|
|
75
|
+
};
|
|
76
|
+
}, []);
|
|
77
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
78
|
+
NavContext.Provider,
|
|
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
|
+
);
|
|
87
|
+
}
|
|
88
|
+
function useLoadPage({
|
|
89
|
+
page,
|
|
90
|
+
variables,
|
|
91
|
+
loaded_queries,
|
|
92
|
+
loaded_artifacts
|
|
93
|
+
}) {
|
|
94
|
+
const {
|
|
95
|
+
client,
|
|
96
|
+
cache,
|
|
97
|
+
data_cache,
|
|
98
|
+
component_cache,
|
|
99
|
+
artifact_cache,
|
|
100
|
+
pending_cache,
|
|
101
|
+
last_variables
|
|
102
|
+
} = useRouterContext();
|
|
103
|
+
const stream = (0, import_react_streaming.useStream)();
|
|
104
|
+
const session = useSession();
|
|
105
|
+
function load_query({ id, artifact }) {
|
|
106
|
+
last_variables.set(page.id, variables);
|
|
107
|
+
if (pending_cache.has(id)) {
|
|
108
|
+
return pending_cache.get(id);
|
|
109
|
+
}
|
|
110
|
+
const observer = client.observe({ artifact, cache });
|
|
111
|
+
let resolve = () => {
|
|
112
|
+
};
|
|
113
|
+
let reject = () => {
|
|
114
|
+
};
|
|
115
|
+
const promise = new Promise((res, rej) => {
|
|
116
|
+
resolve = res;
|
|
117
|
+
reject = rej;
|
|
118
|
+
observer.send({
|
|
119
|
+
variables,
|
|
120
|
+
cacheParams: { disableSubscriptions: true },
|
|
121
|
+
session
|
|
122
|
+
}).then(() => {
|
|
123
|
+
data_cache.set(id, observer);
|
|
124
|
+
if (loaded_queries) {
|
|
125
|
+
loaded_queries[artifact.name] = {
|
|
126
|
+
data: observer.state.data,
|
|
127
|
+
variables
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
stream?.injectToStream(`
|
|
131
|
+
<script>
|
|
132
|
+
window.__houdini__cache__?.hydrate(${cache.serialize()}, window.__houdini__hydration__layer)
|
|
133
|
+
|
|
134
|
+
if (window.__houdini__nav_caches__?.pending_cache.has("${artifact.name}")) {
|
|
135
|
+
// before we resolve the pending signals,
|
|
136
|
+
// fill the data cache with values we got on the server
|
|
137
|
+
const new_store = window.__houdini__client__.observe({
|
|
138
|
+
artifact: window.__houdini__nav_caches__.artifact_cache.get("${artifact.name}"),
|
|
139
|
+
cache: window.__houdini__cache__,
|
|
140
|
+
initialValue: ${JSON.stringify(observer.state.data)}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
window.__houdini__nav_caches__.data_cache.set("${artifact.name}", new_store)
|
|
144
|
+
|
|
145
|
+
// we're pushing this store onto the client, it should be initialized
|
|
146
|
+
new_store.send({
|
|
147
|
+
setup: true,
|
|
148
|
+
variables: ${JSON.stringify(variables)}
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
// notify anyone waiting on the pending cache
|
|
152
|
+
window.__houdini__nav_caches__.pending_cache.get("${artifact.name}").resolve()
|
|
153
|
+
window.__houdini__nav_caches__.pending_cache.delete("${artifact.name}")
|
|
154
|
+
}
|
|
155
|
+
<\/script>
|
|
156
|
+
`);
|
|
157
|
+
resolve();
|
|
158
|
+
}).catch(reject).finally(() => {
|
|
159
|
+
pending_cache.delete(id);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
pending_cache.set(id, { ...promise, resolve, reject });
|
|
163
|
+
return pending_cache.get(id);
|
|
164
|
+
}
|
|
165
|
+
if (last_variables.has(page.id) && !(0, import_deepEquals.deepEquals)(last_variables.get(page.id), variables)) {
|
|
166
|
+
data_cache.clear();
|
|
167
|
+
}
|
|
168
|
+
const missing_artifacts = [];
|
|
169
|
+
const found_artifacts = {};
|
|
170
|
+
for (const key of Object.keys(page.documents)) {
|
|
171
|
+
if (artifact_cache.has(key)) {
|
|
172
|
+
found_artifacts[key] = artifact_cache.get(key);
|
|
173
|
+
} else {
|
|
174
|
+
missing_artifacts.push(key);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
for (const artifact_id of missing_artifacts) {
|
|
178
|
+
page.documents[artifact_id].artifact().then((mod) => {
|
|
179
|
+
const artifact = mod.default;
|
|
180
|
+
artifact_cache.set(artifact_id, artifact);
|
|
181
|
+
if (loaded_artifacts) {
|
|
182
|
+
loaded_artifacts[artifact.name] = artifact;
|
|
183
|
+
}
|
|
184
|
+
stream?.injectToStream(`
|
|
185
|
+
<script type="module" src="@@houdini/artifact/${artifact.name}.js" async=""><\/script>
|
|
186
|
+
`);
|
|
187
|
+
load_query({ id: artifact.name, artifact });
|
|
188
|
+
}).catch((err) => {
|
|
189
|
+
console.log(err);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
for (const artifact of Object.values(found_artifacts)) {
|
|
193
|
+
if (!data_cache.has(artifact.name)) {
|
|
194
|
+
load_query({ id: artifact.name, artifact });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (!component_cache.has(page.id)) {
|
|
198
|
+
throw new Promise((resolve, reject) => {
|
|
199
|
+
page.component().then((mod) => {
|
|
200
|
+
component_cache.set(page.id, mod.default);
|
|
201
|
+
resolve();
|
|
202
|
+
}).catch(reject);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function useNavigationContext() {
|
|
207
|
+
return import_react.default.useContext(NavContext);
|
|
208
|
+
}
|
|
209
|
+
function RouterContextProvider({
|
|
210
|
+
children,
|
|
211
|
+
client,
|
|
212
|
+
cache,
|
|
213
|
+
artifact_cache,
|
|
214
|
+
component_cache,
|
|
215
|
+
data_cache,
|
|
216
|
+
pending_cache,
|
|
217
|
+
last_variables,
|
|
218
|
+
session: ssrSession = {}
|
|
219
|
+
}) {
|
|
220
|
+
const [session, setSession] = import_react.default.useState(ssrSession);
|
|
221
|
+
const handleNewSession = import_react.default.useCallback((event) => {
|
|
222
|
+
setSession(event.detail);
|
|
223
|
+
}, []);
|
|
224
|
+
import_react.default.useEffect(() => {
|
|
225
|
+
window.addEventListener("_houdini_session_", handleNewSession);
|
|
226
|
+
return () => {
|
|
227
|
+
window.removeEventListener("_houdini_session_", handleNewSession);
|
|
228
|
+
};
|
|
229
|
+
}, []);
|
|
230
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
231
|
+
Context.Provider,
|
|
232
|
+
{
|
|
233
|
+
value: {
|
|
234
|
+
client,
|
|
235
|
+
cache,
|
|
236
|
+
artifact_cache,
|
|
237
|
+
component_cache,
|
|
238
|
+
data_cache,
|
|
239
|
+
pending_cache,
|
|
240
|
+
last_variables,
|
|
241
|
+
session
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
children
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
const Context = import_react.default.createContext(null);
|
|
248
|
+
const useRouterContext = () => {
|
|
249
|
+
const ctx = import_react.default.useContext(Context);
|
|
250
|
+
if (!ctx) {
|
|
251
|
+
throw new Error("Could not find router context");
|
|
252
|
+
}
|
|
253
|
+
return ctx;
|
|
254
|
+
};
|
|
255
|
+
function useClient() {
|
|
256
|
+
return useRouterContext().client;
|
|
257
|
+
}
|
|
258
|
+
function useCache() {
|
|
259
|
+
return useRouterContext().cache;
|
|
260
|
+
}
|
|
261
|
+
function updateLocalSession(session) {
|
|
262
|
+
window.dispatchEvent(
|
|
263
|
+
new CustomEvent("_houdini_session_", {
|
|
264
|
+
bubbles: true,
|
|
265
|
+
detail: session
|
|
266
|
+
})
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
function useSession() {
|
|
270
|
+
return useRouterContext().session;
|
|
271
|
+
}
|
|
272
|
+
function useCurrentVariables() {
|
|
273
|
+
return import_react.default.useContext(VariableContext);
|
|
274
|
+
}
|
|
275
|
+
const VariableContext = import_react.default.createContext(null);
|
|
276
|
+
function useQueryResult(name) {
|
|
277
|
+
const store_ref = useRouterContext().data_cache.get(name);
|
|
278
|
+
const [{ data }, observer] = (0, import_useDocumentStore.useDocumentStore)({
|
|
279
|
+
artifact: store_ref.artifact,
|
|
280
|
+
observer: store_ref
|
|
281
|
+
});
|
|
282
|
+
return [data, observer];
|
|
283
|
+
}
|
|
284
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
285
|
+
0 && (module.exports = {
|
|
286
|
+
Router,
|
|
287
|
+
RouterContextProvider,
|
|
288
|
+
updateLocalSession,
|
|
289
|
+
useCache,
|
|
290
|
+
useClient,
|
|
291
|
+
useCurrentVariables,
|
|
292
|
+
useNavigationContext,
|
|
293
|
+
useQueryResult,
|
|
294
|
+
useRouterContext,
|
|
295
|
+
useSession
|
|
296
|
+
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,25 +15,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
var
|
|
26
|
-
__export(
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
var components_exports = {};
|
|
20
|
+
__export(components_exports, {
|
|
21
|
+
Link: () => import_Link.Link,
|
|
22
|
+
Router: () => import_Router.Router,
|
|
23
|
+
RouterContextProvider: () => import_Router.RouterContextProvider,
|
|
24
|
+
updateLocalSession: () => import_Router.updateLocalSession,
|
|
25
|
+
useClient: () => import_Router.useClient
|
|
29
26
|
});
|
|
30
|
-
module.exports = __toCommonJS(
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
const HoudiniProvider = ({
|
|
34
|
-
client,
|
|
35
|
-
children
|
|
36
|
-
}) => /* @__PURE__ */ React.createElement(HoudiniContext.Provider, { value: client }, children);
|
|
27
|
+
module.exports = __toCommonJS(components_exports);
|
|
28
|
+
var import_Link = require("./Link");
|
|
29
|
+
var import_Router = require("./Router");
|
|
37
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
31
|
0 && (module.exports = {
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
Link,
|
|
33
|
+
Router,
|
|
34
|
+
RouterContextProvider,
|
|
35
|
+
updateLocalSession,
|
|
36
|
+
useClient
|
|
41
37
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var routing_exports = {};
|
|
21
|
+
__export(routing_exports, {
|
|
22
|
+
suspense_cache: () => import_cache.suspense_cache
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(routing_exports);
|
|
25
|
+
__reExport(routing_exports, require("./components"), module.exports);
|
|
26
|
+
var import_cache = require("./lib/cache");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
suspense_cache
|
|
30
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
2
|
+
export declare function suspense_cache<T>(): SuspenseCache<T>;
|
|
3
|
+
export declare class SuspenseCache<_Data> extends LRUCache<_Data> {
|
|
4
|
+
#private;
|
|
5
|
+
get(key: string): _Data;
|
|
6
|
+
set(key: string, value: _Data): void;
|
|
7
|
+
}
|
|
@@ -18,54 +18,37 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var cache_exports = {};
|
|
20
20
|
__export(cache_exports, {
|
|
21
|
-
|
|
21
|
+
SuspenseCache: () => SuspenseCache,
|
|
22
|
+
suspense_cache: () => suspense_cache
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(cache_exports);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
set(key, value) {
|
|
32
|
-
this._map.delete(key);
|
|
33
|
-
this._map.set(key, value);
|
|
34
|
-
if (this._map.size > this._capacity) {
|
|
35
|
-
const firstKey = this._map.keys().next();
|
|
36
|
-
if (!firstKey.done) {
|
|
37
|
-
this._map.delete(firstKey.value);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
25
|
+
var import_lru = require("$houdini/runtime/lib/lru");
|
|
26
|
+
function suspense_cache() {
|
|
27
|
+
return new SuspenseCache();
|
|
28
|
+
}
|
|
29
|
+
class SuspenseCache extends import_lru.LRUCache {
|
|
30
|
+
#callbacks = /* @__PURE__ */ new Map();
|
|
41
31
|
get(key) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this._map.delete(key);
|
|
45
|
-
this._map.set(key, value);
|
|
32
|
+
if (super.has(key)) {
|
|
33
|
+
return super.get(key);
|
|
46
34
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return this._map.has(key);
|
|
35
|
+
throw new Promise((resolve, reject) => {
|
|
36
|
+
this.#subscribe(key, resolve, reject);
|
|
37
|
+
});
|
|
51
38
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
capacity() {
|
|
59
|
-
return this._capacity - this._map.size;
|
|
39
|
+
set(key, value) {
|
|
40
|
+
super.set(key, value);
|
|
41
|
+
if (this.#callbacks.has(key)) {
|
|
42
|
+
this.#callbacks.get(key)?.forEach(({ resolve }) => resolve());
|
|
43
|
+
this.#callbacks.delete(key);
|
|
44
|
+
}
|
|
60
45
|
}
|
|
61
|
-
|
|
62
|
-
this.
|
|
46
|
+
#subscribe(key, resolve, reject) {
|
|
47
|
+
this.#callbacks.set(key, [...this.#callbacks.get(key) || [], { resolve, reject }]);
|
|
63
48
|
}
|
|
64
49
|
}
|
|
65
|
-
function createCache(capacity = 1e3) {
|
|
66
|
-
return new LRUCache(capacity);
|
|
67
|
-
}
|
|
68
50
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
51
|
0 && (module.exports = {
|
|
70
|
-
|
|
52
|
+
SuspenseCache,
|
|
53
|
+
suspense_cache
|
|
71
54
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { RouterManifest, RouterPageManifest } from './types';
|
|
3
|
+
export type RouteParam = {
|
|
4
|
+
name: string;
|
|
5
|
+
matcher: string;
|
|
6
|
+
optional: boolean;
|
|
7
|
+
rest: boolean;
|
|
8
|
+
chained: boolean;
|
|
9
|
+
};
|
|
10
|
+
export interface ParamMatcher {
|
|
11
|
+
(param: string): boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function find_match(manifest: RouterManifest, current: string, allowNull: true): [RouterPageManifest | null, GraphQLVariables];
|
|
14
|
+
export declare function find_match(manifest: RouterManifest, current: string, allowNull?: false): [RouterPageManifest, GraphQLVariables];
|
|
15
|
+
/**
|
|
16
|
+
* Creates the regex pattern, extracts parameter names, and generates types for a route
|
|
17
|
+
*/
|
|
18
|
+
export declare function parse_page_pattern(id: string): {
|
|
19
|
+
pattern: RegExp;
|
|
20
|
+
params: RouteParam[];
|
|
21
|
+
page_id: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Splits a route id into its segments, removing segments that
|
|
25
|
+
* don't affect the path (i.e. groups). The root route is represented by `/`
|
|
26
|
+
* and will be returned as `['']`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function get_route_segments(route: string): string[];
|
|
29
|
+
export declare function exec(match: RegExpMatchArray, params: RouteParam[]): Record<string, string> | undefined;
|
|
30
|
+
/**
|
|
31
|
+
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
|
|
32
|
+
|
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
34
|
+
|
|
35
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
36
|
+
|
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
38
|
+
*/
|
|
@@ -0,0 +1,149 @@
|
|
|
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 match_exports = {};
|
|
20
|
+
__export(match_exports, {
|
|
21
|
+
exec: () => exec,
|
|
22
|
+
find_match: () => find_match,
|
|
23
|
+
get_route_segments: () => get_route_segments,
|
|
24
|
+
parse_page_pattern: () => parse_page_pattern
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(match_exports);
|
|
27
|
+
const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
28
|
+
function find_match(manifest, current, allowNull) {
|
|
29
|
+
let match = null;
|
|
30
|
+
let matchVariables = null;
|
|
31
|
+
for (const page of Object.values(manifest.pages)) {
|
|
32
|
+
const urlMatch = current.match(page.pattern);
|
|
33
|
+
if (!urlMatch) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
match = page;
|
|
37
|
+
matchVariables = exec(urlMatch, page.params) || {};
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
if (!match && !allowNull) {
|
|
41
|
+
throw new Error("404");
|
|
42
|
+
}
|
|
43
|
+
return [match, matchVariables];
|
|
44
|
+
}
|
|
45
|
+
function parse_page_pattern(id) {
|
|
46
|
+
const params = [];
|
|
47
|
+
const pattern = id === "/" ? /^\/$/ : new RegExp(
|
|
48
|
+
`^${get_route_segments(id).map((segment) => {
|
|
49
|
+
const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
|
|
50
|
+
if (rest_match) {
|
|
51
|
+
params.push({
|
|
52
|
+
name: rest_match[1],
|
|
53
|
+
matcher: rest_match[2],
|
|
54
|
+
optional: false,
|
|
55
|
+
rest: true,
|
|
56
|
+
chained: true
|
|
57
|
+
});
|
|
58
|
+
return "(?:/(.*))?";
|
|
59
|
+
}
|
|
60
|
+
const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
|
|
61
|
+
if (optional_match) {
|
|
62
|
+
params.push({
|
|
63
|
+
name: optional_match[1],
|
|
64
|
+
matcher: optional_match[2],
|
|
65
|
+
optional: true,
|
|
66
|
+
rest: false,
|
|
67
|
+
chained: true
|
|
68
|
+
});
|
|
69
|
+
return "(?:/([^/]+))?";
|
|
70
|
+
}
|
|
71
|
+
if (!segment) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const parts = segment.split(/\[(.+?)\](?!\])/);
|
|
75
|
+
const result = parts.map((content, i) => {
|
|
76
|
+
if (i % 2) {
|
|
77
|
+
if (content.startsWith("x+")) {
|
|
78
|
+
return escape(
|
|
79
|
+
String.fromCharCode(parseInt(content.slice(2), 16))
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (content.startsWith("u+")) {
|
|
83
|
+
return escape(
|
|
84
|
+
String.fromCharCode(
|
|
85
|
+
...content.slice(2).split("-").map((code) => parseInt(code, 16))
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const match = param_pattern.exec(content);
|
|
90
|
+
if (!match) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const [, is_optional, is_rest, name, matcher] = match;
|
|
96
|
+
params.push({
|
|
97
|
+
name,
|
|
98
|
+
matcher,
|
|
99
|
+
optional: !!is_optional,
|
|
100
|
+
rest: !!is_rest,
|
|
101
|
+
chained: is_rest ? i === 1 && parts[0] === "" : false
|
|
102
|
+
});
|
|
103
|
+
return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
|
|
104
|
+
}
|
|
105
|
+
return escape(content);
|
|
106
|
+
}).join("");
|
|
107
|
+
return "/" + result;
|
|
108
|
+
}).join("")}/?$`
|
|
109
|
+
);
|
|
110
|
+
return { pattern, params, page_id: id };
|
|
111
|
+
}
|
|
112
|
+
function affects_path(segment) {
|
|
113
|
+
return !/^\([^)]+\)$/.test(segment);
|
|
114
|
+
}
|
|
115
|
+
function get_route_segments(route) {
|
|
116
|
+
return route.slice(1).split("/").filter(affects_path);
|
|
117
|
+
}
|
|
118
|
+
function exec(match, params) {
|
|
119
|
+
const result = {};
|
|
120
|
+
const values = match.slice(1);
|
|
121
|
+
let buffered = "";
|
|
122
|
+
for (let i = 0; i < params.length; i += 1) {
|
|
123
|
+
const param = params[i];
|
|
124
|
+
let value = values[i];
|
|
125
|
+
if (param.chained && param.rest && buffered) {
|
|
126
|
+
value = value ? buffered + "/" + value : buffered;
|
|
127
|
+
}
|
|
128
|
+
buffered = "";
|
|
129
|
+
if (value === void 0) {
|
|
130
|
+
if (param.rest)
|
|
131
|
+
result[param.name] = "";
|
|
132
|
+
} else {
|
|
133
|
+
result[param.name] = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (buffered)
|
|
137
|
+
return;
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
function escape(str) {
|
|
141
|
+
return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
|
|
142
|
+
}
|
|
143
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
+
0 && (module.exports = {
|
|
145
|
+
exec,
|
|
146
|
+
find_match,
|
|
147
|
+
get_route_segments,
|
|
148
|
+
parse_page_pattern
|
|
149
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { RouteParam } from './match';
|
|
3
|
+
export type RouterManifest = {
|
|
4
|
+
pages: Record<string, RouterPageManifest>;
|
|
5
|
+
};
|
|
6
|
+
export type RouterPageManifest = {
|
|
7
|
+
id: string;
|
|
8
|
+
pattern: RegExp;
|
|
9
|
+
params: RouteParam[];
|
|
10
|
+
documents: Record<string, {
|
|
11
|
+
artifact: () => Promise<{
|
|
12
|
+
default: QueryArtifact;
|
|
13
|
+
}>;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
component: () => Promise<{
|
|
17
|
+
default: (props: any) => React.ReactElement;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
export type NavigationContext = {
|
|
21
|
+
currentRoute: string;
|
|
22
|
+
goto: (route: string) => void;
|
|
23
|
+
};
|