@rsc-kit/core 0.30.34 → 0.30.35
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.
|
@@ -13,6 +13,13 @@ import type { ReactNode } from "react";
|
|
|
13
13
|
* under the SegmentBoundary above it, which carries one; a slot of the root
|
|
14
14
|
* layout sits under nothing, and without this its redirect would unmount
|
|
15
15
|
* the document.
|
|
16
|
+
*
|
|
17
|
+
* A refresh is swapped in as a transition. Read through useSyncExternalStore it
|
|
18
|
+
* was applied at once - React never treats that store's update as one it can
|
|
19
|
+
* hold back - so content still arriving suspended to the nearest fallback, and
|
|
20
|
+
* a team picker and its breadcrumb blinked to their skeleton on every save.
|
|
21
|
+
* Held in this boundary's state instead, React keeps what is on screen until
|
|
22
|
+
* the new content is ready, and one that is ready shows at once.
|
|
16
23
|
*/
|
|
17
24
|
export declare function SlotBoundary({ name, children }: {
|
|
18
25
|
name: string;
|
package/dist/js/SlotBoundary.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useContext,
|
|
3
|
+
import { startTransition, useContext, useEffect, useState } from "react";
|
|
4
4
|
import { getSlotState, subscribeToSlot } from "./slotStore";
|
|
5
5
|
import { RedirectBoundary } from "./RedirectBoundary";
|
|
6
6
|
import { SegmentDepthContext } from "./segmentDepth";
|
|
@@ -18,11 +18,26 @@ import { SegmentDepthContext } from "./segmentDepth";
|
|
|
18
18
|
* under the SegmentBoundary above it, which carries one; a slot of the root
|
|
19
19
|
* layout sits under nothing, and without this its redirect would unmount
|
|
20
20
|
* the document.
|
|
21
|
+
*
|
|
22
|
+
* A refresh is swapped in as a transition. Read through useSyncExternalStore it
|
|
23
|
+
* was applied at once - React never treats that store's update as one it can
|
|
24
|
+
* hold back - so content still arriving suspended to the nearest fallback, and
|
|
25
|
+
* a team picker and its breadcrumb blinked to their skeleton on every save.
|
|
26
|
+
* Held in this boundary's state instead, React keeps what is on screen until
|
|
27
|
+
* the new content is ready, and one that is ready shows at once.
|
|
21
28
|
*/
|
|
22
29
|
export function SlotBoundary({ name, children }) {
|
|
23
30
|
// Which navigation replaces this region - see clearSlots.
|
|
24
31
|
const depth = useContext(SegmentDepthContext);
|
|
25
|
-
const state
|
|
32
|
+
const [state, setState] = useState(() => getSlotState(name));
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const sync = () => startTransition(() => setState(getSlotState(name)));
|
|
35
|
+
const unsubscribe = subscribeToSlot(name, sync, depth);
|
|
36
|
+
// A write between the render and this subscription would otherwise wait
|
|
37
|
+
// for the next one.
|
|
38
|
+
sync();
|
|
39
|
+
return unsubscribe;
|
|
40
|
+
}, [name, depth]);
|
|
26
41
|
return (_jsx(RedirectBoundary, { children: (state.tree === undefined ? children : state.tree) }));
|
|
27
42
|
}
|
|
28
43
|
//# sourceMappingURL=SlotBoundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlotBoundary.js","sourceRoot":"","sources":["../../src/js/SlotBoundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"SlotBoundary.js","sourceRoot":"","sources":["../../src/js/SlotBoundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAyC;IACpF,0DAA0D;IAC1D,MAAM,KAAK,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAE7D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvE,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAEvD,wEAAwE;QACxE,oBAAoB;QACpB,IAAI,EAAE,CAAC;QAEP,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAElB,OAAO,CACL,KAAC,gBAAgB,cACd,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAc,GAC/C,CACpB,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport { startTransition, useContext, useEffect, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { getSlotState, subscribeToSlot } from \"./slotStore\";\nimport { RedirectBoundary } from \"./RedirectBoundary\";\nimport { SegmentDepthContext } from \"./segmentDepth\";\n\n/**\n * The seam a re-rendered slot is swapped in at.\n *\n * Server components cannot be re-rendered in the browser, so the swap point\n * has to be a client component reading from a store. With nothing stored it\n * renders what the server sent with the page — which is the behaviour that\n * existed before slots could be revalidated, and is what makes this safe to\n * wrap every slot in.\n *\n * Inside a RedirectBoundary, because a slot is a page too and may decide a\n * redirect inside its own Suspense boundary. A slot of a nested layout sits\n * under the SegmentBoundary above it, which carries one; a slot of the root\n * layout sits under nothing, and without this its redirect would unmount\n * the document.\n *\n * A refresh is swapped in as a transition. Read through useSyncExternalStore it\n * was applied at once - React never treats that store's update as one it can\n * hold back - so content still arriving suspended to the nearest fallback, and\n * a team picker and its breadcrumb blinked to their skeleton on every save.\n * Held in this boundary's state instead, React keeps what is on screen until\n * the new content is ready, and one that is ready shows at once.\n */\nexport function SlotBoundary({ name, children }: { name: string; children: ReactNode }) {\n // Which navigation replaces this region - see clearSlots.\n const depth = useContext(SegmentDepthContext);\n const [state, setState] = useState(() => getSlotState(name));\n\n useEffect(() => {\n const sync = () => startTransition(() => setState(getSlotState(name)));\n const unsubscribe = subscribeToSlot(name, sync, depth);\n\n // A write between the render and this subscription would otherwise wait\n // for the next one.\n sync();\n\n return unsubscribe;\n }, [name, depth]);\n\n return (\n <RedirectBoundary>\n {(state.tree === undefined ? children : state.tree) as ReactNode}\n </RedirectBoundary>\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsc-kit/core",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.35",
|
|
4
4
|
"description": "React Server Components as a Vite plugin. Routing, streaming, server actions, typed urls and build-time prerendering — deploy to Bun, Node, Workers, Vercel or Deno.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|