@vitejs/plugin-rsc 0.5.35 → 0.5.37
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 +6 -4
- package/dist/{client-reference-Bk5pzNGN.d.ts → client-reference-CWbaj3vK.d.ts} +1 -1
- package/dist/{encryption-utils-BNbYHtC4.js → encryption-utils-Bmw1Q82C.js} +6 -4
- package/dist/{index-XXYjyFr6.d.ts → index-DFncbcyO.d.ts} +7 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{picocolors-DCTC64Zv.js → picocolors-BPyd8zCA.js} +1 -1
- package/dist/{plugin-CKqXjp8D.d.ts → plugin-C2nJizTd.d.ts} +16 -5
- package/dist/{plugin-CLvIS10V.js → plugin-C4C80eZm.js} +24 -15
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +1 -1
- package/dist/rsc/server.d.ts +1 -1
- package/dist/rsc/server.node.d.ts +1 -1
- package/dist/rsc/static.d.ts +1 -1
- package/dist/rsc/static.node.d.ts +1 -1
- package/dist/{shared-CXQb6hk9.js → shared-DH8gaClP.js} +1 -0
- package/dist/{shared-DJBuYpZL.d.ts → shared-Df9Nennr.d.ts} +1 -1
- package/dist/ssr.d.ts +1 -1
- package/dist/ssr.js +1 -1
- package/dist/ssr.node.d.ts +1 -1
- package/dist/ssr.node.js +1 -1
- package/dist/transforms/index.d.ts +1 -1
- package/dist/transforms/index.js +7 -5
- package/dist/utils/encryption-runtime.d.ts +2 -2
- package/dist/utils/encryption-runtime.js +8 -5
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -425,10 +425,12 @@ export default defineConfig({
|
|
|
425
425
|
// this is enabled by default. See the "server-only and client-only import" section below for details.
|
|
426
426
|
validateImports: true,
|
|
427
427
|
|
|
428
|
-
// by default, the plugin
|
|
429
|
-
//
|
|
430
|
-
//
|
|
431
|
-
//
|
|
428
|
+
// by default, the plugin generates a random encryption key for "use server" closure
|
|
429
|
+
// arguments at build time and writes it into the build output.
|
|
430
|
+
// `defineEncryptionKey` is a JavaScript expression evaluated at runtime instead,
|
|
431
|
+
// so the key can be loaded as a runtime secret, rotated without rebuilding,
|
|
432
|
+
// and shared by server instances built separately from the same source.
|
|
433
|
+
// It isn't meant to keep encrypted closures valid across different app versions.
|
|
432
434
|
// cf. https://nextjs.org/docs/app/guides/data-security#overwriting-encryption-keys-advanced
|
|
433
435
|
defineEncryptionKey: 'process.env.MY_ENCRYPTION_KEY',
|
|
434
436
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ClientReferenceMetadata } from "./rsc-D8UlANI2.js";
|
|
2
|
-
import { i as ResolvedAssetDeps } from "./plugin-
|
|
2
|
+
import { i as ResolvedAssetDeps } from "./plugin-C2nJizTd.js";
|
|
3
3
|
//#region src/rsc/client-reference.d.ts
|
|
4
4
|
type OnClientReference = (metadata: ClientReferenceMetadata & {
|
|
5
5
|
deps: ResolvedAssetDeps;
|
|
@@ -51,21 +51,23 @@ async function generateEncryptionKey() {
|
|
|
51
51
|
const exported = await crypto.subtle.exportKey("raw", key);
|
|
52
52
|
return new Uint8Array(exported);
|
|
53
53
|
}
|
|
54
|
-
async function encryptBuffer(data, key) {
|
|
54
|
+
async function encryptBuffer(data, key, additionalData) {
|
|
55
55
|
const iv = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
|
|
56
56
|
const encrypted = await crypto.subtle.encrypt({
|
|
57
57
|
name: "AES-GCM",
|
|
58
|
-
iv
|
|
58
|
+
iv,
|
|
59
|
+
...additionalData && { additionalData }
|
|
59
60
|
}, key, data);
|
|
60
61
|
return toBase64(concatArray([iv, new Uint8Array(encrypted)]));
|
|
61
62
|
}
|
|
62
|
-
async function decryptBuffer(encryptedString, key) {
|
|
63
|
+
async function decryptBuffer(encryptedString, key, additionalData) {
|
|
63
64
|
const concatenated = fromBase64(encryptedString);
|
|
64
65
|
const iv = concatenated.slice(0, 16);
|
|
65
66
|
const encrypted = concatenated.slice(16);
|
|
66
67
|
return crypto.subtle.decrypt({
|
|
67
68
|
name: "AES-GCM",
|
|
68
|
-
iv
|
|
69
|
+
iv,
|
|
70
|
+
...additionalData && { additionalData }
|
|
69
71
|
}, key, encrypted);
|
|
70
72
|
}
|
|
71
73
|
//#endregion
|
|
@@ -531,8 +531,9 @@ type TransformHoistInlineDirectiveOptions = {
|
|
|
531
531
|
runtime: (value: string, name: string, meta: TransformHoistInlineDirectiveMeta) => string;
|
|
532
532
|
directive: string | RegExp;
|
|
533
533
|
rejectNonAsyncFunction?: boolean;
|
|
534
|
-
|
|
535
|
-
|
|
534
|
+
/** `name` is the hoisted function's name, e.g. to bind the encoding to it. */
|
|
535
|
+
encode?: (value: string, name: string) => string;
|
|
536
|
+
decode?: (value: string, name: string) => string;
|
|
536
537
|
/** Keep generated hoisted declarations module-local instead of exporting them. */
|
|
537
538
|
noExport?: boolean;
|
|
538
539
|
/**
|
|
@@ -547,6 +548,8 @@ type TransformHoistInlineDirectiveMeta = {
|
|
|
547
548
|
directiveMatch: RegExpMatchArray;
|
|
548
549
|
/** Original source function before closure captures are added as parameters. */
|
|
549
550
|
valueNode: ArrowFunctionExpression | FunctionDeclaration | FunctionExpression;
|
|
551
|
+
/** Closure captures, in the order they are bound ahead of the original parameters. */
|
|
552
|
+
bindVars: string[];
|
|
550
553
|
};
|
|
551
554
|
type TransformHoistInlineDirectiveResult = {
|
|
552
555
|
output: MagicString;
|
|
@@ -928,8 +931,8 @@ declare function rejectNonAsyncFunction$1(opts: {
|
|
|
928
931
|
type TransformServerActionServerOptions = {
|
|
929
932
|
runtime: (value: string, name: string) => string;
|
|
930
933
|
rejectNonAsyncFunction?: boolean;
|
|
931
|
-
encode?: (value: string) => string;
|
|
932
|
-
decode?: (value: string) => string;
|
|
934
|
+
encode?: (value: string, name: string) => string;
|
|
935
|
+
decode?: (value: string, name: string) => string;
|
|
933
936
|
};
|
|
934
937
|
type TransformServerActionServerResult = {
|
|
935
938
|
exportNames: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as getPluginApi, o as RscPluginManager, r as PluginApi, s as RscPluginOptions, u as vitePluginRsc } from "./plugin-
|
|
1
|
+
import { c as getPluginApi, o as RscPluginManager, r as PluginApi, s as RscPluginOptions, u as vitePluginRsc } from "./plugin-C2nJizTd.js";
|
|
2
2
|
export { type PluginApi, type RscPluginManager, type RscPluginOptions, vitePluginRsc as default, getPluginApi };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as vitePluginRsc, t as getPluginApi } from "./plugin-
|
|
1
|
+
import { r as vitePluginRsc, t as getPluginApi } from "./plugin-C4C80eZm.js";
|
|
2
2
|
export { vitePluginRsc as default, getPluginApi };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __commonJSMin } from "./plugin-
|
|
1
|
+
import { a as __commonJSMin } from "./plugin-C4C80eZm.js";
|
|
2
2
|
//#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
3
3
|
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
4
|
let p = process || {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v as TransformWrapExportFilter } from "./index-
|
|
1
|
+
import { v as TransformWrapExportFilter } from "./index-DFncbcyO.js";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
3
|
import { Plugin, ResolvedConfig, Rollup, ViteDevServer, parseAstAsync } from "vite";
|
|
4
4
|
//#region src/plugins/import-environment.d.ts
|
|
@@ -91,10 +91,21 @@ type RscPluginOptions = {
|
|
|
91
91
|
*/
|
|
92
92
|
enableActionEncryption?: boolean;
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
95
|
-
* "use server" closure
|
|
96
|
-
*
|
|
97
|
-
*
|
|
94
|
+
* JavaScript expression evaluated at runtime on the server that returns (or
|
|
95
|
+
* resolves to) a base64-encoded key for encrypting "use server" closure
|
|
96
|
+
* arguments, e.g. `'process.env.MY_ENCRYPTION_KEY'`.
|
|
97
|
+
*
|
|
98
|
+
* By default, the plugin generates a random key at build time and writes it
|
|
99
|
+
* into the build output. This option moves the key out of the build into a
|
|
100
|
+
* runtime secret, so that:
|
|
101
|
+
* - the key isn't stored in build artifacts,
|
|
102
|
+
* - it can be rotated without rebuilding, and
|
|
103
|
+
* - server instances built separately from the same source share one key.
|
|
104
|
+
*
|
|
105
|
+
* It isn't meant to keep encrypted closures valid across different versions
|
|
106
|
+
* of the app. Action ids can change when the source changes, and the
|
|
107
|
+
* encryption format may change between plugin versions.
|
|
108
|
+
*
|
|
98
109
|
* cf. https://nextjs.org/docs/app/guides/data-security#overwriting-encryption-keys-advanced
|
|
99
110
|
*/
|
|
100
111
|
defineEncryptionKey?: string;
|
|
@@ -3,7 +3,7 @@ import { i as hasDirective } from "./scope-Ck0n25my.js";
|
|
|
3
3
|
import { t as cjsModuleRunnerPlugin } from "./cjs-DhDj_zQT.js";
|
|
4
4
|
import { i as toCssVirtual, n as parseIdQuery, r as parseReferenceValidationVirtual, t as parseCssVirtual } from "./shared-B6H2TbnP.js";
|
|
5
5
|
import { findDirectives, transformDirectiveProxyExport, transformExpandExportAll, transformServerActionServer, transformWrapExport } from "./transforms/index.js";
|
|
6
|
-
import { o as generateEncryptionKey, s as toBase64 } from "./encryption-utils-
|
|
6
|
+
import { o as generateEncryptionKey, s as toBase64 } from "./encryption-utils-Bmw1Q82C.js";
|
|
7
7
|
import { createRpcServer } from "./utils/rpc.js";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import assert from "node:assert";
|
|
@@ -426,7 +426,7 @@ function scanBuildStripPlugin({ manager }) {
|
|
|
426
426
|
const importGlobRE = /\bimport\.meta\.glob(?:<\w+>)?\s*\(/g;
|
|
427
427
|
async function transformScanBuildStrip(code) {
|
|
428
428
|
const [imports] = esModuleLexer.parse(code);
|
|
429
|
-
let output = imports.map((e) => e.
|
|
429
|
+
let output = imports.map((e) => e.specifier && `import ${JSON.stringify(e.specifier)};\n`).filter(Boolean).join("");
|
|
430
430
|
if (importGlobRE.test(code)) {
|
|
431
431
|
const ast = await parseAstAsync(code);
|
|
432
432
|
walk(ast, { enter(node) {
|
|
@@ -711,7 +711,7 @@ function vitePluginRscMinimal(rscPluginOptions = {}, manager = new RscPluginMana
|
|
|
711
711
|
function vitePluginRsc(rscPluginOptions = {}) {
|
|
712
712
|
const manager = new RscPluginManager();
|
|
713
713
|
const buildApp = async (builder) => {
|
|
714
|
-
const colors = await import("./picocolors-
|
|
714
|
+
const colors = await import("./picocolors-BPyd8zCA.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
715
715
|
const logStep = (msg) => {
|
|
716
716
|
builder.config.logger.info(colors.blue(msg));
|
|
717
717
|
};
|
|
@@ -1160,8 +1160,11 @@ export function createRpcClient(params) {
|
|
|
1160
1160
|
}
|
|
1161
1161
|
}
|
|
1162
1162
|
},
|
|
1163
|
-
generateBundle
|
|
1164
|
-
|
|
1163
|
+
generateBundle: {
|
|
1164
|
+
order: "post",
|
|
1165
|
+
handler(_options, bundle) {
|
|
1166
|
+
if (this.environment.name !== "client") return;
|
|
1167
|
+
if (manager.isScanBuild) return;
|
|
1165
1168
|
const rscBundle = manager.bundles["rsc"];
|
|
1166
1169
|
if (!manager.config.environments.rsc.build.cssCodeSplit) {
|
|
1167
1170
|
let cssBundleName;
|
|
@@ -1184,12 +1187,12 @@ export function createRpcClient(params) {
|
|
|
1184
1187
|
});
|
|
1185
1188
|
}
|
|
1186
1189
|
const serverResources = {};
|
|
1187
|
-
const rscAssetDeps = collectAssetDeps(rscBundle);
|
|
1190
|
+
const rscAssetDeps = collectAssetDeps(rscBundle).idToDeps;
|
|
1188
1191
|
for (const [id, meta] of Object.entries(manager.serverResourcesMetaMap)) serverResources[meta.key] = assetsURLOfDeps({
|
|
1189
1192
|
js: [],
|
|
1190
1193
|
css: rscAssetDeps[id]?.deps.css ?? []
|
|
1191
1194
|
}, manager);
|
|
1192
|
-
const assetDeps = collectAssetDeps(bundle);
|
|
1195
|
+
const { idToDeps: assetDeps, chunkToDeps } = collectAssetDeps(bundle);
|
|
1193
1196
|
let clientEntryUrl;
|
|
1194
1197
|
let clientEntryDeps;
|
|
1195
1198
|
const clientReferenceDeps = {};
|
|
@@ -1201,11 +1204,12 @@ export function createRpcClient(params) {
|
|
|
1201
1204
|
clientReferenceDeps[meta.referenceKey] = assetsURLOfDeps(deps, manager);
|
|
1202
1205
|
}
|
|
1203
1206
|
if (!rscPluginOptions.customClientEntry) {
|
|
1204
|
-
const entry =
|
|
1207
|
+
const entry = [...chunkToDeps].find(([chunk]) => chunk.name === "index" && chunk.isEntry);
|
|
1205
1208
|
if (!entry) throw new Error(`[vite-rsc] Client build must have an entry chunk named "index". Use 'customClientEntry' option to disable this requirement.`);
|
|
1206
|
-
|
|
1209
|
+
const [entryChunk, entryDeps] = entry;
|
|
1210
|
+
clientEntryDeps = assetsURLOfDeps(entryDeps, manager);
|
|
1207
1211
|
for (const [key, deps] of Object.entries(clientReferenceDeps)) clientReferenceDeps[key] = mergeAssetDeps(deps, clientEntryDeps);
|
|
1208
|
-
clientEntryUrl = assetsURL(
|
|
1212
|
+
clientEntryUrl = assetsURL(entryChunk.fileName, manager);
|
|
1209
1213
|
}
|
|
1210
1214
|
manager.buildAssetsManifest = {
|
|
1211
1215
|
clientEntryUrl,
|
|
@@ -1688,11 +1692,12 @@ function vitePluginUseServer(useServerPluginOptions, manager) {
|
|
|
1688
1692
|
if (this.environment.name === serverEnvironmentName) {
|
|
1689
1693
|
const transformServerActionServer_ = withRollupError(this, transformServerActionServer);
|
|
1690
1694
|
const enableEncryption = useServerPluginOptions.enableActionEncryption ?? true;
|
|
1695
|
+
const getActionId = (name) => `${getServerReference().referenceKey}#${name}`;
|
|
1691
1696
|
const result = transformServerActionServer_(code, ast, {
|
|
1692
1697
|
runtime: (value, name) => `$$ReactServer.registerServerReference(${value}, ${JSON.stringify(getServerReference().referenceKey)}, ${JSON.stringify(name)})`,
|
|
1693
1698
|
rejectNonAsyncFunction: true,
|
|
1694
|
-
encode: enableEncryption ? (value) => `__vite_rsc_encryption_runtime.encryptActionBoundArgs(${value})` : void 0,
|
|
1695
|
-
decode: enableEncryption ? (value) => `await __vite_rsc_encryption_runtime.decryptActionBoundArgs(${value})` : void 0
|
|
1699
|
+
encode: enableEncryption ? (value, name) => `__vite_rsc_encryption_runtime.encryptActionBoundArgs(${value}, ${JSON.stringify(getActionId(name))})` : void 0,
|
|
1700
|
+
decode: enableEncryption ? (value, name) => `await __vite_rsc_encryption_runtime.decryptActionBoundArgs(${value}, ${JSON.stringify(getActionId(name))})` : void 0
|
|
1696
1701
|
});
|
|
1697
1702
|
const output = result.output;
|
|
1698
1703
|
if (!result || !output.hasChanged()) {
|
|
@@ -1742,7 +1747,7 @@ function vitePluginUseServer(useServerPluginOptions, manager) {
|
|
|
1742
1747
|
output.prepend(`import * as $$ReactClient from "${importSource}";\n`);
|
|
1743
1748
|
return {
|
|
1744
1749
|
code: output.toString(),
|
|
1745
|
-
map: output.generateMap({ hires: "boundary" })
|
|
1750
|
+
map: this.environment.mode === "build" ? { mappings: "" } : output.generateMap({ hires: "boundary" })
|
|
1746
1751
|
};
|
|
1747
1752
|
}
|
|
1748
1753
|
} }
|
|
@@ -1831,7 +1836,10 @@ function collectAssetDeps(bundle) {
|
|
|
1831
1836
|
chunk,
|
|
1832
1837
|
deps
|
|
1833
1838
|
};
|
|
1834
|
-
return
|
|
1839
|
+
return {
|
|
1840
|
+
idToDeps,
|
|
1841
|
+
chunkToDeps
|
|
1842
|
+
};
|
|
1835
1843
|
}
|
|
1836
1844
|
function collectAssetDepsInner(fileName, bundle) {
|
|
1837
1845
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -1896,7 +1904,7 @@ function vitePluginRscCss(rscCssOptions = {}, manager) {
|
|
|
1896
1904
|
if (options === false) return false;
|
|
1897
1905
|
if (options?.filter && !options.filter(filename)) return false;
|
|
1898
1906
|
if (!/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)\b/.test(code) || !/\.[tj]sx?$/.test(filename)) return false;
|
|
1899
|
-
if (!esModuleLexer.parse(code)[0].some((i) => i.
|
|
1907
|
+
if (!esModuleLexer.parse(code)[0].some((i) => i.type === "static" && i.specifier && isCSSRequest(i.specifier))) return false;
|
|
1900
1908
|
return (_name, meta) => !!(meta.isFunction && meta.declName && /^[A-Z]/.test(meta.declName) || meta.defaultExportIdentifierName && /^[A-Z]/.test(meta.defaultExportIdentifierName));
|
|
1901
1909
|
}
|
|
1902
1910
|
return [
|
|
@@ -2077,6 +2085,7 @@ function generateResourcesCode(depsCode, manager, options = {}) {
|
|
|
2077
2085
|
return React.createElement(React.Fragment, null, [...deps.css.map((href) => React.createElement("link", {
|
|
2078
2086
|
key: "css:" + href,
|
|
2079
2087
|
rel: "stylesheet",
|
|
2088
|
+
crossOrigin: "anonymous",
|
|
2080
2089
|
...precedence ? { precedence } : {},
|
|
2081
2090
|
href,
|
|
2082
2091
|
"data-rsc-css-href": href
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ResolvedAssetsManifest, c as getPluginApi, d as vitePluginRscMinimal, i as ResolvedAssetDeps, l as transformRscCssExport, n as AssetsManifest, o as RscPluginManager, r as PluginApi, s as RscPluginOptions, t as AssetDeps, u as vitePluginRsc } from "./plugin-
|
|
1
|
+
import { a as ResolvedAssetsManifest, c as getPluginApi, d as vitePluginRscMinimal, i as ResolvedAssetDeps, l as transformRscCssExport, n as AssetsManifest, o as RscPluginManager, r as PluginApi, s as RscPluginOptions, t as AssetDeps, u as vitePluginRsc } from "./plugin-C2nJizTd.js";
|
|
2
2
|
export { AssetDeps, AssetsManifest, PluginApi, ResolvedAssetDeps, ResolvedAssetsManifest, type RscPluginManager, RscPluginOptions, vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
|
package/dist/plugin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as vitePluginRscMinimal, n as transformRscCssExport, r as vitePluginRsc, t as getPluginApi } from "./plugin-
|
|
1
|
+
import { i as vitePluginRscMinimal, n as transformRscCssExport, r as vitePluginRsc, t as getPluginApi } from "./plugin-C4C80eZm.js";
|
|
2
2
|
export { vitePluginRsc as default, getPluginApi, transformRscCssExport, vitePluginRscMinimal };
|
package/dist/rsc/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as createServerManifest, o as loadServerAction, r as createClientManifest, s as setRequireModule } from "../rsc-D8UlANI2.js";
|
|
2
2
|
import { a as registerClientReference, i as decodeReply, n as decodeAction, o as registerServerReference, r as decodeFormState, t as createTemporaryReferenceSet } from "../server-YwgjVtsE.js";
|
|
3
|
-
import { t as OnClientReference } from "../client-reference-
|
|
3
|
+
import { t as OnClientReference } from "../client-reference-CWbaj3vK.js";
|
|
4
4
|
//#region src/rsc/server.d.ts
|
|
5
5
|
export declare function renderToReadableStream<T>(data: T, options?: object, extraOptions?: {
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as RenderToPipeableStreamOptions, f as PipeableStream, v as RenderToReadableStreamOptions } from "../index-CROaL0MT.js";
|
|
2
2
|
import { a as createServerManifest, o as loadServerAction, r as createClientManifest, s as setRequireModule } from "../rsc-D8UlANI2.js";
|
|
3
3
|
import { a as decodeReplyFromBusboy, i as decodeReply, n as decodeAction, o as registerClientReference, r as decodeFormState, s as registerServerReference, t as createTemporaryReferenceSet } from "../server.node-DU77AeKU.js";
|
|
4
|
-
import { t as OnClientReference } from "../client-reference-
|
|
4
|
+
import { t as OnClientReference } from "../client-reference-CWbaj3vK.js";
|
|
5
5
|
//#region src/rsc/server.node.d.ts
|
|
6
6
|
export declare function renderToReadableStream<T>(data: T, options?: RenderToReadableStreamOptions, extraOptions?: {
|
|
7
7
|
/**
|
package/dist/rsc/static.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as PrerenderResult, p as PrerenderOptions } from "../index-CROaL0MT.js";
|
|
2
|
-
import { t as OnClientReference } from "../client-reference-
|
|
2
|
+
import { t as OnClientReference } from "../client-reference-CWbaj3vK.js";
|
|
3
3
|
//#region src/rsc/static.d.ts
|
|
4
4
|
export declare function prerender<T>(data: T, options?: PrerenderOptions, extraOptions?: {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as PrerenderToNodeStreamResult, h as PrerenderToNodeStreamOptions, m as PrerenderResult, p as PrerenderOptions } from "../index-CROaL0MT.js";
|
|
2
|
-
import { t as OnClientReference } from "../client-reference-
|
|
2
|
+
import { t as OnClientReference } from "../client-reference-CWbaj3vK.js";
|
|
3
3
|
//#region src/rsc/static.node.d.ts
|
|
4
4
|
export declare function prerender<T>(data: T, options?: PrerenderOptions, extraOptions?: {
|
|
5
5
|
/**
|
package/dist/ssr.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { l as EncodeFormActionCallback } from "./index-CROaL0MT.js";
|
|
2
2
|
import { n as setRequireModule, t as createServerConsumerManifest } from "./ssr-C-U7jY5S.js";
|
|
3
3
|
import { callServer, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL } from "./react/ssr.js";
|
|
4
|
-
import { n as getClientEntryUrl, r as setOnClientReference, t as OnClientReference } from "./shared-
|
|
4
|
+
import { n as getClientEntryUrl, r as setOnClientReference, t as OnClientReference } from "./shared-Df9Nennr.js";
|
|
5
5
|
export { type EncodeFormActionCallback, OnClientReference, callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, getClientEntryUrl, setOnClientReference, setRequireModule };
|
package/dist/ssr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createServerConsumerManifest, setRequireModule } from "./core/ssr.js";
|
|
2
|
-
import { n as setOnClientReference, t as getClientEntryUrl } from "./shared-
|
|
2
|
+
import { n as setOnClientReference, t as getClientEntryUrl } from "./shared-DH8gaClP.js";
|
|
3
3
|
import { callServer, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL } from "./react/ssr.js";
|
|
4
4
|
export { callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, getClientEntryUrl, setOnClientReference, setRequireModule };
|
package/dist/ssr.node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { l as EncodeFormActionCallback } from "./index-CROaL0MT.js";
|
|
2
2
|
import { n as setRequireModule, t as createServerConsumerManifest } from "./ssr-C-U7jY5S.js";
|
|
3
3
|
import { callServer, createFromNodeStream, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL } from "./react/ssr.node.js";
|
|
4
|
-
import { n as getClientEntryUrl, r as setOnClientReference, t as OnClientReference } from "./shared-
|
|
4
|
+
import { n as getClientEntryUrl, r as setOnClientReference, t as OnClientReference } from "./shared-Df9Nennr.js";
|
|
5
5
|
export { type EncodeFormActionCallback, OnClientReference, callServer, createFromNodeStream, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, getClientEntryUrl, setOnClientReference, setRequireModule };
|
package/dist/ssr.node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createServerConsumerManifest, setRequireModule } from "./core/ssr.js";
|
|
2
|
-
import { n as setOnClientReference, t as getClientEntryUrl } from "./shared-
|
|
2
|
+
import { n as setOnClientReference, t as getClientEntryUrl } from "./shared-DH8gaClP.js";
|
|
3
3
|
import { callServer, createFromNodeStream, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL } from "./react/ssr.node.js";
|
|
4
4
|
export { callServer, createFromNodeStream, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, getClientEntryUrl, setOnClientReference, setRequireModule };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as ModuleExportSpecifier, C as TransformModuleExportEffectFilter, D as ModuleExportEntry, E as transformModuleExportEffect, F as findDirectives, I as transformHoistInlineDirective, M as TransformHoistInlineDirectiveMeta, N as TransformHoistInlineDirectiveOptions, O as ModuleExportGroup, P as TransformHoistInlineDirectiveResult, S as TransformModuleExportEffectContext, T as TransformModuleExportEffectResult, _ as transformProxyExport, a as TransformServerActionServerResult, b as TransformWrapExportResult, c as extractNames, d as rejectNonAsyncFunction, f as validateNonAsyncFunction, g as transformDirectiveProxyExport, h as TransformProxyExportResult, i as TransformServerActionServerOptions, j as scanModuleExports, k as ModuleExportMeta, l as hasDirective, m as TransformProxyExportOptions, n as TransformExpandExportAllOptions, o as transformServerActionServer, p as TransformProxyExportFilter, r as transformExpandExportAll, s as extractIdentifiers, t as TransformExpandExportAllContext, u as isDirective, v as TransformWrapExportFilter, w as TransformModuleExportEffectOptions, x as transformWrapExport, y as TransformWrapExportOptions } from "../index-
|
|
1
|
+
import { A as ModuleExportSpecifier, C as TransformModuleExportEffectFilter, D as ModuleExportEntry, E as transformModuleExportEffect, F as findDirectives, I as transformHoistInlineDirective, M as TransformHoistInlineDirectiveMeta, N as TransformHoistInlineDirectiveOptions, O as ModuleExportGroup, P as TransformHoistInlineDirectiveResult, S as TransformModuleExportEffectContext, T as TransformModuleExportEffectResult, _ as transformProxyExport, a as TransformServerActionServerResult, b as TransformWrapExportResult, c as extractNames, d as rejectNonAsyncFunction, f as validateNonAsyncFunction, g as transformDirectiveProxyExport, h as TransformProxyExportResult, i as TransformServerActionServerOptions, j as scanModuleExports, k as ModuleExportMeta, l as hasDirective, m as TransformProxyExportOptions, n as TransformExpandExportAllOptions, o as transformServerActionServer, p as TransformProxyExportFilter, r as transformExpandExportAll, s as extractIdentifiers, t as TransformExpandExportAllContext, u as isDirective, v as TransformWrapExportFilter, w as TransformModuleExportEffectOptions, x as transformWrapExport, y as TransformWrapExportOptions } from "../index-DFncbcyO.js";
|
|
2
2
|
export { ModuleExportEntry, ModuleExportGroup, ModuleExportMeta, ModuleExportSpecifier, TransformExpandExportAllContext, TransformExpandExportAllOptions, TransformHoistInlineDirectiveMeta, TransformHoistInlineDirectiveOptions, TransformHoistInlineDirectiveResult, TransformModuleExportEffectContext, TransformModuleExportEffectFilter, TransformModuleExportEffectOptions, TransformModuleExportEffectResult, TransformProxyExportFilter, TransformProxyExportOptions, TransformProxyExportResult, TransformServerActionServerOptions, TransformServerActionServerResult, TransformWrapExportFilter, TransformWrapExportOptions, TransformWrapExportResult, extractIdentifiers, extractNames, findDirectives, hasDirective, isDirective, rejectNonAsyncFunction, scanModuleExports, transformDirectiveProxyExport, transformExpandExportAll, transformHoistInlineDirective, transformModuleExportEffect, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
|
package/dist/transforms/index.js
CHANGED
|
@@ -91,25 +91,26 @@ function transformHoistInlineDirective(input, viteAst, { runtime, rejectNonAsync
|
|
|
91
91
|
const declName = node.type === "FunctionDeclaration" && node.id.name;
|
|
92
92
|
const originalName = declName || methodInfo?.name || parent?.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.id.name || "anonymous_server_function";
|
|
93
93
|
const bindVars = getBindVars(node, scopeTree);
|
|
94
|
+
const newName = `$$hoist_${names.length}` + (originalName ? `_${originalName}` : "");
|
|
95
|
+
names.push(newName);
|
|
94
96
|
let newParams = [...bindVars.map((b) => b.root), ...node.params.map((n) => input.slice(n.start, n.end))].join(", ");
|
|
95
97
|
if (bindVars.length > 0 && options.decode) {
|
|
96
98
|
newParams = ["$$hoist_encoded", ...node.params.map((n) => input.slice(n.start, n.end))].join(", ");
|
|
97
|
-
output.appendLeft(node.body.body[0].start, `const [${bindVars.map((b) => b.root).join(",")}] = ${options.decode("$$hoist_encoded")};\n`);
|
|
99
|
+
output.appendLeft(node.body.body[0].start, `const [${bindVars.map((b) => b.root).join(",")}] = ${options.decode("$$hoist_encoded", newName)};\n`);
|
|
98
100
|
}
|
|
99
|
-
const newName = `$$hoist_${names.length}` + (originalName ? `_${originalName}` : "");
|
|
100
|
-
names.push(newName);
|
|
101
101
|
const implementationName = options.hoistRuntime ? `${newName}$$impl` : newName;
|
|
102
102
|
output.update(node.start, node.body.start, `\n;${options.noExport || options.hoistRuntime ? "" : "export "}${node.async ? "async " : ""}function${node.generator ? "*" : ""} ${implementationName}(${newParams}) `);
|
|
103
103
|
const runtimeCode = `/* #__PURE__ */ ${runtime(implementationName, newName, {
|
|
104
104
|
directiveMatch: match,
|
|
105
|
-
valueNode: node
|
|
105
|
+
valueNode: node,
|
|
106
|
+
bindVars: bindVars.map((b) => b.root)
|
|
106
107
|
})}`;
|
|
107
108
|
if (options.hoistRuntime) runtimeHoists.push(`${options.noExport ? "" : "export "}const ${newName} = ${runtimeCode};\n`);
|
|
108
109
|
output.appendLeft(node.end, `;\n/* #__PURE__ */ Object.defineProperty(${implementationName}, "name", { value: ${JSON.stringify(originalName)} });\n`);
|
|
109
110
|
output.move(node.start, node.end, input.length);
|
|
110
111
|
let newCode = options.hoistRuntime ? newName : runtimeCode;
|
|
111
112
|
if (bindVars.length > 0) {
|
|
112
|
-
const bindArgs = options.encode ? options.encode("[" + bindVars.map((b) => b.expr).join(", ") + "]") : bindVars.map((b) => b.expr).join(", ");
|
|
113
|
+
const bindArgs = options.encode ? options.encode("[" + bindVars.map((b) => b.expr).join(", ") + "]", newName) : bindVars.map((b) => b.expr).join(", ");
|
|
113
114
|
newCode = `${newCode}.bind(null, ${bindArgs})`;
|
|
114
115
|
}
|
|
115
116
|
if (methodInfo) {
|
|
@@ -534,6 +535,7 @@ function transformModuleExportEffect(input, viteAst, options) {
|
|
|
534
535
|
* bindings, consistent with the other transform helpers.
|
|
535
536
|
*/
|
|
536
537
|
function transformWrapExport(input, viteAst, options) {
|
|
538
|
+
if (!input.endsWith("\n")) input += "\n";
|
|
537
539
|
const output = new MagicString(input);
|
|
538
540
|
const exportNames = [];
|
|
539
541
|
const appendedCode = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region src/utils/encryption-runtime.d.ts
|
|
2
|
-
export declare function encryptActionBoundArgs(originalValue: unknown): Promise<string>;
|
|
3
|
-
export declare function decryptActionBoundArgs(encrypted: ReturnType<typeof encryptActionBoundArgs
|
|
2
|
+
export declare function encryptActionBoundArgs(originalValue: unknown, actionId?: string): Promise<string>;
|
|
3
|
+
export declare function decryptActionBoundArgs(encrypted: ReturnType<typeof encryptActionBoundArgs>, actionId?: string): Promise<unknown>;
|
|
4
4
|
//#endregion
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { n as once } from "../shared-BWJvctW6.js";
|
|
2
|
-
import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-
|
|
2
|
+
import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-Bmw1Q82C.js";
|
|
3
3
|
import { renderToReadableStream } from "../react/rsc/server.js";
|
|
4
4
|
import encryptionKeySource from "virtual:vite-rsc/encryption-key";
|
|
5
5
|
//#region src/utils/encryption-runtime.ts
|
|
6
|
-
async function encryptActionBoundArgs(originalValue) {
|
|
6
|
+
async function encryptActionBoundArgs(originalValue, actionId) {
|
|
7
7
|
const serialized = renderToReadableStream(originalValue);
|
|
8
8
|
const serializedBuffer = await concatArrayStream(serialized);
|
|
9
|
-
return encryptBuffer(serializedBuffer, await getEncryptionKey());
|
|
9
|
+
return encryptBuffer(serializedBuffer, await getEncryptionKey(), toAdditionalData(actionId));
|
|
10
10
|
}
|
|
11
|
-
async function decryptActionBoundArgs(encrypted) {
|
|
12
|
-
const [{ createFromReadableStream }, serializedBuffer] = await Promise.all([import("../react/rsc/client.js"), decryptBuffer(await encrypted, await getEncryptionKey())]);
|
|
11
|
+
async function decryptActionBoundArgs(encrypted, actionId) {
|
|
12
|
+
const [{ createFromReadableStream }, serializedBuffer] = await Promise.all([import("../react/rsc/client.js"), decryptBuffer(await encrypted, await getEncryptionKey(), toAdditionalData(actionId))]);
|
|
13
13
|
return createFromReadableStream(arrayToStream(new Uint8Array(serializedBuffer)));
|
|
14
14
|
}
|
|
15
|
+
function toAdditionalData(actionId) {
|
|
16
|
+
return actionId === void 0 ? void 0 : new TextEncoder().encode(actionId);
|
|
17
|
+
}
|
|
15
18
|
const getEncryptionKey = /* #__PURE__ */ once(async () => {
|
|
16
19
|
const resolved = await encryptionKeySource();
|
|
17
20
|
return await crypto.subtle.importKey("raw", fromBase64(resolved), { name: "AES-GCM" }, true, ["encrypt", "decrypt"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-rsc",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.37",
|
|
4
4
|
"description": "React Server Components (RSC) support for Vite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -40,22 +40,23 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@rolldown/pluginutils": "^1.0.1",
|
|
43
|
-
"es-module-lexer": "^
|
|
43
|
+
"es-module-lexer": "^3.0.3",
|
|
44
44
|
"estree-walker": "^3.0.3",
|
|
45
|
-
"magic-string": "^1.
|
|
45
|
+
"magic-string": "^1.4.3",
|
|
46
46
|
"obug": "^3.0.0",
|
|
47
|
-
"srvx": "^0.
|
|
47
|
+
"srvx": "^1.0.5",
|
|
48
48
|
"strip-literal": "^4.0.0",
|
|
49
49
|
"turbo-stream": "^3.2.1",
|
|
50
50
|
"vitefu": "^1.1.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@playwright/test": "^1.
|
|
53
|
+
"@playwright/test": "^1.63.0",
|
|
54
54
|
"@tsconfig/strictest": "^2.0.8",
|
|
55
55
|
"@types/estree": "^1.0.9",
|
|
56
|
-
"@types/node": "^24.
|
|
56
|
+
"@types/node": "^24.19.1",
|
|
57
57
|
"@types/react": "^19.3.0",
|
|
58
58
|
"@types/react-dom": "^19.3.0",
|
|
59
|
+
"@typescript/typescript6": "^6.0.2",
|
|
59
60
|
"@vitejs/plugin-react": "workspace:*",
|
|
60
61
|
"@vitejs/test-dep-cjs-and-esm": "./test-dep/cjs-and-esm",
|
|
61
62
|
"@vitejs/test-dep-cjs-falsy-primitive": "./test-dep/cjs-falsy-primitive",
|
|
@@ -63,7 +64,7 @@
|
|
|
63
64
|
"react": "^19.3.0",
|
|
64
65
|
"react-dom": "^19.3.0",
|
|
65
66
|
"react-server-dom-webpack": "^19.3.0",
|
|
66
|
-
"tinyexec": "^1.3.
|
|
67
|
+
"tinyexec": "^1.3.1",
|
|
67
68
|
"tsdown": "^0.23.0"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|