@hamur/adapter-preact 0.0.0-stage → 0.0.2
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/LICENSE +22 -0
- package/README.md +35 -2
- package/dist/chunks/browser-index-89d71ade.js +118 -0
- package/dist/chunks/browser-index-ezte15pp.js +67 -0
- package/dist/chunks/browser-index-hsy7tnbg.js +21 -0
- package/dist/chunks/browser-index-k3m2axbw.js +274 -0
- package/dist/src/adapter.js +456 -0
- package/dist/src/error-page.js +391 -0
- package/dist/src/index.js +1506 -0
- package/dist/src/keepalive.js +6 -0
- package/dist/src/runtime/client.js +96 -0
- package/dist/src/runtime/island.js +33 -0
- package/dist/src/runtime/server.js +95 -0
- package/dist/types/src/activation.d.ts +15 -0
- package/dist/types/src/adapter.d.ts +2 -0
- package/dist/types/src/async-data.d.ts +13 -0
- package/dist/types/src/client-component.d.ts +11 -0
- package/dist/types/src/client-fallback.d.ts +2 -0
- package/dist/types/src/context.d.ts +81 -0
- package/dist/types/src/error-page.d.ts +1 -0
- package/dist/types/src/head.d.ts +5 -0
- package/dist/types/src/index.d.ts +429 -0
- package/dist/types/src/island-html.d.ts +13 -0
- package/dist/types/src/island.d.ts +19 -0
- package/dist/types/src/jsx-locator.d.ts +6 -0
- package/dist/types/src/keepalive.d.ts +26 -0
- package/dist/types/src/lazy-hydration.d.ts +12 -0
- package/dist/types/src/markdown-page.d.ts +9 -0
- package/dist/types/src/markdown.d.ts +12 -0
- package/dist/types/src/plugin.d.ts +36 -0
- package/dist/types/src/route-boundary.d.ts +41 -0
- package/dist/types/src/runtime/client.d.ts +10 -0
- package/dist/types/src/runtime/hmr.d.ts +31 -0
- package/dist/types/src/runtime/hydration-dev.d.ts +1 -0
- package/dist/types/src/runtime/hydration.d.ts +8 -0
- package/dist/types/src/runtime/island.d.ts +8 -0
- package/dist/types/src/runtime/server.d.ts +11 -0
- package/dist/types/src/server-island.d.ts +10 -0
- package/dist/types/src/svg.d.ts +10 -0
- package/package.json +71 -4
- package/src/activation.ts +51 -0
- package/src/adapter.ts +35 -0
- package/src/async-data.ts +65 -0
- package/src/client-component.ts +23 -0
- package/src/client-fallback.ts +2 -0
- package/src/context.ts +372 -0
- package/src/env.d.ts +3 -0
- package/src/error-page.ts +1 -0
- package/src/head.ts +34 -0
- package/src/index.ts +1868 -0
- package/src/island-html.ts +58 -0
- package/src/island.ts +56 -0
- package/src/jsx-locator.ts +199 -0
- package/src/keepalive.ts +100 -0
- package/src/lazy-hydration.ts +101 -0
- package/src/markdown-page.ts +18 -0
- package/src/markdown.ts +58 -0
- package/src/plugin.ts +231 -0
- package/src/route-boundary.ts +51 -0
- package/src/runtime/client.ts +85 -0
- package/src/runtime/hmr.ts +141 -0
- package/src/runtime/hydration-dev.ts +8 -0
- package/src/runtime/hydration.ts +7 -0
- package/src/runtime/island.ts +37 -0
- package/src/runtime/server.ts +102 -0
- package/src/server-island.ts +35 -0
- package/src/svg.ts +27 -0
- package/src/webmcp.d.ts +18 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/adapter-preact/src/index.ts
|
|
3
|
+
import { Component as Component3, Fragment as Fragment3, createElement as createElement5 } from "preact";
|
|
4
|
+
import { reportWebVitals, syncedState } from "hamur/app";
|
|
5
|
+
import { Suspense as Suspense3 } from "preact/compat";
|
|
6
|
+
import {
|
|
7
|
+
asyncDataArguments,
|
|
8
|
+
asyncDataKey,
|
|
9
|
+
stateArguments,
|
|
10
|
+
fetchKey,
|
|
11
|
+
timeAttributes,
|
|
12
|
+
timeView,
|
|
13
|
+
watchTime,
|
|
14
|
+
createLoadingIndicator,
|
|
15
|
+
loadingIndicatorOptions,
|
|
16
|
+
paintLoadingIndicator,
|
|
17
|
+
createRouteAnnouncer,
|
|
18
|
+
createAnnouncer,
|
|
19
|
+
announcerActions,
|
|
20
|
+
announcerRole,
|
|
21
|
+
hideAnnouncer,
|
|
22
|
+
ROUTE_ANNOUNCER_ID,
|
|
23
|
+
ANNOUNCER_POLITE_ID,
|
|
24
|
+
ANNOUNCER_ASSERTIVE_ID,
|
|
25
|
+
isHandlerReference,
|
|
26
|
+
isPending,
|
|
27
|
+
resolveCallOptions,
|
|
28
|
+
settledOf
|
|
29
|
+
} from "hamur/adapter";
|
|
30
|
+
import {
|
|
31
|
+
useCallback,
|
|
32
|
+
useContext as useContext6,
|
|
33
|
+
useEffect as useEffect3,
|
|
34
|
+
useId as useId3,
|
|
35
|
+
useLayoutEffect as useLayoutEffect2,
|
|
36
|
+
useMemo as useMemo2,
|
|
37
|
+
useRef as useRef2,
|
|
38
|
+
useState as useLocalState
|
|
39
|
+
} from "preact/hooks";
|
|
40
|
+
import {
|
|
41
|
+
clearAsyncData,
|
|
42
|
+
createForm,
|
|
43
|
+
enhance,
|
|
44
|
+
navigateTo,
|
|
45
|
+
redirect,
|
|
46
|
+
useCookie as cookieOf,
|
|
47
|
+
withoutBase
|
|
48
|
+
} from "hamur/app";
|
|
49
|
+
import {
|
|
50
|
+
callOnce as callOnceOf,
|
|
51
|
+
clearState as clearStateOf,
|
|
52
|
+
setResponseStatus as setResponseStatusOf,
|
|
53
|
+
useResponseHeader as responseHeaderOf,
|
|
54
|
+
useRequestEvent as requestEventOf,
|
|
55
|
+
useRequestFetch as requestFetchOf,
|
|
56
|
+
useRequestHeader as requestHeaderOf,
|
|
57
|
+
useRequestHeaders as requestHeadersOf,
|
|
58
|
+
useRequestURL as requestURLOf,
|
|
59
|
+
usePreviewMode as previewModeOf
|
|
60
|
+
} from "hamur/app";
|
|
61
|
+
import { whenAppReady } from "hamur/adapter";
|
|
62
|
+
import {
|
|
63
|
+
layoutSegments,
|
|
64
|
+
IDLE_FORM_STATUS,
|
|
65
|
+
assertFormMethod,
|
|
66
|
+
createActionRunner,
|
|
67
|
+
createFormStatus,
|
|
68
|
+
functionFormAction,
|
|
69
|
+
linkActionRunner,
|
|
70
|
+
restoredResult,
|
|
71
|
+
runFunctionForm,
|
|
72
|
+
publicError,
|
|
73
|
+
runtimeConfigOf,
|
|
74
|
+
siteConfigOf,
|
|
75
|
+
sanitizeHead,
|
|
76
|
+
seoMetaToHead,
|
|
77
|
+
createLinkSlot,
|
|
78
|
+
linkAttributes,
|
|
79
|
+
linkExtraAttributes,
|
|
80
|
+
linkState,
|
|
81
|
+
warnRemovedLinkProps,
|
|
82
|
+
relativeTarget,
|
|
83
|
+
resolveLinkTarget,
|
|
84
|
+
resolveRelative,
|
|
85
|
+
prefetchAttribute,
|
|
86
|
+
viewTransitionAttribute,
|
|
87
|
+
checkTransitionName,
|
|
88
|
+
optimisticSource,
|
|
89
|
+
navigationHook,
|
|
90
|
+
navigationBlocker,
|
|
91
|
+
routeGuard,
|
|
92
|
+
createBlocker,
|
|
93
|
+
registerSnapshot,
|
|
94
|
+
setLinkState,
|
|
95
|
+
linkPending,
|
|
96
|
+
LINK_DEFAULTS,
|
|
97
|
+
linkDefaultsOf,
|
|
98
|
+
linkPrefetchProps
|
|
99
|
+
} from "hamur/adapter";
|
|
100
|
+
import { diagnosticURL, noteOutlet, prehydrate } from "hamur/adapter";
|
|
101
|
+
|
|
102
|
+
// packages/adapter-preact/src/context.ts
|
|
103
|
+
import { Component as Component2, createContext, createElement, Fragment } from "preact";
|
|
104
|
+
import { useContext, useLayoutEffect, useMemo } from "preact/hooks";
|
|
105
|
+
import { createRouterApi, layoutOf, reportClientError, routeBoundary } from "hamur/adapter";
|
|
106
|
+
|
|
107
|
+
// packages/adapter-preact/src/route-boundary.ts
|
|
108
|
+
import { Component } from "preact";
|
|
109
|
+
var rethrown = new WeakSet;
|
|
110
|
+
|
|
111
|
+
// packages/adapter-preact/src/context.ts
|
|
112
|
+
import { routeStateOf, setServerHTML, emptyServerHTML, SLOT_ELEMENT } from "hamur/adapter";
|
|
113
|
+
import { withBase } from "hamur/app";
|
|
114
|
+
var RouteContext = createContext(null);
|
|
115
|
+
var RouterContext = createContext(null);
|
|
116
|
+
var NeverHydratedContext = createContext(false);
|
|
117
|
+
var SearchContext = createContext(null);
|
|
118
|
+
var searchStores = new WeakMap;
|
|
119
|
+
var BaseURLContext = createContext("/");
|
|
120
|
+
var HrefContext = createContext((to) => {
|
|
121
|
+
if (typeof to !== "string")
|
|
122
|
+
throw new Error(`Link to the route "${to.name}" must be rendered inside a Hamur app`);
|
|
123
|
+
return withBase(to, "/");
|
|
124
|
+
});
|
|
125
|
+
var DataContext = createContext({});
|
|
126
|
+
var EntryContext = createContext(null);
|
|
127
|
+
var ErrorContext = createContext({});
|
|
128
|
+
var HeadContext = createContext(null);
|
|
129
|
+
var StateContext = createContext(null);
|
|
130
|
+
var OutletContext = createContext(null);
|
|
131
|
+
var SlotsContext = createContext(null);
|
|
132
|
+
var OutletValueContext = createContext(undefined);
|
|
133
|
+
var LayoutContext = createContext(null);
|
|
134
|
+
var ActivationContext = createContext(undefined);
|
|
135
|
+
var SubmittedContext = createContext({});
|
|
136
|
+
var FormStatusContext = createContext(null);
|
|
137
|
+
var AppContextContext = createContext(null);
|
|
138
|
+
var NavigationContext = createContext(null);
|
|
139
|
+
var LinkHrefContext = createContext(null);
|
|
140
|
+
|
|
141
|
+
// packages/adapter-preact/src/index.ts
|
|
142
|
+
import { $fetch } from "hamur/app";
|
|
143
|
+
|
|
144
|
+
// packages/adapter-preact/src/client-component.ts
|
|
145
|
+
import { createContext as createContext2, createElement as createElement2 } from "preact";
|
|
146
|
+
import { Suspense, lazy } from "preact/compat";
|
|
147
|
+
import { useContext as useContext2, useEffect, useState } from "preact/hooks";
|
|
148
|
+
var ClientOnlyContext = createContext2(null);
|
|
149
|
+
|
|
150
|
+
// packages/adapter-preact/src/index.ts
|
|
151
|
+
import { clientFallback, markWaiting as markWaiting3 } from "hamur/adapter";
|
|
152
|
+
|
|
153
|
+
// packages/adapter-preact/src/client-fallback.ts
|
|
154
|
+
var clientFallbackIds = new Set;
|
|
155
|
+
|
|
156
|
+
// packages/adapter-preact/src/head.ts
|
|
157
|
+
var mounted = new WeakMap;
|
|
158
|
+
|
|
159
|
+
// packages/adapter-preact/src/async-data.ts
|
|
160
|
+
import { isPreviewMode } from "hamur/adapter";
|
|
161
|
+
var kept = new WeakMap;
|
|
162
|
+
|
|
163
|
+
// packages/adapter-preact/src/index.ts
|
|
164
|
+
import {
|
|
165
|
+
addRouteMiddleware,
|
|
166
|
+
clearError,
|
|
167
|
+
disableScrollHandling,
|
|
168
|
+
forbidden,
|
|
169
|
+
navigateTo as navigateTo2,
|
|
170
|
+
notFound,
|
|
171
|
+
permanentRedirect,
|
|
172
|
+
refreshCookie,
|
|
173
|
+
setPageLayout,
|
|
174
|
+
showError,
|
|
175
|
+
unauthorized
|
|
176
|
+
} from "hamur/app";
|
|
177
|
+
|
|
178
|
+
// packages/adapter-preact/src/lazy-hydration.ts
|
|
179
|
+
import { createElement as createElement3 } from "preact";
|
|
180
|
+
import { Suspense as Suspense2 } from "preact/compat";
|
|
181
|
+
import { useContext as useContext3, useEffect as useEffect2, useRef, useState as useState2 } from "preact/hooks";
|
|
182
|
+
import { HYDRATE_ELEMENT, hydrateOnAttribute, markWaiting, replayInteraction, whenTriggered } from "hamur/adapter";
|
|
183
|
+
var pending = new Set;
|
|
184
|
+
// packages/adapter-preact/src/island.ts
|
|
185
|
+
import { h } from "preact";
|
|
186
|
+
import { useContext as useContext4, useId } from "preact/hooks";
|
|
187
|
+
import { ISLAND_ELEMENT, renderIsland } from "hamur/adapter";
|
|
188
|
+
|
|
189
|
+
// packages/adapter-preact/src/island-html.ts
|
|
190
|
+
import { markWaiting as markWaiting2 } from "hamur/adapter";
|
|
191
|
+
var outcomes = new WeakMap;
|
|
192
|
+
// packages/adapter-preact/src/server-island.ts
|
|
193
|
+
import { h as h2 } from "preact";
|
|
194
|
+
import { useContext as useContext5, useId as useId2, useState as useState3 } from "preact/hooks";
|
|
195
|
+
import { SERVER_ISLAND_ELEMENT, renderServerIsland, serverIslandProps } from "hamur/adapter";
|
|
196
|
+
// packages/adapter-preact/src/markdown.ts
|
|
197
|
+
import { Fragment as Fragment2, createElement as createElement4 } from "preact";
|
|
198
|
+
import { markdownLink, markdownProse, markdownView } from "hamur/adapter";
|
|
199
|
+
|
|
200
|
+
// packages/adapter-preact/src/index.ts
|
|
201
|
+
import { matchesOf, routeDataOf } from "hamur/adapter";
|
|
202
|
+
import { equalSearch, isOnline, pollInterval, searchTarget, startPoll, subscribeOnline } from "hamur/adapter";
|
|
203
|
+
import { APP_UPDATE_OFF, createAppUpdate } from "hamur/adapter";
|
|
204
|
+
var NO_DEFAULTS = {};
|
|
205
|
+
function linkElement(props, defaults) {
|
|
206
|
+
return createElement5(typeof props.children === "function" ? CustomLink : AnchorLink, {
|
|
207
|
+
link: props,
|
|
208
|
+
defaults
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function Link(props) {
|
|
212
|
+
return linkElement(props, NO_DEFAULTS);
|
|
213
|
+
}
|
|
214
|
+
function useLinkTarget(props, attrs) {
|
|
215
|
+
warnRemovedLinkProps(props);
|
|
216
|
+
const { to: target, query, relative } = props;
|
|
217
|
+
const route = useContext6(RouteContext);
|
|
218
|
+
const hrefOf = useContext6(HrefContext);
|
|
219
|
+
const app = useContext6(AppContextContext);
|
|
220
|
+
const searched = route ? searchTarget(relativeTarget(target, route, relative), route, query) : target;
|
|
221
|
+
const { to, props: rest } = resolveLinkTarget(app, searched, attrs, hrefOf, props.external);
|
|
222
|
+
return { to, route, hrefOf, href: hrefOf(to), rest };
|
|
223
|
+
}
|
|
224
|
+
function AnchorLink({ link: props, defaults }) {
|
|
225
|
+
const d = linkDefaultsOf(useContext6(AppContextContext), defaults);
|
|
226
|
+
const {
|
|
227
|
+
to: _to,
|
|
228
|
+
href: _href,
|
|
229
|
+
noPrefetch: _noPrefetch,
|
|
230
|
+
query,
|
|
231
|
+
state: entryState,
|
|
232
|
+
relative: _relative,
|
|
233
|
+
mask,
|
|
234
|
+
unmaskOnReload,
|
|
235
|
+
viewTransition,
|
|
236
|
+
replace,
|
|
237
|
+
prefetch,
|
|
238
|
+
prefetchOn,
|
|
239
|
+
activeClass = d.activeClass,
|
|
240
|
+
exactActiveClass = d.exactActiveClass,
|
|
241
|
+
pendingClass = d.pendingClass,
|
|
242
|
+
ariaCurrentValue = "page",
|
|
243
|
+
external,
|
|
244
|
+
noRel,
|
|
245
|
+
prefetchedClass = d.prefetchedClass,
|
|
246
|
+
scroll,
|
|
247
|
+
prefetchDelay = d.prefetchDelay,
|
|
248
|
+
onBeforeNavigate,
|
|
249
|
+
children,
|
|
250
|
+
...attrs
|
|
251
|
+
} = props;
|
|
252
|
+
const mode = external ? "false" : prefetchAttribute(linkPrefetchProps({ prefetch, prefetchOn }, d));
|
|
253
|
+
const baseURL = useContext6(BaseURLContext);
|
|
254
|
+
const { to, route, hrefOf, href, rest } = useLinkTarget(props, attrs);
|
|
255
|
+
const anchor = useRef2(null);
|
|
256
|
+
const appRef = rest.ref;
|
|
257
|
+
const ref = useCallback((element) => {
|
|
258
|
+
anchor.current = element;
|
|
259
|
+
if (typeof appRef !== "function")
|
|
260
|
+
return void (appRef && (appRef.current = element));
|
|
261
|
+
const cleanup = appRef(element);
|
|
262
|
+
return typeof cleanup === "function" ? () => void (anchor.current = null, cleanup()) : undefined;
|
|
263
|
+
}, [appRef]);
|
|
264
|
+
const before = useRef2(onBeforeNavigate);
|
|
265
|
+
before.current = onBeforeNavigate;
|
|
266
|
+
const hasBefore = onBeforeNavigate !== undefined;
|
|
267
|
+
useLayoutEffect2(() => {
|
|
268
|
+
const element = anchor.current;
|
|
269
|
+
if (!element || entryState === undefined && !hasBefore)
|
|
270
|
+
return;
|
|
271
|
+
setLinkState(element, entryState, hasBefore ? (nav) => before.current?.(nav) : undefined);
|
|
272
|
+
return () => setLinkState(element, undefined);
|
|
273
|
+
}, [entryState, hasBefore]);
|
|
274
|
+
const state = route ? linkState(typeof to === "string" ? to : withoutBase(href, baseURL), route) : undefined;
|
|
275
|
+
const key = "className" in rest ? "className" : "class";
|
|
276
|
+
const classes = [rest[key], state?.active && activeClass, state?.exact && exactActiveClass].filter(Boolean).join(" ");
|
|
277
|
+
return createElement5("a", {
|
|
278
|
+
...rest,
|
|
279
|
+
ref,
|
|
280
|
+
...classes ? { [key]: classes } : {},
|
|
281
|
+
...state?.exact && rest["aria-current"] === undefined ? { "aria-current": ariaCurrentValue } : {},
|
|
282
|
+
href,
|
|
283
|
+
"data-hamur-prefetch": mode,
|
|
284
|
+
"data-hamur-replace": replace ? "" : undefined,
|
|
285
|
+
"data-hamur-view-transition": viewTransitionAttribute(viewTransition),
|
|
286
|
+
"data-hamur-pending-class": pendingClass === LINK_DEFAULTS.pendingClass ? undefined : pendingClass,
|
|
287
|
+
"data-hamur-trim": query ? "" : undefined,
|
|
288
|
+
"data-hamur-mask": mask === undefined ? undefined : hrefOf(mask),
|
|
289
|
+
"data-hamur-unmask": mask !== undefined && unmaskOnReload === false ? "false" : undefined,
|
|
290
|
+
...linkExtraAttributes({
|
|
291
|
+
href,
|
|
292
|
+
external,
|
|
293
|
+
noRel,
|
|
294
|
+
rel: rest.rel,
|
|
295
|
+
target: rest.target,
|
|
296
|
+
prefetchedClass,
|
|
297
|
+
scroll,
|
|
298
|
+
prefetchDelay,
|
|
299
|
+
externalRelAttribute: d.externalRelAttribute
|
|
300
|
+
})
|
|
301
|
+
}, createElement5(LinkHrefContext.Provider, { value: href }, children));
|
|
302
|
+
}
|
|
303
|
+
function CustomLink({ link: props, defaults }) {
|
|
304
|
+
const slot = useLinkSlot(props, linkDefaultsOf(useContext6(AppContextContext), defaults));
|
|
305
|
+
return createElement5(LinkHrefContext.Provider, { value: slot.href }, props.children(slot));
|
|
306
|
+
}
|
|
307
|
+
function useLinkSlot(props, d) {
|
|
308
|
+
const {
|
|
309
|
+
state: entryState,
|
|
310
|
+
mask,
|
|
311
|
+
unmaskOnReload,
|
|
312
|
+
viewTransition,
|
|
313
|
+
replace,
|
|
314
|
+
prefetch,
|
|
315
|
+
prefetchOn,
|
|
316
|
+
pendingClass = d.pendingClass,
|
|
317
|
+
ariaCurrentValue = "page",
|
|
318
|
+
external,
|
|
319
|
+
noRel,
|
|
320
|
+
prefetchedClass = d.prefetchedClass,
|
|
321
|
+
scroll,
|
|
322
|
+
prefetchDelay = d.prefetchDelay,
|
|
323
|
+
query,
|
|
324
|
+
rel,
|
|
325
|
+
target
|
|
326
|
+
} = props;
|
|
327
|
+
const baseURL = useContext6(BaseURLContext);
|
|
328
|
+
const router = useContext6(RouterContext);
|
|
329
|
+
const navigation = useNavigation();
|
|
330
|
+
const { to, route, hrefOf, href } = useLinkTarget(props, props);
|
|
331
|
+
const state = route ? linkState(typeof to === "string" ? to : withoutBase(href, baseURL), route) : undefined;
|
|
332
|
+
return createLinkSlot({
|
|
333
|
+
href,
|
|
334
|
+
to,
|
|
335
|
+
attrs: linkAttributes({
|
|
336
|
+
href,
|
|
337
|
+
external,
|
|
338
|
+
...linkPrefetchProps({ prefetch, prefetchOn }, d),
|
|
339
|
+
replace,
|
|
340
|
+
viewTransition,
|
|
341
|
+
pendingClass,
|
|
342
|
+
trim: !!query,
|
|
343
|
+
mask: mask === undefined ? undefined : hrefOf(mask),
|
|
344
|
+
unmaskOnReload,
|
|
345
|
+
ariaCurrent: state?.exact ? ariaCurrentValue : undefined,
|
|
346
|
+
rel,
|
|
347
|
+
target,
|
|
348
|
+
noRel,
|
|
349
|
+
prefetchedClass,
|
|
350
|
+
scroll,
|
|
351
|
+
prefetchDelay,
|
|
352
|
+
externalRelAttribute: d.externalRelAttribute
|
|
353
|
+
}),
|
|
354
|
+
active: !!state?.active,
|
|
355
|
+
exact: !!state?.exact,
|
|
356
|
+
pending: linkPending(href, navigation, baseURL),
|
|
357
|
+
external,
|
|
358
|
+
options: {
|
|
359
|
+
replace,
|
|
360
|
+
state: entryState,
|
|
361
|
+
mask,
|
|
362
|
+
unmaskOnReload,
|
|
363
|
+
viewTransition,
|
|
364
|
+
scroll: scroll === false ? false : undefined
|
|
365
|
+
},
|
|
366
|
+
router
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
var isDev = import.meta.dev === true;
|
|
370
|
+
var warnedSlots = new Set;
|
|
371
|
+
var outcomes2 = new WeakMap;
|
|
372
|
+
var waits = new WeakMap;
|
|
373
|
+
var IDLE = { state: "idle", pending: false };
|
|
374
|
+
function useNavigation() {
|
|
375
|
+
const source = useContext6(NavigationContext);
|
|
376
|
+
const [navigation, setNavigation] = useLocalState(source ? source.get() : IDLE);
|
|
377
|
+
useEffect3(() => {
|
|
378
|
+
if (!source)
|
|
379
|
+
return;
|
|
380
|
+
setNavigation(source.get());
|
|
381
|
+
return source.subscribe(() => setNavigation(source.get()));
|
|
382
|
+
}, [source]);
|
|
383
|
+
return navigation;
|
|
384
|
+
}
|
|
385
|
+
function DefaultErrorPage({ error }) {
|
|
386
|
+
return createElement5("main", { style: { fontFamily: "system-ui, sans-serif", textAlign: "center", padding: "4rem 1rem" } }, createElement5("h1", { style: { fontSize: "4rem", margin: 0 } }, String(error.status)), createElement5("p", null, error.message), isDev && error.code ? createElement5("p", null, createElement5("a", { href: diagnosticURL(error.code), target: "_blank", rel: "noopener" }, error.code)) : null, error.stack ? createElement5("pre", { style: { textAlign: "left", overflow: "auto" } }, error.stack) : null, createElement5(Link, { to: "/" }, "Back home"));
|
|
387
|
+
}
|
|
388
|
+
var pendingApply = new WeakSet;
|
|
389
|
+
export {
|
|
390
|
+
DefaultErrorPage as default
|
|
391
|
+
};
|