@void/react 1.7.0 → 1.8.0
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/dist/index.d.mts +3 -2
- package/dist/index.mjs +4 -4
- package/dist/plugin.mjs +4 -1
- package/dist/runtime/pages-client.d.mts +3 -1
- package/dist/runtime/pages-client.mjs +120 -13
- package/dist/runtime/pages-server.mjs +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -26,6 +26,6 @@ export default defineConfig({
|
|
|
26
26
|
|
|
27
27
|
## Documentation
|
|
28
28
|
|
|
29
|
-
Follow [Pages Routing](https://void.cloud/guide/pages-routing/overview) to add pages, then use [loaders](https://void.cloud/guide/pages-routing/loaders), [forms](https://void.cloud/guide/pages-routing/actions-and-forms), and [layouts](https://void.cloud/guide/pages-routing/layouts). See the [adapter API reference](https://void.cloud/reference/api/pages) for plugin options and runtime helpers.
|
|
29
|
+
Follow [Pages Routing](https://void.cloud/guide/pages-routing/overview) to add pages, then use [loaders](https://void.cloud/guide/pages-routing/loaders), [forms](https://void.cloud/guide/pages-routing/actions-and-forms), and [layouts](https://void.cloud/guide/pages-routing/layouts). Use [not-found and error components](https://void.cloud/guide/pages-routing/errors) to recover inside your layouts. See the [adapter API reference](https://void.cloud/reference/api/pages) for plugin options and runtime helpers.
|
|
30
30
|
|
|
31
31
|
Read the [Void documentation](https://void.cloud) online or use the Markdown guides and references in `node_modules/void/docs/`, included with the `void` package.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes, ButtonHTMLAttributes, Context, FormHTMLAttributes, JSX, ReactElement, ReactNode } from "react";
|
|
2
|
-
import { ActionClient, BaseLinkProps, FormMethod, FormModel, FormState, IslandFormState, NavigationState, VoidActionError, VoidActionError as VoidActionError$1, VoidRouter, isCallSiteActionError, isVoidActionError } from "void/pages-client";
|
|
2
|
+
import { ActionClient, ActionResult, BaseLinkProps, ErrorPageProps, FormMethod, FormModel, FormState, IslandFormState, NavigationState, PageError, VoidActionError, VoidActionError as VoidActionError$1, VoidRouter, getValidationErrors, isCallSiteActionError, isVoidActionError } from "void/pages-client";
|
|
3
3
|
import { ActionFormOptions, ActionUrl, PageParams, PagePath, ResolveActionBody } from "void/routes";
|
|
4
4
|
import { CloudContextVariables, InferProps } from "void";
|
|
5
5
|
type FormProps = Omit<FormHTMLAttributes<HTMLFormElement>, "action" | "onSubmit" | "method" | "onError"> & {
|
|
@@ -32,6 +32,7 @@ type FormReturn<TData> = FormState<TData, "setters"> & Readonly<{
|
|
|
32
32
|
type FormOptions = {
|
|
33
33
|
params?: Record<string, string>;
|
|
34
34
|
resetOnSuccess?: boolean;
|
|
35
|
+
throwOnError?: boolean;
|
|
35
36
|
preserveScroll?: boolean;
|
|
36
37
|
onSuccess?: () => void | Promise<void>;
|
|
37
38
|
onError?: (error: Record<string, string> | VoidActionError$1) => void | Promise<void>;
|
|
@@ -55,4 +56,4 @@ export declare const RouterContext: Context<VoidRouter | null>;
|
|
|
55
56
|
export declare const NavigationContext: Context<NavigationState>;
|
|
56
57
|
export declare const FrontmatterContext: Context<Record<string, unknown>>;
|
|
57
58
|
export type Deferred<T> = Promise<T>;
|
|
58
|
-
export { type InferProps, type VoidActionError, isCallSiteActionError, isVoidActionError };
|
|
59
|
+
export { type ActionResult, type ErrorPageProps, type InferProps, type PageError, type VoidActionError, getValidationErrors, isCallSiteActionError, isVoidActionError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as RouterContext, i as ParamsContext, n as FrontmatterContext, o as SharedContext, r as NavigationContext, t as ErrorsContext } from "./context-BQpawTZc.mjs";
|
|
2
2
|
import { n as setActionRouter, t as action } from "./action-CyCVdW12.mjs";
|
|
3
3
|
import { useActionState, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { cloneFormValue, formErrorMessage, formRetryMessage, formSubmissionBlocked, getValidationErrors, handleLinkClick, interpolateRouteParams, isAbortError, isCallSiteActionError, isEqualFormValue, isVoidActionError, linkActiveAttributes, linkPendingAttributes, linkPrefetchStrategies, observeLinkVisible, parseFormResetArgs, prefetchLink, resolveLink, ssrProxy, submitAction, submitIslandAction } from "void/pages-client";
|
|
4
|
+
import { cloneFormValue, formErrorMessage, formRetryMessage, formSubmissionBlocked, getValidationErrors, getValidationErrors as getValidationErrors$1, handleLinkClick, interpolateRouteParams, isAbortError, isCallSiteActionError, isCallSiteActionError as isCallSiteActionError$1, isEqualFormValue, isVoidActionError, linkActiveAttributes, linkPendingAttributes, linkPrefetchStrategies, observeLinkVisible, parseFormResetArgs, prefetchLink, resolveLink, ssrProxy, submitAction, submitIslandAction } from "void/pages-client";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
// src/runtime/form.tsx
|
|
7
7
|
function Form({ form, method = "post", renderError, children, ...props }) {
|
|
@@ -238,7 +238,7 @@ function useForm(url, defaults, options) {
|
|
|
238
238
|
data: payload.snapshot,
|
|
239
239
|
preserveScroll: options?.preserveScroll,
|
|
240
240
|
_resolveOnShell: true
|
|
241
|
-
});
|
|
241
|
+
}, options);
|
|
242
242
|
} catch (submitError) {
|
|
243
243
|
if (isAbortError(submitError)) return {
|
|
244
244
|
status: "idle",
|
|
@@ -247,7 +247,7 @@ function useForm(url, defaults, options) {
|
|
|
247
247
|
throw submitError;
|
|
248
248
|
}
|
|
249
249
|
if (!result.ok) {
|
|
250
|
-
const validationErrors = getValidationErrors(result.error.body);
|
|
250
|
+
const validationErrors = isCallSiteActionError$1(result.error) ? getValidationErrors$1(result.error.body) : null;
|
|
251
251
|
if (validationErrors) return runErrorCallback({
|
|
252
252
|
status: "validation",
|
|
253
253
|
defaults: previousOutcome.defaults,
|
|
@@ -528,4 +528,4 @@ function useIslandForm(defaults) {
|
|
|
528
528
|
delete: (url) => submit(url, "DELETE")
|
|
529
529
|
};
|
|
530
530
|
}
|
|
531
|
-
export { ErrorsContext, Form, FrontmatterContext, Link, NavigationContext, ParamsContext, RouterContext, SharedContext, action, isCallSiteActionError, isVoidActionError, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
|
|
531
|
+
export { ErrorsContext, Form, FrontmatterContext, Link, NavigationContext, ParamsContext, RouterContext, SharedContext, action, getValidationErrors, isCallSiteActionError, isVoidActionError, setActionRouter, useForm, useIslandForm, useNavigation, useParams, useRouter, useShared };
|
package/dist/plugin.mjs
CHANGED
|
@@ -90,7 +90,8 @@ function pagesPlugin(pagesDir, options) {
|
|
|
90
90
|
include: [...WORKER_OPTIMIZE_DEPS, ...installedDependencies(["void/live/client"])]
|
|
91
91
|
} } }
|
|
92
92
|
};
|
|
93
|
-
|
|
93
|
+
const pageScan = await scan();
|
|
94
|
+
if (!pageScan?.pages.some((page) => !page.island) && !pageScan?.boundaries?.some((boundary) => boundary.kind === "not-found" && !boundary.directory)) return;
|
|
94
95
|
return {
|
|
95
96
|
resolve: { dedupe: REACT_DEDUPE },
|
|
96
97
|
build: {
|
|
@@ -174,6 +175,8 @@ function generateClientEntry(scan, pagesDir, viewTransitions, prefetch, staticPa
|
|
|
174
175
|
components,
|
|
175
176
|
layoutTree,
|
|
176
177
|
routeMeta,
|
|
178
|
+
boundaryManifest,
|
|
179
|
+
dev: import.meta.env.DEV,
|
|
177
180
|
matchRoute,
|
|
178
181
|
staticPageData: ${!!staticPageData?.enabled},
|
|
179
182
|
staticPageDataFastPath: ${!!staticPageData?.fastPath},
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ComponentType } from "react";
|
|
2
|
-
import { VoidRouter } from "void/pages-client";
|
|
2
|
+
import { BoundaryManifest, VoidRouter } from "void/pages-client";
|
|
3
3
|
import { CacheForResult, LinkPrefetchValue } from "void/pages-prefetch";
|
|
4
4
|
import { PageObject } from "void/pages-protocol";
|
|
5
5
|
type ComponentModule = {
|
|
6
6
|
default: ComponentType<any>;
|
|
7
7
|
};
|
|
8
8
|
export type ReactPagesConfig = Readonly<{
|
|
9
|
+
boundaryManifest?: BoundaryManifest;
|
|
10
|
+
dev?: boolean;
|
|
9
11
|
components: Record<string, () => Promise<ComponentModule>>;
|
|
10
12
|
layoutTree: Record<string, Array<string>>;
|
|
11
13
|
routeMeta: Record<string, {
|
|
@@ -1,15 +1,61 @@
|
|
|
1
1
|
import { n as setActionRouter } from "../action-CyCVdW12.mjs";
|
|
2
2
|
import { a as RouterContext, i as ParamsContext, o as SharedContext, r as NavigationContext, t as ErrorsContext } from "../context-BQpawTZc.mjs";
|
|
3
3
|
import { n as DEFERRED_SHELL_END_ID } from "../deferred-shell-D5T32zXz.mjs";
|
|
4
|
-
import React, { Suspense, startTransition, use, useCallback, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useState, useTransition } from "react";
|
|
5
|
-
import { createPageNavigationEngine, createRouterFacade, idleNavigationState, isAbortError, isCallSiteActionError, refreshPage, toUrlString } from "void/pages-client";
|
|
4
|
+
import React, { Component, Suspense, lazy, startTransition, use, useCallback, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useState, useSyncExternalStore, useTransition } from "react";
|
|
5
|
+
import { clientPageError, createPageNavigationEngine, createRouterFacade, idleNavigationState, isAbortError, isCallSiteActionError, pageBoundarySlots, refreshPage, showTerminalPageError, toUrlString } from "void/pages-client";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
8
|
+
// src/runtime/PageErrorBoundary.tsx
|
|
9
|
+
const fallbacks = /* @__PURE__ */ new Map();
|
|
10
|
+
function fallbackFor(boundary) {
|
|
11
|
+
let fallback = fallbacks.get(boundary.id);
|
|
12
|
+
if (!fallback) {
|
|
13
|
+
fallback = lazy(boundary.load);
|
|
14
|
+
fallbacks.set(boundary.id, fallback);
|
|
15
|
+
}
|
|
16
|
+
return fallback;
|
|
17
|
+
}
|
|
18
|
+
/** Native boundaries recover only descendants, so fallback failures reach the parent. */
|
|
19
|
+
var PageErrorBoundary = class extends Component {
|
|
20
|
+
state = {
|
|
21
|
+
generation: this.props.generation,
|
|
22
|
+
error: null,
|
|
23
|
+
failed: false
|
|
24
|
+
};
|
|
25
|
+
static getDerivedStateFromProps(props, state) {
|
|
26
|
+
return props.generation !== state.generation ? {
|
|
27
|
+
generation: props.generation,
|
|
28
|
+
error: null,
|
|
29
|
+
failed: false
|
|
30
|
+
} : null;
|
|
31
|
+
}
|
|
32
|
+
static getDerivedStateFromError(error) {
|
|
33
|
+
return {
|
|
34
|
+
error,
|
|
35
|
+
failed: true
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
componentDidCatch() {
|
|
39
|
+
this.props.onFailure();
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
if (this.state.failed) {
|
|
43
|
+
const Fallback = fallbackFor(this.props.boundary);
|
|
44
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
45
|
+
fallback: null,
|
|
46
|
+
children: /* @__PURE__ */ jsx(Fallback, { error: clientPageError(this.state.error, this.props.dev) })
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return this.props.children;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
7
52
|
// src/runtime/pages-client.ts
|
|
8
53
|
const deferredState = /* @__PURE__ */ new WeakMap();
|
|
9
54
|
const viewTransitionWaiters = /* @__PURE__ */ new Map();
|
|
10
55
|
const pendingVisitSettlers = /* @__PURE__ */ new Map();
|
|
11
56
|
const committedResources = /* @__PURE__ */ new Set();
|
|
12
57
|
const EMPTY_PARAMS = {};
|
|
58
|
+
let terminalResource = null;
|
|
13
59
|
let activePendingNavigationId = null;
|
|
14
60
|
let prerenderedUrl = null;
|
|
15
61
|
let scheduleVisit = null;
|
|
@@ -174,7 +220,7 @@ function createRouter(engine) {
|
|
|
174
220
|
};
|
|
175
221
|
return router;
|
|
176
222
|
}
|
|
177
|
-
function RouteResource({ resource, onCommit }) {
|
|
223
|
+
function RouteResource({ resource, onCommit, config, onFailure }) {
|
|
178
224
|
const result = use(resource.shell);
|
|
179
225
|
const outerRouter = React.useContext(RouterContext);
|
|
180
226
|
useLayoutEffect(() => {
|
|
@@ -206,11 +252,23 @@ function RouteResource({ resource, onCommit }) {
|
|
|
206
252
|
]);
|
|
207
253
|
if (!result || !pageData) return null;
|
|
208
254
|
const PageComponent = result.component;
|
|
255
|
+
const boundaries = pageBoundarySlots(config.boundaryManifest, pageData.component, config.components);
|
|
256
|
+
const wrap = (element, depth) => boundaries.filter((b) => b.depth === depth).reduce((child, boundary) => React.createElement(PageErrorBoundary, {
|
|
257
|
+
boundary,
|
|
258
|
+
key: boundary.key,
|
|
259
|
+
generation: resource.id,
|
|
260
|
+
dev: config.dev,
|
|
261
|
+
onFailure: () => {
|
|
262
|
+
onFailure(resource.fetchUrl);
|
|
263
|
+
if (resource.resolvedUrl) onFailure(resource.resolvedUrl);
|
|
264
|
+
}
|
|
265
|
+
}, child), element);
|
|
209
266
|
let element = React.createElement(PageComponent, pageData.props);
|
|
210
267
|
for (let i = result.layouts.length - 1; i >= 0; i--) {
|
|
211
268
|
const Layout = result.layouts[i];
|
|
212
|
-
element = React.createElement(Layout, null, element);
|
|
269
|
+
element = React.createElement(Layout, null, wrap(element, i + 1));
|
|
213
270
|
}
|
|
271
|
+
element = wrap(element, 0);
|
|
214
272
|
return React.createElement(RouterContext.Provider, { value: routeRouter }, React.createElement(ParamsContext.Provider, { value: routeParams }, React.createElement(SharedContext.Provider, { value: pageData.shared ?? {} }, React.createElement(ErrorsContext.Provider, { value: pageData.errors ?? {} }, element))));
|
|
215
273
|
}
|
|
216
274
|
function startViewTransition(resource, reveal, enabled) {
|
|
@@ -228,7 +286,7 @@ function startViewTransition(resource, reveal, enabled) {
|
|
|
228
286
|
return readyForCapture;
|
|
229
287
|
});
|
|
230
288
|
}
|
|
231
|
-
function App({ engine, router, viewTransitions, navigationFallback: NavigationFallback }) {
|
|
289
|
+
function App({ config, engine, router, viewTransitions, navigationFallback: NavigationFallback }) {
|
|
232
290
|
const initialPageData = engine.initialPageData;
|
|
233
291
|
const [hydrated, setHydrated] = useState(prerenderedUrl === null);
|
|
234
292
|
const initialResource = useMemo(() => ({
|
|
@@ -264,6 +322,22 @@ function App({ engine, router, viewTransitions, navigationFallback: NavigationFa
|
|
|
264
322
|
navigation: idleNavigationState()
|
|
265
323
|
});
|
|
266
324
|
const [isTransitionPending, startTransition] = useTransition();
|
|
325
|
+
const [navigationStore] = useState(() => {
|
|
326
|
+
let snapshot = idleNavigationState();
|
|
327
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
328
|
+
return {
|
|
329
|
+
getSnapshot: () => snapshot,
|
|
330
|
+
subscribe(listener) {
|
|
331
|
+
listeners.add(listener);
|
|
332
|
+
return () => listeners.delete(listener);
|
|
333
|
+
},
|
|
334
|
+
set(navigation) {
|
|
335
|
+
snapshot = navigation;
|
|
336
|
+
for (const listener of listeners) listener();
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
});
|
|
340
|
+
const lastNavigation = useSyncExternalStore(navigationStore.subscribe, navigationStore.getSnapshot, navigationStore.getSnapshot);
|
|
267
341
|
const finishNavigation = useCallback((resource, result) => {
|
|
268
342
|
if (committedResources.has(resource.id)) return;
|
|
269
343
|
committedResources.add(resource.id);
|
|
@@ -311,6 +385,7 @@ function App({ engine, router, viewTransitions, navigationFallback: NavigationFa
|
|
|
311
385
|
const resolveOnData = prepared.options.resolveOn === "data" || prepared.options._resolveOnShell;
|
|
312
386
|
if (prepared.immediate) {
|
|
313
387
|
const navigation = navigationForResource(prepared);
|
|
388
|
+
navigationStore.set(navigation);
|
|
314
389
|
activePendingNavigationId = prepared.id;
|
|
315
390
|
dispatch({
|
|
316
391
|
type: "begin",
|
|
@@ -343,6 +418,9 @@ function App({ engine, router, viewTransitions, navigationFallback: NavigationFa
|
|
|
343
418
|
});
|
|
344
419
|
const next = {
|
|
345
420
|
...prepared,
|
|
421
|
+
get resolvedUrl() {
|
|
422
|
+
return prepared.resolvedUrl;
|
|
423
|
+
},
|
|
346
424
|
shell: prepared.shell.then((result) => {
|
|
347
425
|
if (!result) {
|
|
348
426
|
const resolveViewTransition = viewTransitionWaiters.get(prepared.id);
|
|
@@ -390,6 +468,8 @@ function App({ engine, router, viewTransitions, navigationFallback: NavigationFa
|
|
|
390
468
|
})
|
|
391
469
|
};
|
|
392
470
|
const navigation = navigationForResource(next);
|
|
471
|
+
navigationStore.set(navigation);
|
|
472
|
+
terminalResource = next;
|
|
393
473
|
pendingVisitSettlers.set(next.id, {
|
|
394
474
|
resolve: resolveVisit,
|
|
395
475
|
reject: rejectVisit
|
|
@@ -439,6 +519,7 @@ function App({ engine, router, viewTransitions, navigationFallback: NavigationFa
|
|
|
439
519
|
}, [
|
|
440
520
|
engine,
|
|
441
521
|
NavigationFallback,
|
|
522
|
+
navigationStore,
|
|
442
523
|
startTransition,
|
|
443
524
|
viewTransitions
|
|
444
525
|
]);
|
|
@@ -456,11 +537,14 @@ function App({ engine, router, viewTransitions, navigationFallback: NavigationFa
|
|
|
456
537
|
const navigationValue = useMemo(() => {
|
|
457
538
|
if (state.navigation.state !== "idle" || !isTransitionPending) return state.navigation;
|
|
458
539
|
return {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
method: "GET"
|
|
540
|
+
...lastNavigation,
|
|
541
|
+
state: "loading"
|
|
462
542
|
};
|
|
463
|
-
}, [
|
|
543
|
+
}, [
|
|
544
|
+
isTransitionPending,
|
|
545
|
+
lastNavigation,
|
|
546
|
+
state.navigation
|
|
547
|
+
]);
|
|
464
548
|
const routerValue = useMemo(() => createRouterFacade(router, () => hydrated ? state.routeUrl : prerenderedUrl ?? state.routeUrl), [
|
|
465
549
|
router,
|
|
466
550
|
state.routeUrl,
|
|
@@ -468,10 +552,13 @@ function App({ engine, router, viewTransitions, navigationFallback: NavigationFa
|
|
|
468
552
|
]);
|
|
469
553
|
return React.createElement(RouterContext.Provider, { value: routerValue }, React.createElement(NavigationContext.Provider, { value: navigationValue }, React.createElement(Suspense, { fallback: NavigationFallback && state.pendingId !== null ? React.createElement(NavigationFallback, { initialPageData }) : null }, React.createElement(RouteResource, {
|
|
470
554
|
resource: state.resource,
|
|
471
|
-
onCommit: finishNavigation
|
|
555
|
+
onCommit: finishNavigation,
|
|
556
|
+
config,
|
|
557
|
+
onFailure: (url) => engine.flush(url)
|
|
472
558
|
}))));
|
|
473
559
|
}
|
|
474
560
|
async function startReactPages(config) {
|
|
561
|
+
terminalResource = null;
|
|
475
562
|
viewTransitionWaiters.clear();
|
|
476
563
|
pendingVisitSettlers.clear();
|
|
477
564
|
committedResources.clear();
|
|
@@ -494,7 +581,12 @@ async function startReactPages(config) {
|
|
|
494
581
|
prefetchHoverDelay: config.prefetchHoverDelay,
|
|
495
582
|
prefetchDefaultCacheFor: config.prefetchDefaultCacheFor,
|
|
496
583
|
prefetchDefaultStrategy: config.prefetchDefaultStrategy,
|
|
497
|
-
cacheVisitedPageData: config.cacheVisitedPageData
|
|
584
|
+
cacheVisitedPageData: config.cacheVisitedPageData,
|
|
585
|
+
boundaryManifest: config.boundaryManifest,
|
|
586
|
+
dev: config.dev
|
|
587
|
+
}).catch((error) => {
|
|
588
|
+
if (config.boundaryManifest && Object.keys(config.boundaryManifest.plans).length) showTerminalPageError();
|
|
589
|
+
throw error;
|
|
498
590
|
});
|
|
499
591
|
const router = createRouter(engine);
|
|
500
592
|
setActionRouter(router);
|
|
@@ -503,6 +595,7 @@ async function startReactPages(config) {
|
|
|
503
595
|
const isSsr = appEl.getAttribute("data-void-ssr") !== "false";
|
|
504
596
|
if (isSsr) prerenderedUrl = prerenderedRouteUrl(engine.initialPageData);
|
|
505
597
|
const appRoot = React.createElement(App, {
|
|
598
|
+
config,
|
|
506
599
|
engine,
|
|
507
600
|
router,
|
|
508
601
|
viewTransitions: config.viewTransitions,
|
|
@@ -511,8 +604,22 @@ async function startReactPages(config) {
|
|
|
511
604
|
const hasDeferred = Boolean(engine.initialPageData.deferredKeys);
|
|
512
605
|
const app = isSsr && hasDeferred ? React.createElement(React.Fragment, null, appRoot, React.createElement("template", { id: DEFERRED_SHELL_END_ID })) : appRoot;
|
|
513
606
|
startTransition(() => {
|
|
514
|
-
|
|
515
|
-
|
|
607
|
+
const rootOptions = config.boundaryManifest && Object.keys(config.boundaryManifest.plans).length ? { onUncaughtError: (error) => {
|
|
608
|
+
const resource = terminalResource;
|
|
609
|
+
if (resource) {
|
|
610
|
+
resource.dispose();
|
|
611
|
+
engine.flush(resource.fetchUrl);
|
|
612
|
+
engine.flush(resource.resolvedUrl ?? resource.fetchUrl);
|
|
613
|
+
}
|
|
614
|
+
for (const settler of pendingVisitSettlers.values()) settler.reject(error);
|
|
615
|
+
pendingVisitSettlers.clear();
|
|
616
|
+
for (const resolve of viewTransitionWaiters.values()) resolve();
|
|
617
|
+
viewTransitionWaiters.clear();
|
|
618
|
+
activePendingNavigationId = null;
|
|
619
|
+
showTerminalPageError(resource ? resource.resolvedUrl ?? resource.fetchUrl + resource.hash : currentUrl());
|
|
620
|
+
} } : void 0;
|
|
621
|
+
if (!isSsr) createRoot(appEl, rootOptions).render(app);
|
|
622
|
+
else hydrateRoot(appEl, app, rootOptions);
|
|
516
623
|
});
|
|
517
624
|
engine.start();
|
|
518
625
|
return { router };
|
|
@@ -145,7 +145,7 @@ async function renderReactPage({ pageObj, assetTags, components, layoutTree, req
|
|
|
145
145
|
<html${htmlAttrs}>
|
|
146
146
|
<head>${headHtml}${preambleScript}${assetTags.css}${assetTags.preloads}</head>
|
|
147
147
|
<body${bodyAttrs}>
|
|
148
|
-
|
|
148
|
+
${pageObj.documentOnly ? "" : `<script id="__VOID_PAGE_DATA__" type="application/json">${pageData}<\/script>`}
|
|
149
149
|
<div id="app">`),
|
|
150
150
|
renderedAppStream,
|
|
151
151
|
textStream(`</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "React pages, server rendering, forms, and navigation for Void.",
|
|
5
5
|
"homepage": "https://void.cloud",
|
|
6
6
|
"bugs": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@vitejs/plugin-react": "^6.
|
|
41
|
+
"@vitejs/plugin-react": "^6.3.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^26.6.6",
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"pathslash": "^0.1.0",
|
|
49
49
|
"react": "^19.3.1",
|
|
50
50
|
"react-dom": "^19.3.1",
|
|
51
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@1.
|
|
52
|
-
"vite-plus": "1.
|
|
53
|
-
"void": "1.
|
|
51
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.6.0",
|
|
52
|
+
"vite-plus": "1.6.0",
|
|
53
|
+
"void": "1.8.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^19.0.0",
|
|
57
57
|
"react-dom": "^19.0.0",
|
|
58
58
|
"vite": "^8.0.0",
|
|
59
|
-
"void": "1.
|
|
59
|
+
"void": "1.8.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "vp pack",
|