@vitejs/plugin-rsc 0.4.34 → 0.5.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/dist/{browser-CQv7Z3J4.d.ts → browser-STIFJSFF.d.ts} +1 -1
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +19 -1
- package/dist/{cjs-BamOAUgw.js → cjs-C5-IrxV9.js} +1 -1
- package/dist/core/browser.d.ts +1 -1
- package/dist/core/plugin.js +1 -1
- package/dist/core/rsc.d.ts +2 -2
- package/dist/core/rsc.js +1 -1
- package/dist/core/ssr.d.ts +2 -2
- package/dist/core/ssr.js +1 -1
- package/dist/{encryption-runtime-DT6dtlC5.js → encryption-runtime-FhNKiASK.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/{plugin-BLedJFh7.js → plugin-CrduXSyi.js} +6 -14
- package/dist/{plugin-DCLI7Wh8.d.ts → plugin-DGhnAIi6.d.ts} +1 -5
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.js +7 -7
- package/dist/plugins/cjs.js +2 -2
- package/dist/react/browser.d.ts +3 -3
- package/dist/react/rsc.d.ts +3 -3
- package/dist/react/rsc.js +2 -2
- package/dist/react/ssr.d.ts +3 -3
- package/dist/react/ssr.js +2 -2
- package/dist/{rsc-3bkzqdsJ.d.ts → rsc-Cg31p8XR.d.ts} +1 -1
- package/dist/{rsc-BdCB3621.js → rsc-DdBcg-Lb.js} +1 -1
- package/dist/rsc.d.ts +4 -4
- package/dist/rsc.js +22 -5
- package/dist/{ssr-CMjeQ9AS.d.ts → ssr-00tY_Tdf.d.ts} +1 -1
- package/dist/{ssr-Cd4SbAaO.js → ssr-CE8X2HyS.js} +1 -1
- package/dist/ssr.d.ts +3 -3
- package/dist/ssr.js +52 -4
- package/dist/transforms/index.d.ts +1 -1
- package/dist/transforms/index.js +1 -1
- package/dist/utils/encryption-runtime.d.ts +1 -1
- package/dist/utils/encryption-runtime.js +4 -4
- package/dist/utils/rpc.js +1 -1
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.development.js +2964 -774
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.production.js +554 -312
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.edge.development.js +2721 -724
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.edge.production.js +541 -300
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.development.js +2955 -858
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.production.js +652 -332
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2956 -861
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.unbundled.production.js +652 -332
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-plugin.js +6 -2
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.development.js +1931 -713
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.production.js +544 -295
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.development.js +1926 -715
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.production.js +542 -299
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.development.js +2719 -743
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.production.js +725 -338
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2703 -727
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.unbundled.production.js +725 -338
- package/dist/vendor/react-server-dom/package.json +3 -3
- package/dist/vendor/react-server-dom/server.node.js +3 -1
- package/dist/vendor/react-server-dom/server.node.unbundled.js +3 -1
- package/dist/vendor/react-server-dom/static.browser.js +1 -3
- package/dist/vendor/react-server-dom/static.edge.js +1 -3
- package/dist/vendor/react-server-dom/static.node.js +2 -3
- package/dist/vendor/react-server-dom/static.node.unbundled.js +1 -3
- package/package.json +6 -7
- package/types/index.d.ts +0 -4
- package/dist/browser--ZREVnM9.js +0 -22
- package/dist/client-C7Eok9hc.js +0 -23
- package/dist/extra/browser.d.ts +0 -14
- package/dist/extra/browser.js +0 -88
- package/dist/extra/rsc.d.ts +0 -2
- package/dist/extra/rsc.js +0 -56
- package/dist/extra/ssr.d.ts +0 -14
- package/dist/extra/ssr.js +0 -37
- package/dist/rsc-CiAoLCx8.js +0 -21
- package/dist/rsc-c22DF1A7.d.ts +0 -16
- package/dist/rsc-html-stream/browser.d.ts +0 -5
- package/dist/rsc-html-stream/browser.js +0 -8
- package/dist/rsc-html-stream/ssr.d.ts +0 -7
- package/dist/rsc-html-stream/ssr.js +0 -8
- package/dist/server-DMhFuTz_.js +0 -72
- package/dist/ssr-BQwZitKq.js +0 -53
- package/types/virtual.d.ts +0 -5
- /package/dist/{browser-DwWQeoll.d.ts → browser-CXHICuDc.d.ts} +0 -0
- /package/dist/{encryption-runtime-B8xcnJoN.d.ts → encryption-runtime-DwihLkYv.d.ts} +0 -0
- /package/dist/{encryption-utils-BDwwcMVT.js → encryption-utils-CoE0gWjC.js} +0 -0
- /package/dist/{index-B04iFwO5.d.ts → index-DYBWAuKP.d.ts} +0 -0
- /package/dist/{index-CPkExgij.d.ts → index-kBz3NvVt.d.ts} +0 -0
- /package/dist/{plugin-CZbI4rhS.js → plugin-BwI7mYXI.js} +0 -0
- /package/dist/{rpc-CUvSZurk.js → rpc-D7cb_Wd5.js} +0 -0
- /package/dist/{rsc-JJjz3Z0i.d.ts → rsc-Fgmk6j0z.d.ts} +0 -0
- /package/dist/{rsc-GFzFWyhT.js → rsc-cp4EenMG.js} +0 -0
- /package/dist/{shared-n-ykEs15.js → shared-CceFFukJ.js} +0 -0
- /package/dist/{ssr-BrSGyrxe.d.ts → ssr-BnYZ8xo9.d.ts} +0 -0
- /package/dist/{ssr-Cm2FP2zD.js → ssr-C468YlFl.js} +0 -0
- /package/dist/{transforms-CpF3zNE0.js → transforms-wFF-pWF7.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-server-dom-webpack",
|
|
3
3
|
"description": "React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.",
|
|
4
|
-
"version": "19.
|
|
4
|
+
"version": "19.2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react"
|
|
7
7
|
],
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"node": ">=0.10.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
|
-
"react": "^19.
|
|
103
|
-
"react-dom": "^19.
|
|
102
|
+
"react": "^19.2.0",
|
|
103
|
+
"react-dom": "^19.2.0",
|
|
104
104
|
"webpack": "^5.59.0"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
@@ -7,9 +7,11 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
7
7
|
s = require('./cjs/react-server-dom-webpack-server.node.development.js');
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
exports.renderToReadableStream = s.renderToReadableStream;
|
|
10
11
|
exports.renderToPipeableStream = s.renderToPipeableStream;
|
|
11
|
-
exports.decodeReplyFromBusboy = s.decodeReplyFromBusboy;
|
|
12
12
|
exports.decodeReply = s.decodeReply;
|
|
13
|
+
exports.decodeReplyFromBusboy = s.decodeReplyFromBusboy;
|
|
14
|
+
exports.decodeReplyFromAsyncIterable = s.decodeReplyFromAsyncIterable;
|
|
13
15
|
exports.decodeAction = s.decodeAction;
|
|
14
16
|
exports.decodeFormState = s.decodeFormState;
|
|
15
17
|
exports.registerServerReference = s.registerServerReference;
|
|
@@ -7,9 +7,11 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
7
7
|
s = require('./cjs/react-server-dom-webpack-server.node.unbundled.development.js');
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
exports.renderToReadableStream = s.renderToReadableStream;
|
|
10
11
|
exports.renderToPipeableStream = s.renderToPipeableStream;
|
|
11
|
-
exports.decodeReplyFromBusboy = s.decodeReplyFromBusboy;
|
|
12
12
|
exports.decodeReply = s.decodeReply;
|
|
13
|
+
exports.decodeReplyFromBusboy = s.decodeReplyFromBusboy;
|
|
14
|
+
exports.decodeReplyFromAsyncIterable = s.decodeReplyFromAsyncIterable;
|
|
13
15
|
exports.decodeAction = s.decodeAction;
|
|
14
16
|
exports.decodeFormState = s.decodeFormState;
|
|
15
17
|
exports.registerServerReference = s.registerServerReference;
|
|
@@ -7,6 +7,5 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
7
7
|
s = require('./cjs/react-server-dom-webpack-server.node.development.js');
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
10
|
+
exports.prerender = s.prerender;
|
|
11
|
+
exports.prerenderToNodeStream = s.prerenderToNodeStream;
|
|
@@ -7,6 +7,4 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
7
7
|
s = require('./cjs/react-server-dom-webpack-server.node.unbundled.development.js');
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
exports.unstable_prerenderToNodeStream = s.unstable_prerenderToNodeStream;
|
|
12
|
-
}
|
|
10
|
+
exports.prerenderToNodeStream = s.prerenderToNodeStream;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-rsc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React Server Components (RSC) support for Vite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -53,14 +53,13 @@
|
|
|
53
53
|
"@tsconfig/strictest": "^2.0.6",
|
|
54
54
|
"@types/estree": "^1.0.8",
|
|
55
55
|
"@types/node": "^22.18.8",
|
|
56
|
-
"@types/react": "^19.
|
|
57
|
-
"@types/react-dom": "^19.1
|
|
56
|
+
"@types/react": "^19.2.2",
|
|
57
|
+
"@types/react-dom": "^19.2.1",
|
|
58
58
|
"@vitejs/plugin-react": "workspace:*",
|
|
59
59
|
"@vitejs/test-dep-cjs-and-esm": "./test-dep/cjs-and-esm",
|
|
60
|
-
"react": "^19.
|
|
61
|
-
"react-dom": "^19.
|
|
62
|
-
"react-server-dom-webpack": "^19.
|
|
63
|
-
"rsc-html-stream": "^0.0.7",
|
|
60
|
+
"react": "^19.2.0",
|
|
61
|
+
"react-dom": "^19.2.0",
|
|
62
|
+
"react-server-dom-webpack": "^19.2.0",
|
|
64
63
|
"tinyexec": "^1.0.1",
|
|
65
64
|
"tsdown": "^0.15.6"
|
|
66
65
|
},
|
package/types/index.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import './virtual'
|
|
2
|
-
|
|
3
1
|
declare global {
|
|
4
2
|
interface ImportMeta {
|
|
5
3
|
readonly viteRsc: {
|
|
6
4
|
loadCss: (importer?: string) => import('react').ReactNode
|
|
7
|
-
/** @deprecated use `loadModule("ssr", entry)` instead */
|
|
8
|
-
loadSsrModule: <T>(entry: string) => Promise<T>
|
|
9
5
|
loadModule: <T>(environmentName: string, entryName: string) => Promise<T>
|
|
10
6
|
loadBootstrapScriptContent: (entryName: string) => Promise<string>
|
|
11
7
|
}
|
package/dist/browser--ZREVnM9.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { setRequireModule } from "./browser-7NhxQxuk.js";
|
|
2
|
-
import * as clientReferences from "virtual:vite-rsc/client-references";
|
|
3
|
-
|
|
4
|
-
//#region src/browser.ts
|
|
5
|
-
initialize();
|
|
6
|
-
function initialize() {
|
|
7
|
-
setRequireModule({ load: async (id) => {
|
|
8
|
-
if (!import.meta.env.__vite_rsc_build__) return __vite_rsc_raw_import__(withTrailingSlash(import.meta.env.BASE_URL) + id.slice(1));
|
|
9
|
-
else {
|
|
10
|
-
const import_ = clientReferences.default[id];
|
|
11
|
-
if (!import_) throw new Error(`client reference not found '${id}'`);
|
|
12
|
-
return import_();
|
|
13
|
-
}
|
|
14
|
-
} });
|
|
15
|
-
}
|
|
16
|
-
function withTrailingSlash(path) {
|
|
17
|
-
if (path[path.length - 1] !== "/") return `${path}/`;
|
|
18
|
-
return path;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { };
|
package/dist/client-C7Eok9hc.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/rsc-html-stream@0.0.7/node_modules/rsc-html-stream/client.js
|
|
2
|
-
let encoder = new TextEncoder();
|
|
3
|
-
let streamController;
|
|
4
|
-
let rscStream = new ReadableStream({ start(controller) {
|
|
5
|
-
if (typeof window === "undefined") return;
|
|
6
|
-
let handleChunk = (chunk) => {
|
|
7
|
-
if (typeof chunk === "string") controller.enqueue(encoder.encode(chunk));
|
|
8
|
-
else controller.enqueue(chunk);
|
|
9
|
-
};
|
|
10
|
-
window.__FLIGHT_DATA ||= [];
|
|
11
|
-
window.__FLIGHT_DATA.forEach(handleChunk);
|
|
12
|
-
window.__FLIGHT_DATA.push = (chunk) => {
|
|
13
|
-
handleChunk(chunk);
|
|
14
|
-
};
|
|
15
|
-
streamController = controller;
|
|
16
|
-
} });
|
|
17
|
-
if (typeof document !== "undefined" && document.readyState === "loading") document.addEventListener("DOMContentLoaded", () => {
|
|
18
|
-
streamController?.close();
|
|
19
|
-
});
|
|
20
|
-
else streamController?.close();
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
export { rscStream };
|
package/dist/extra/browser.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { RscPayload } from "../rsc-c22DF1A7.js";
|
|
2
|
-
|
|
3
|
-
//#region src/extra/browser.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use `@vitejs/plugin-rsc/browser` API instead.
|
|
7
|
-
*/
|
|
8
|
-
declare function hydrate(): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use `@vitejs/plugin-rsc/browser` API instead.
|
|
11
|
-
*/
|
|
12
|
-
declare function fetchRSC(request: string | URL | Request): Promise<RscPayload["root"]>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { fetchRSC, hydrate };
|
package/dist/extra/browser.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import "../dist-DiJnRA1C.js";
|
|
2
|
-
import "../shared-CXg_u-4h.js";
|
|
3
|
-
import "../browser-7NhxQxuk.js";
|
|
4
|
-
import { createFromFetch, createFromReadableStream, createTemporaryReferenceSet, encodeReply, setServerCallback } from "../browser-D8OPzpF5.js";
|
|
5
|
-
import "../browser--ZREVnM9.js";
|
|
6
|
-
import { rscStream } from "../client-C7Eok9hc.js";
|
|
7
|
-
import React from "react";
|
|
8
|
-
import ReactDomClient from "react-dom/client";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
|
|
11
|
-
//#region src/extra/browser.tsx
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated Use `@vitejs/plugin-rsc/browser` API instead.
|
|
14
|
-
*/
|
|
15
|
-
async function hydrate() {
|
|
16
|
-
const callServer = async (id, args) => {
|
|
17
|
-
const url = new URL(window.location.href);
|
|
18
|
-
const temporaryReferences = createTemporaryReferenceSet();
|
|
19
|
-
const payload = await createFromFetch(fetch(url, {
|
|
20
|
-
method: "POST",
|
|
21
|
-
body: await encodeReply(args, { temporaryReferences }),
|
|
22
|
-
headers: { "x-rsc-action": id }
|
|
23
|
-
}), { temporaryReferences });
|
|
24
|
-
setPayload(payload);
|
|
25
|
-
return payload.returnValue;
|
|
26
|
-
};
|
|
27
|
-
setServerCallback(callServer);
|
|
28
|
-
async function onNavigation() {
|
|
29
|
-
const url = new URL(window.location.href);
|
|
30
|
-
const payload = await createFromFetch(fetch(url));
|
|
31
|
-
setPayload(payload);
|
|
32
|
-
}
|
|
33
|
-
const initialPayload = await createFromReadableStream(rscStream);
|
|
34
|
-
let setPayload;
|
|
35
|
-
function BrowserRoot() {
|
|
36
|
-
const [payload, setPayload_] = React.useState(initialPayload);
|
|
37
|
-
React.useEffect(() => {
|
|
38
|
-
setPayload = (v) => React.startTransition(() => setPayload_(v));
|
|
39
|
-
}, [setPayload_]);
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
return listenNavigation(() => onNavigation());
|
|
42
|
-
}, []);
|
|
43
|
-
return payload.root;
|
|
44
|
-
}
|
|
45
|
-
const browserRoot = /* @__PURE__ */ jsx(React.StrictMode, { children: /* @__PURE__ */ jsx(BrowserRoot, {}) });
|
|
46
|
-
ReactDomClient.hydrateRoot(document, browserRoot, { formState: initialPayload.formState });
|
|
47
|
-
if (import.meta.hot) import.meta.hot.on("rsc:update", () => {
|
|
48
|
-
window.history.replaceState({}, "", window.location.href);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @deprecated Use `@vitejs/plugin-rsc/browser` API instead.
|
|
53
|
-
*/
|
|
54
|
-
async function fetchRSC(request) {
|
|
55
|
-
return (await createFromFetch(fetch(request))).root;
|
|
56
|
-
}
|
|
57
|
-
function listenNavigation(onNavigation) {
|
|
58
|
-
window.addEventListener("popstate", onNavigation);
|
|
59
|
-
const oldPushState = window.history.pushState;
|
|
60
|
-
window.history.pushState = function(...args) {
|
|
61
|
-
const res = oldPushState.apply(this, args);
|
|
62
|
-
onNavigation();
|
|
63
|
-
return res;
|
|
64
|
-
};
|
|
65
|
-
const oldReplaceState = window.history.replaceState;
|
|
66
|
-
window.history.replaceState = function(...args) {
|
|
67
|
-
const res = oldReplaceState.apply(this, args);
|
|
68
|
-
onNavigation();
|
|
69
|
-
return res;
|
|
70
|
-
};
|
|
71
|
-
function onClick(e) {
|
|
72
|
-
let link = e.target.closest("a");
|
|
73
|
-
if (link && link instanceof HTMLAnchorElement && link.href && (!link.target || link.target === "_self") && link.origin === location.origin && !link.hasAttribute("download") && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.defaultPrevented) {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
history.pushState(null, "", link.href);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
document.addEventListener("click", onClick);
|
|
79
|
-
return () => {
|
|
80
|
-
document.removeEventListener("click", onClick);
|
|
81
|
-
window.removeEventListener("popstate", onNavigation);
|
|
82
|
-
window.history.pushState = oldPushState;
|
|
83
|
-
window.history.replaceState = oldReplaceState;
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
export { fetchRSC, hydrate };
|
package/dist/extra/rsc.d.ts
DELETED
package/dist/extra/rsc.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import "../dist-DiJnRA1C.js";
|
|
2
|
-
import "../shared-CXg_u-4h.js";
|
|
3
|
-
import "../encryption-utils-BDwwcMVT.js";
|
|
4
|
-
import { loadServerAction } from "../rsc-GFzFWyhT.js";
|
|
5
|
-
import { createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, renderToReadableStream } from "../rsc-BdCB3621.js";
|
|
6
|
-
import "../encryption-runtime-DT6dtlC5.js";
|
|
7
|
-
import "../rsc-CiAoLCx8.js";
|
|
8
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
|
-
//#region src/extra/rsc.tsx
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use `@vitejs/plugin-rsc/rsc` API instead.
|
|
13
|
-
*/
|
|
14
|
-
async function renderRequest(request, root, options) {
|
|
15
|
-
function RscRoot() {
|
|
16
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [options?.nonce && /* @__PURE__ */ jsx("meta", {
|
|
17
|
-
property: "csp-nonce",
|
|
18
|
-
nonce: options.nonce
|
|
19
|
-
}), root] });
|
|
20
|
-
}
|
|
21
|
-
const url = new URL(request.url);
|
|
22
|
-
const isAction = request.method === "POST";
|
|
23
|
-
const isRscRequest = !request.headers.get("accept")?.includes("text/html") && !url.searchParams.has("__html") || url.searchParams.has("__rsc");
|
|
24
|
-
let returnValue;
|
|
25
|
-
let formState;
|
|
26
|
-
let temporaryReferences;
|
|
27
|
-
if (isAction) {
|
|
28
|
-
const actionId = request.headers.get("x-rsc-action");
|
|
29
|
-
if (actionId) {
|
|
30
|
-
const body = request.headers.get("content-type")?.startsWith("multipart/form-data") ? await request.formData() : await request.text();
|
|
31
|
-
temporaryReferences = createTemporaryReferenceSet();
|
|
32
|
-
const args = await decodeReply(body, { temporaryReferences });
|
|
33
|
-
returnValue = await (await loadServerAction(actionId)).apply(null, args);
|
|
34
|
-
} else {
|
|
35
|
-
const formData = await request.formData();
|
|
36
|
-
formState = await decodeFormState(await (await decodeAction(formData))(), formData);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const rscStream = renderToReadableStream({
|
|
40
|
-
root: /* @__PURE__ */ jsx(RscRoot, {}),
|
|
41
|
-
formState,
|
|
42
|
-
returnValue
|
|
43
|
-
}, { temporaryReferences });
|
|
44
|
-
if (isRscRequest) return new Response(rscStream, { headers: {
|
|
45
|
-
"content-type": "text/x-component;charset=utf-8",
|
|
46
|
-
vary: "accept"
|
|
47
|
-
} });
|
|
48
|
-
return (await import.meta.viteRsc.loadModule("ssr", "index")).renderHtml(rscStream, {
|
|
49
|
-
formState,
|
|
50
|
-
nonce: options?.nonce,
|
|
51
|
-
debugNoJs: url.searchParams.has("__nojs")
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
export { renderRequest };
|
package/dist/extra/ssr.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ReactFormState } from "react-dom/client";
|
|
2
|
-
|
|
3
|
-
//#region src/extra/ssr.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use `@vitejs/plugin-rsc/ssr` API instead.
|
|
7
|
-
*/
|
|
8
|
-
declare function renderHtml(rscStream: ReadableStream<Uint8Array>, options?: {
|
|
9
|
-
formState?: ReactFormState;
|
|
10
|
-
nonce?: string;
|
|
11
|
-
debugNoJs?: boolean;
|
|
12
|
-
}): Promise<Response>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { renderHtml };
|
package/dist/extra/ssr.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import "../dist-DiJnRA1C.js";
|
|
2
|
-
import "../shared-CXg_u-4h.js";
|
|
3
|
-
import "../shared-n-ykEs15.js";
|
|
4
|
-
import "../ssr-Cm2FP2zD.js";
|
|
5
|
-
import { createFromReadableStream } from "../ssr-Cd4SbAaO.js";
|
|
6
|
-
import "../ssr-BQwZitKq.js";
|
|
7
|
-
import { injectRSCPayload } from "../server-DMhFuTz_.js";
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
import ReactDomServer from "react-dom/server.edge";
|
|
11
|
-
|
|
12
|
-
//#region src/extra/ssr.tsx
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Use `@vitejs/plugin-rsc/ssr` API instead.
|
|
15
|
-
*/
|
|
16
|
-
async function renderHtml(rscStream, options) {
|
|
17
|
-
const [rscStream1, rscStream2] = rscStream.tee();
|
|
18
|
-
let payload;
|
|
19
|
-
function SsrRoot() {
|
|
20
|
-
payload ??= createFromReadableStream(rscStream1, { nonce: options?.nonce });
|
|
21
|
-
return React.use(payload).root;
|
|
22
|
-
}
|
|
23
|
-
const bootstrapScriptContent = await import.meta.viteRsc.loadBootstrapScriptContent("index");
|
|
24
|
-
let responseStream = await ReactDomServer.renderToReadableStream(/* @__PURE__ */ jsx(SsrRoot, {}), {
|
|
25
|
-
bootstrapScriptContent: options?.debugNoJs ? void 0 : bootstrapScriptContent,
|
|
26
|
-
nonce: options?.nonce,
|
|
27
|
-
formState: options?.formState
|
|
28
|
-
});
|
|
29
|
-
if (!options?.debugNoJs) responseStream = responseStream.pipeThrough(injectRSCPayload(rscStream2, { nonce: options?.nonce }));
|
|
30
|
-
return new Response(responseStream, { headers: {
|
|
31
|
-
"content-type": "text/html;charset=utf-8",
|
|
32
|
-
vary: "accept"
|
|
33
|
-
} });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { renderHtml };
|
package/dist/rsc-CiAoLCx8.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { setRequireModule } from "./rsc-GFzFWyhT.js";
|
|
2
|
-
import serverReferences from "virtual:vite-rsc/server-references";
|
|
3
|
-
|
|
4
|
-
//#region src/rsc.tsx
|
|
5
|
-
initialize();
|
|
6
|
-
function initialize() {
|
|
7
|
-
setRequireModule({ load: async (id) => {
|
|
8
|
-
if (!import.meta.env.__vite_rsc_build__) return import(
|
|
9
|
-
/* @vite-ignore */
|
|
10
|
-
id
|
|
11
|
-
);
|
|
12
|
-
else {
|
|
13
|
-
const import_ = serverReferences[id];
|
|
14
|
-
if (!import_) throw new Error(`server reference not found '${id}'`);
|
|
15
|
-
return import_();
|
|
16
|
-
}
|
|
17
|
-
} });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { };
|
package/dist/rsc-c22DF1A7.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ReactFormState } from "react-dom/client";
|
|
2
|
-
|
|
3
|
-
//#region src/extra/rsc.d.ts
|
|
4
|
-
type RscPayload = {
|
|
5
|
-
root: React.ReactNode;
|
|
6
|
-
formState?: ReactFormState;
|
|
7
|
-
returnValue?: unknown;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use `@vitejs/plugin-rsc/rsc` API instead.
|
|
11
|
-
*/
|
|
12
|
-
declare function renderRequest(request: Request, root: React.ReactNode, options?: {
|
|
13
|
-
nonce?: string;
|
|
14
|
-
}): Promise<Response>;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { RscPayload, renderRequest };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
//#region src/rsc-html-stream/ssr.d.ts
|
|
2
|
-
/** @deprecated use `rsc-html-stream/server` instead */
|
|
3
|
-
declare const injectRscStreamToHtml: (stream: ReadableStream<Uint8Array>, options?: {
|
|
4
|
-
nonce?: string;
|
|
5
|
-
}) => TransformStream<Uint8Array, Uint8Array>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { injectRscStreamToHtml };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { injectRSCPayload } from "../server-DMhFuTz_.js";
|
|
2
|
-
|
|
3
|
-
//#region src/rsc-html-stream/ssr.ts
|
|
4
|
-
/** @deprecated use `rsc-html-stream/server` instead */
|
|
5
|
-
const injectRscStreamToHtml = (stream, options) => injectRSCPayload(stream, options);
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
export { injectRscStreamToHtml };
|
package/dist/server-DMhFuTz_.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/rsc-html-stream@0.0.7/node_modules/rsc-html-stream/server.js
|
|
2
|
-
const encoder = new TextEncoder();
|
|
3
|
-
const trailer = "</body></html>";
|
|
4
|
-
function injectRSCPayload(rscStream, options) {
|
|
5
|
-
let decoder = new TextDecoder();
|
|
6
|
-
let resolveFlightDataPromise;
|
|
7
|
-
let flightDataPromise = new Promise((resolve) => resolveFlightDataPromise = resolve);
|
|
8
|
-
let startedRSC = false;
|
|
9
|
-
let nonce = options && typeof options.nonce === "string" ? options.nonce : void 0;
|
|
10
|
-
let buffered = [];
|
|
11
|
-
let timeout = null;
|
|
12
|
-
function flushBufferedChunks(controller) {
|
|
13
|
-
for (let chunk of buffered) {
|
|
14
|
-
let buf = decoder.decode(chunk, { stream: true });
|
|
15
|
-
if (buf.endsWith(trailer)) buf = buf.slice(0, -14);
|
|
16
|
-
controller.enqueue(encoder.encode(buf));
|
|
17
|
-
}
|
|
18
|
-
let remaining = decoder.decode();
|
|
19
|
-
if (remaining.length) {
|
|
20
|
-
if (remaining.endsWith(trailer)) remaining = remaining.slice(0, -14);
|
|
21
|
-
controller.enqueue(encoder.encode(remaining));
|
|
22
|
-
}
|
|
23
|
-
buffered.length = 0;
|
|
24
|
-
timeout = null;
|
|
25
|
-
}
|
|
26
|
-
return new TransformStream({
|
|
27
|
-
transform(chunk, controller) {
|
|
28
|
-
buffered.push(chunk);
|
|
29
|
-
if (timeout) return;
|
|
30
|
-
timeout = setTimeout(async () => {
|
|
31
|
-
try {
|
|
32
|
-
flushBufferedChunks(controller);
|
|
33
|
-
} catch (e) {
|
|
34
|
-
controller.error(e);
|
|
35
|
-
resolveFlightDataPromise();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (!startedRSC) {
|
|
39
|
-
startedRSC = true;
|
|
40
|
-
writeRSCStream(rscStream, controller, nonce).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
|
|
41
|
-
}
|
|
42
|
-
}, 0);
|
|
43
|
-
},
|
|
44
|
-
async flush(controller) {
|
|
45
|
-
await flightDataPromise;
|
|
46
|
-
if (timeout) {
|
|
47
|
-
clearTimeout(timeout);
|
|
48
|
-
flushBufferedChunks(controller);
|
|
49
|
-
}
|
|
50
|
-
controller.enqueue(encoder.encode(trailer));
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
async function writeRSCStream(rscStream, controller, nonce) {
|
|
55
|
-
let decoder = new TextDecoder("utf-8", { fatal: true });
|
|
56
|
-
for await (let chunk of rscStream) try {
|
|
57
|
-
writeChunk(JSON.stringify(decoder.decode(chunk, { stream: true })), controller, nonce);
|
|
58
|
-
} catch (err) {
|
|
59
|
-
writeChunk(`Uint8Array.from(atob(${JSON.stringify(btoa(String.fromCodePoint(...chunk)))}), m => m.codePointAt(0))`, controller, nonce);
|
|
60
|
-
}
|
|
61
|
-
let remaining = decoder.decode();
|
|
62
|
-
if (remaining.length) writeChunk(JSON.stringify(remaining), controller, nonce);
|
|
63
|
-
}
|
|
64
|
-
function writeChunk(chunk, controller, nonce) {
|
|
65
|
-
controller.enqueue(encoder.encode(`<script${nonce ? ` nonce="${nonce}"` : ""}>${escapeScript(`(self.__FLIGHT_DATA||=[]).push(${chunk})`)}<\/script>`));
|
|
66
|
-
}
|
|
67
|
-
function escapeScript(script) {
|
|
68
|
-
return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
export { injectRSCPayload };
|
package/dist/ssr-BQwZitKq.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { toCssVirtual } from "./shared-n-ykEs15.js";
|
|
2
|
-
import { setRequireModule } from "./ssr-Cm2FP2zD.js";
|
|
3
|
-
import * as clientReferences from "virtual:vite-rsc/client-references";
|
|
4
|
-
import assetsManifest from "virtual:vite-rsc/assets-manifest";
|
|
5
|
-
import * as ReactDOM from "react-dom";
|
|
6
|
-
|
|
7
|
-
//#region src/ssr.tsx
|
|
8
|
-
initialize();
|
|
9
|
-
function initialize() {
|
|
10
|
-
setRequireModule({ load: async (id) => {
|
|
11
|
-
if (!import.meta.env.__vite_rsc_build__) return wrapResourceProxy(await import(
|
|
12
|
-
/* @vite-ignore */
|
|
13
|
-
id
|
|
14
|
-
), {
|
|
15
|
-
js: [],
|
|
16
|
-
css: (await import(
|
|
17
|
-
/* @vite-ignore */
|
|
18
|
-
"/@id/__x00__" + toCssVirtual({
|
|
19
|
-
id,
|
|
20
|
-
type: "ssr"
|
|
21
|
-
})
|
|
22
|
-
)).default
|
|
23
|
-
});
|
|
24
|
-
else {
|
|
25
|
-
const import_ = clientReferences.default[id];
|
|
26
|
-
if (!import_) throw new Error(`client reference not found '${id}'`);
|
|
27
|
-
const deps = assetsManifest.clientReferenceDeps[id];
|
|
28
|
-
if (deps) preloadDeps(deps);
|
|
29
|
-
return wrapResourceProxy(await import_(), deps);
|
|
30
|
-
}
|
|
31
|
-
} });
|
|
32
|
-
}
|
|
33
|
-
function wrapResourceProxy(mod, deps) {
|
|
34
|
-
return new Proxy(mod, { get(target, p, receiver) {
|
|
35
|
-
if (p in mod) {
|
|
36
|
-
if (deps) preloadDeps(deps);
|
|
37
|
-
}
|
|
38
|
-
return Reflect.get(target, p, receiver);
|
|
39
|
-
} });
|
|
40
|
-
}
|
|
41
|
-
function preloadDeps(deps) {
|
|
42
|
-
for (const href of deps.js) ReactDOM.preloadModule(href, {
|
|
43
|
-
as: "script",
|
|
44
|
-
crossOrigin: ""
|
|
45
|
-
});
|
|
46
|
-
for (const href of deps.css) ReactDOM.preinit(href, {
|
|
47
|
-
as: "style",
|
|
48
|
-
precedence: "vite-rsc/client-reference"
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
export { };
|
package/types/virtual.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|