@vitejs/plugin-rsc 0.5.36 → 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-DibqjEBF.js → picocolors-BPyd8zCA.js} +1 -1
- package/dist/{plugin-CKqXjp8D.d.ts → plugin-C2nJizTd.d.ts} +16 -5
- package/dist/{plugin-Bqv0ikDW.js → plugin-C4C80eZm.js} +6 -5
- 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-DJBuYpZL.d.ts → shared-Df9Nennr.d.ts} +1 -1
- package/dist/ssr.d.ts +1 -1
- package/dist/ssr.node.d.ts +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 +2 -1
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";
|
|
@@ -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
|
};
|
|
@@ -1692,11 +1692,12 @@ function vitePluginUseServer(useServerPluginOptions, manager) {
|
|
|
1692
1692
|
if (this.environment.name === serverEnvironmentName) {
|
|
1693
1693
|
const transformServerActionServer_ = withRollupError(this, transformServerActionServer);
|
|
1694
1694
|
const enableEncryption = useServerPluginOptions.enableActionEncryption ?? true;
|
|
1695
|
+
const getActionId = (name) => `${getServerReference().referenceKey}#${name}`;
|
|
1695
1696
|
const result = transformServerActionServer_(code, ast, {
|
|
1696
1697
|
runtime: (value, name) => `$$ReactServer.registerServerReference(${value}, ${JSON.stringify(getServerReference().referenceKey)}, ${JSON.stringify(name)})`,
|
|
1697
1698
|
rejectNonAsyncFunction: true,
|
|
1698
|
-
encode: enableEncryption ? (value) => `__vite_rsc_encryption_runtime.encryptActionBoundArgs(${value})` : void 0,
|
|
1699
|
-
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
|
|
1700
1701
|
});
|
|
1701
1702
|
const output = result.output;
|
|
1702
1703
|
if (!result || !output.hasChanged()) {
|
|
@@ -1746,7 +1747,7 @@ function vitePluginUseServer(useServerPluginOptions, manager) {
|
|
|
1746
1747
|
output.prepend(`import * as $$ReactClient from "${importSource}";\n`);
|
|
1747
1748
|
return {
|
|
1748
1749
|
code: output.toString(),
|
|
1749
|
-
map: output.generateMap({ hires: "boundary" })
|
|
1750
|
+
map: this.environment.mode === "build" ? { mappings: "" } : output.generateMap({ hires: "boundary" })
|
|
1750
1751
|
};
|
|
1751
1752
|
}
|
|
1752
1753
|
} }
|
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.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 };
|
|
@@ -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",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
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",
|