@pylonsync/functions 0.3.270 → 0.3.271

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pylonsync/functions",
3
- "version": "0.3.270",
3
+ "version": "0.3.271",
4
4
  "description": "TypeScript function runtime for pylon — defines server-side queries, mutations, and actions.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -270,6 +270,13 @@ function buildTree(Page, Layouts, props) {
270
270
  // ---------------------------------------------------------------------------
271
271
 
272
272
  let navEpoch = 0;
273
+ // The props the active page was rendered with (auth, serverData, params, …).
274
+ // The boundary reuses them so a boundary module AND its layout chain — e.g. an
275
+ // auth-guarding dashboard layout that reads props.auth — render with the SAME
276
+ // context the page had. The server renders boundaries with the page props too;
277
+ // a minimal hand-built props object would make such a layout see no auth and
278
+ // (for instance) redirect to /login instead of showing the not-found page.
279
+ let currentPageProps = {};
273
280
 
274
281
  // Walk up the active route's component path to the nearest boundary module
275
282
  // (<dir>/not-found or <dir>/error) present in the manifest. Manifest route
@@ -372,14 +379,12 @@ function BoundaryView(props) {
372
379
  }, [component, kind]);
373
380
  if (!resolved) return null;
374
381
  if (resolved.missing) return createElement(DefaultBoundary, { kind });
375
- const bProps = {
376
- params: currentParams,
377
- searchParams: Object.fromEntries(new URLSearchParams(location.search)),
378
- url: location.pathname + location.search,
379
- reset,
380
- };
381
- // error.tsx receives the SAFE error projection (message + digest) — never a
382
- // raw Error/stack, matching the server boundary's #270 posture.
382
+ // Reuse the page's props (auth, serverData, params, url, …) so the boundary's
383
+ // layout chain renders with the SAME context the page had — an auth-guarding
384
+ // layout that reads props.auth must not see undefined and redirect away. Add
385
+ // reset (+ the SAFE error projection for error.tsx — message + digest only,
386
+ // never a raw Error/stack, matching the server boundary's #270 posture).
387
+ const bProps = { ...currentPageProps, reset };
383
388
  if (kind === "error" && error) {
384
389
  bProps.error = {
385
390
  message: String((error && error.message) || error),
@@ -632,8 +637,9 @@ export function hydrate(component, Page, Layouts) {
632
637
  return;
633
638
  }
634
639
  setNavParams(data);
640
+ currentPageProps = withClientProps(data);
635
641
  const tree = withBoundary(
636
- buildTree(Page, Layouts, withClientProps(data)),
642
+ buildTree(Page, Layouts, currentPageProps),
637
643
  data.component,
638
644
  );
639
645
  activeRoot = hydrateRoot(document, tree);
@@ -713,8 +719,9 @@ async function navigate(href, opts) {
713
719
  syncHeadMeta(doc);
714
720
  setNavParams(data);
715
721
  navEpoch++;
722
+ currentPageProps = withClientProps(data);
716
723
  const tree = withBoundary(
717
- buildTree(route.Page, route.Layouts, withClientProps(data)),
724
+ buildTree(route.Page, route.Layouts, currentPageProps),
718
725
  data.component,
719
726
  );
720
727
  activeRoot.render(tree);