Unverified Commit c54b8a3a authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Assign proper function names to server actions (#71478)

This PR adjusts the server action transforms to assign proper function names for the generated server reference proxies.

- If the original function has a name, this name is used.
- If a function expression is assigned to a variable, the variable's name is used.
- If an anonymous function expression is assigned to a prop, the prop's name is used.

In addition, this PR simplifies the output for exported functions, avoiding unnecessary `registerServerReference` calls.

It also fixes the source mapping of default exported server actions.

**Before:**

<img width="890" alt="before" src="https://github.com/user-attachments/assets/a3d6a5f8-d48e-474d-8f03-b49306fb704f">

**After:**

<img width="890" alt="after" src="https://github.com/user-attachments/assets/8f332690-6c26-46f1-9eef-7680f47ea578">

Next up, we will do the same for `'use cache'` functions.
parent 1f462140
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export default registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); export default (()=>{});
export async function $$RSC_SERVER_ACTION_0() {}
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export const $$RSC_SERVER_ACTION_0 = async function foo() {};
const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export async function $$RSC_SERVER_ACTION_0() {}
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); export const $$RSC_SERVER_ACTION_0 = async function foo() {
export async function $$RSC_SERVER_ACTION_0() {
'use strict'; 'use strict';
} };
const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
const bar = async ()=>{ const bar = async ()=>{
const x = 1; const x = 1;
// prettier-ignore // prettier-ignore
......
/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper";
export default /*#__PURE__*/ createServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", callServer, void 0, findSourceMapURL, "default");
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import deleteFromDb from 'db'; import deleteFromDb from 'db';
export const $$RSC_SERVER_ACTION_0 = async function deleteItem($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb($$ACTION_ARG_1);
};
export function Item({ id1, id2 }) { export function Item({ id1, id2 }) {
var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
id1, id1,
...@@ -8,11 +13,11 @@ export function Item({ id1, id2 }) { ...@@ -8,11 +13,11 @@ export function Item({ id1, id2 }) {
])); ]));
return <Button action={deleteItem}>Delete</Button>; return <Button action={deleteItem}>Delete</Button>;
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) { export const $$RSC_SERVER_ACTION_1 = async function action($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0); console.log($$ACTION_ARG_0);
await deleteFromDb($$ACTION_ARG_1); console.log($$ACTION_ARG_1);
} };
export default function Home() { export default function Home() {
const info = { const info = {
name: 'John', name: 'John',
...@@ -24,8 +29,3 @@ export default function Home() { ...@@ -24,8 +29,3 @@ export default function Home() {
])); ]));
return null; return null;
} }
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
console.log($$ACTION_ARG_0);
console.log($$ACTION_ARG_1);
}
/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export default async function $$RSC_SERVER_ACTION_0() {} export default async function $$RSC_SERVER_ACTION_0() {}
Object.defineProperty($$RSC_SERVER_ACTION_0, "name", {
"value": "default",
"writable": false
});
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([ ensureServerEntryExports([
$$RSC_SERVER_ACTION_0 $$RSC_SERVER_ACTION_0
......
/* __next_internal_action_entry_do_not_use__ {"90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export default $$RSC_SERVER_ACTION_0 = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null); export default $$RSC_SERVER_ACTION_0 = async (a, b)=>{
var $$RSC_SERVER_ACTION_0;
export async function $$RSC_SERVER_ACTION_1(a, b) {
console.log(a, b); console.log(a, b);
} };
var $$RSC_SERVER_ACTION_0;
Object.defineProperty($$RSC_SERVER_ACTION_0, "name", {
"value": "default",
"writable": false
});
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([ ensureServerEntryExports([
$$RSC_SERVER_ACTION_0 $$RSC_SERVER_ACTION_0
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import deleteFromDb from 'db'; import deleteFromDb from 'db';
const v1 = 'v1'; const v1 = 'v1';
export const $$RSC_SERVER_ACTION_0 = async function deleteItem($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb(v1);
await deleteFromDb($$ACTION_ARG_1);
};
export function Item({ id1, id2 }) { export function Item({ id1, id2 }) {
const v2 = id2; const v2 = id2;
const deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ const deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
...@@ -10,27 +16,21 @@ export function Item({ id1, id2 }) { ...@@ -10,27 +16,21 @@ export function Item({ id1, id2 }) {
])); ]));
return <Button action={deleteItem}>Delete</Button>; return <Button action={deleteItem}>Delete</Button>;
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) { export const $$RSC_SERVER_ACTION_1 = async function g($$ACTION_CLOSURE_BOUND, y, ...z) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0); return $$ACTION_ARG_0 + y + z[0];
await deleteFromDb(v1); };
await deleteFromDb($$ACTION_ARG_1);
}
const f = (x)=>{ const f = (x)=>{
var g = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ var g = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
x x
])); ]));
}; };
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND, y, ...z) { export const $$RSC_SERVER_ACTION_2 = async function f($$ACTION_CLOSURE_BOUND, y, ...z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND);
return $$ACTION_ARG_0 + y + z[0]; return $$ACTION_ARG_0 + y + z[0];
} };
const g = (x)=>{ const g = (x)=>{
f = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ f = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
x x
])); ]));
}; };
export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, y, ...z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND);
return $$ACTION_ARG_0 + y + z[0];
}
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo","ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo","ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); export const foo = async ()=>{};
export async function $$RSC_SERVER_ACTION_0() {}
const bar = async ()=>{}; const bar = async ()=>{};
export { bar }; export { bar };
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; import { ensureServerEntryExports } from "private-next-rsc-action-validate";
......
/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import deleteFromDb from 'db'; import deleteFromDb from 'db';
const v1 = 'v1'; const v1 = 'v1';
export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb(v1);
await deleteFromDb($$ACTION_ARG_1);
};
export const $$RSC_SERVER_ACTION_1 = async function action($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb(v1);
await deleteFromDb($$ACTION_ARG_1);
};
export function Item({ id1, id2 }) { export function Item({ id1, id2 }) {
const v2 = id2; const v2 = id2;
return <> return <>
...@@ -11,7 +23,7 @@ export function Item({ id1, id2 }) { ...@@ -11,7 +23,7 @@ export function Item({ id1, id2 }) {
]))}> ]))}>
Delete Delete
</Button> </Button>
<Button action={registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ <Button action={registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
id1, id1,
v2 v2
]))}> ]))}>
...@@ -19,15 +31,3 @@ export function Item({ id1, id2 }) { ...@@ -19,15 +31,3 @@ export function Item({ id1, id2 }) {
</Button> </Button>
</>; </>;
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb(v1);
await deleteFromDb($$ACTION_ARG_1);
}
export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb(v1);
await deleteFromDb($$ACTION_ARG_1);
}
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND, value2) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
return $$ACTION_ARG_0 * value2;
};
export function Item({ value }) { export function Item({ value }) {
return <> return <>
<Button action={registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ <Button action={registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
...@@ -9,7 +13,3 @@ export function Item({ value }) { ...@@ -9,7 +13,3 @@ export function Item({ value }) {
</Button> </Button>
</>; </>;
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND, value2) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
return $$ACTION_ARG_0 * value2;
}
...@@ -7,6 +7,7 @@ export default function Page() { ...@@ -7,6 +7,7 @@ export default function Page() {
return <Button action={myAction}>Delete</Button> return <Button action={myAction}>Delete</Button>
} }
// TODO: should use `action` as function name?
export const action = withValidate(async () => { export const action = withValidate(async () => {
'use server' 'use server'
}) })
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); export const $$RSC_SERVER_ACTION_0 = async function myAction(a, b, c) {
export async function $$RSC_SERVER_ACTION_0(a, b, c) {
console.log('a'); console.log('a');
} };
var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export default function Page() { export default function Page() {
return <Button action={myAction}>Delete</Button>; return <Button action={myAction}>Delete</Button>;
} }
export const $$RSC_SERVER_ACTION_1 = async function() {};
// TODO: should use `action` as function name?
export const action = withValidate(registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null)); export const action = withValidate(registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null));
export async function $$RSC_SERVER_ACTION_1() {}
...@@ -6,6 +6,7 @@ export default function Page() { ...@@ -6,6 +6,7 @@ export default function Page() {
const y = 1 const y = 1
return ( return (
<Foo <Foo
// TODO: should use `action` as function name?
action={validator(async function (z) { action={validator(async function (z) {
'use server' 'use server'
return x + y + z return x + y + z
......
/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import { validator, another } from 'auth'; import { validator, another } from 'auth';
const x = 1; const x = 1;
export const $$RSC_SERVER_ACTION_0 = async function($$ACTION_CLOSURE_BOUND, z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
return x + $$ACTION_ARG_0 + z;
};
export default function Page() { export default function Page() {
const y = 1; const y = 1;
return <Foo action={validator(registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ return <Foo // TODO: should use `action` as function name?
action={validator(registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
y y
])))}/>; ])))}/>;
} }
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND, z) { export const $$RSC_SERVER_ACTION_1 = async function() {};
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); validator(registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null));
return x + $$ACTION_ARG_0 + z; export const $$RSC_SERVER_ACTION_2 = async function() {};
} another(validator(registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null)));
validator(registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null));
export async function $$RSC_SERVER_ACTION_2() {}
another(validator(registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null)));
export async function $$RSC_SERVER_ACTION_3() {}
/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default","f14702b5a021dd117f7ec7a3c838f397c2046d3b":"action"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default","f14702b5a021dd117f7ec7a3c838f397c2046d3b":"action"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import { validator } from 'auth'; import { validator } from 'auth';
export const action = validator(registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null)); export const action = validator(async ()=>{});
export async function $$RSC_SERVER_ACTION_0() {} export default $$RSC_SERVER_ACTION_0 = validator(async ()=>{});
export default $$RSC_SERVER_ACTION_1 = validator(registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null)); var $$RSC_SERVER_ACTION_0;
var $$RSC_SERVER_ACTION_1; Object.defineProperty($$RSC_SERVER_ACTION_0, "name", {
export async function $$RSC_SERVER_ACTION_2() {} "value": "default",
"writable": false
});
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([ ensureServerEntryExports([
action, action,
$$RSC_SERVER_ACTION_1 $$RSC_SERVER_ACTION_0
]); ]);
registerServerReference(action, "f14702b5a021dd117f7ec7a3c838f397c2046d3b", null); registerServerReference(action, "f14702b5a021dd117f7ec7a3c838f397c2046d3b", null);
registerServerReference($$RSC_SERVER_ACTION_1, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); registerServerReference($$RSC_SERVER_ACTION_0, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null);
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND, a, b, c, d) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log(a, b, $$ACTION_ARG_0, c, d);
};
export const $$RSC_SERVER_ACTION_1 = async function action2($$ACTION_CLOSURE_BOUND, a, b, c, d) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
console.log(a, b, $$ACTION_ARG_0, c, d);
};
export default function Page({ foo, x, y }) { export default function Page({ foo, x, y }) {
var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
x x
])); ]));
action.bind(null, foo[0], foo[1], foo.x, foo[y]); action.bind(null, foo[0], foo[1], foo.x, foo[y]);
const action2 = registerServerReference($$RSC_SERVER_ACTION_1,"90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ const action2 = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
x x
])); ]));
action2.bind(null, foo[0], foo[1], foo.x, foo[y]); action2.bind(null, foo[0], foo[1], foo.x, foo[y]);
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND, a, b, c, d) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log(a, b, $$ACTION_ARG_0, c, d);
}
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND, a, b, c, d) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
console.log(a, b, $$ACTION_ARG_0, c, d);
}
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND, a, b, c, { d }) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log(a, b, $$ACTION_ARG_0, d);
};
export default function Page({ foo, x, y }) { export default function Page({ foo, x, y }) {
var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
foo foo
])); ]));
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND, a, b, c, { d }) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log(a, b, $$ACTION_ARG_0, d);
}
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import deleteFromDb from 'db'; import deleteFromDb from 'db';
export const $$RSC_SERVER_ACTION_0 = async function deleteItem($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb($$ACTION_ARG_1);
};
export function Item({ id1, id2 }) { export function Item({ id1, id2 }) {
id1++; id1++;
return (()=>{ return (()=>{
...@@ -12,11 +17,11 @@ export function Item({ id1, id2 }) { ...@@ -12,11 +17,11 @@ export function Item({ id1, id2 }) {
id2 id2
])); ]));
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) { export const $$RSC_SERVER_ACTION_1 = async function deleteItem($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0); await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb($$ACTION_ARG_1); await deleteFromDb($$ACTION_ARG_1);
} };
// In this example, if Button immediately executes the action, different ids should // In this example, if Button immediately executes the action, different ids should
// be passed. // be passed.
export function Item2({ id1, id2 }) { export function Item2({ id1, id2 }) {
...@@ -31,8 +36,3 @@ export function Item2({ id1, id2 }) { ...@@ -31,8 +36,3 @@ export function Item2({ id1, id2 }) {
id2 id2
])); ]));
} }
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb($$ACTION_ARG_1);
}
const noop = (action) => action const noop = (action) => action
// TODO: should use `log` as function name?
export const log = noop(async (data) => { export const log = noop(async (data) => {
'use server' 'use server'
console.log(data) console.log(data)
......
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
const noop = (action)=>action; const noop = (action)=>action;
export const log = noop(registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null)); export const $$RSC_SERVER_ACTION_0 = async function(data) {
export async function $$RSC_SERVER_ACTION_0(data) {
console.log(data); console.log(data);
} };
// TODO: should use `log` as function name?
export const log = noop(registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null));
...@@ -3,24 +3,24 @@ ...@@ -3,24 +3,24 @@
// 2. Actual action functions should be renamed to `$$ACTION_...` and got exported. // 2. Actual action functions should be renamed to `$$ACTION_...` and got exported.
/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","a9b2939c1f39073a6bed227fd20233064c8b7869":"$$RSC_SERVER_ACTION_4"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","a9b2939c1f39073a6bed227fd20233064c8b7869":"$$RSC_SERVER_ACTION_4"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
var foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); export const $$RSC_SERVER_ACTION_0 = async function foo() {
export async function $$RSC_SERVER_ACTION_0() {
console.log(1); console.log(1);
} };
var foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export { foo }; export { foo };
export var bar = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null); export const $$RSC_SERVER_ACTION_1 = async function bar() {
export async function $$RSC_SERVER_ACTION_1() {
console.log(2); console.log(2);
} };
export default registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null); export var bar = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null);
export async function $$RSC_SERVER_ACTION_2() { export const $$RSC_SERVER_ACTION_2 = async function baz() {
console.log(3); console.log(3);
} };
export const qux = registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null); export default registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null);
export async function $$RSC_SERVER_ACTION_3() { export const $$RSC_SERVER_ACTION_3 = async function qux() {
console.log(4); console.log(4);
} };
export const quux = registerServerReference($$RSC_SERVER_ACTION_4, "a9b2939c1f39073a6bed227fd20233064c8b7869", null); export const qux = registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null);
export async function $$RSC_SERVER_ACTION_4() { export const $$RSC_SERVER_ACTION_4 = async function quuux() {
console.log(5); console.log(5);
} };
export const quux = registerServerReference($$RSC_SERVER_ACTION_4, "a9b2939c1f39073a6bed227fd20233064c8b7869", null);
/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
let a, f; let a, f;
function Comp(b, c, ...g) { export const $$RSC_SERVER_ACTION_0 = async function action2($$ACTION_CLOSURE_BOUND, e) {
return registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
b,
c,
g
]));
}
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND, e) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log(a, $$ACTION_ARG_0, $$ACTION_ARG_1, e, $$ACTION_ARG_2, $$ACTION_ARG_3); console.log(a, $$ACTION_ARG_0, $$ACTION_ARG_1, e, $$ACTION_ARG_2, $$ACTION_ARG_3);
} };
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND, e) { export const $$RSC_SERVER_ACTION_1 = async function action3($$ACTION_CLOSURE_BOUND, e) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
$$ACTION_ARG_0(e); $$ACTION_ARG_0(e);
console.log(a, $$ACTION_ARG_1, $$ACTION_ARG_2, e); console.log(a, $$ACTION_ARG_1, $$ACTION_ARG_2, e);
} };
export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, d) { export const $$RSC_SERVER_ACTION_2 = async function action1($$ACTION_CLOSURE_BOUND, d) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND);
let f; let f;
console.log(...window, { console.log(...window, {
...@@ -38,4 +31,11 @@ export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, d) { ...@@ -38,4 +31,11 @@ export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, d) {
d d
])) ]))
]; ];
};
function Comp(b, c, ...g) {
return registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
b,
c,
g
]));
} }
/* __next_internal_action_entry_do_not_use__ {"28baf972d345b86b747ad0df73d75a0088a42214":"dec","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"28baf972d345b86b747ad0df73d75a0088a42214":"dec","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export const dec = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); export const dec = async (value)=>{
export async function $$RSC_SERVER_ACTION_0(value) {
return value - 1; return value - 1;
} };
// Test case for https://github.com/vercel/next.js/issues/54655 // Test case for https://github.com/vercel/next.js/issues/54655
export default dec; export default dec;
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; import { ensureServerEntryExports } from "private-next-rsc-action-validate";
......
/* __next_internal_action_entry_do_not_use__ {"0090eaf4e1f08a2d94f6be401e54a2ded399b87c":"action0","1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"0090eaf4e1f08a2d94f6be401e54a2ded399b87c":"action0","1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
let a, f; let a, f;
export async function action0(b, c, ...g) { export const $$RSC_SERVER_ACTION_0 = async function action2($$ACTION_CLOSURE_BOUND, e) {
return registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
b,
c,
g
]));
}
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND, e) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log(a, $$ACTION_ARG_0, $$ACTION_ARG_1, e, $$ACTION_ARG_2, $$ACTION_ARG_3); console.log(a, $$ACTION_ARG_0, $$ACTION_ARG_1, e, $$ACTION_ARG_2, $$ACTION_ARG_3);
} };
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND, e) { export const $$RSC_SERVER_ACTION_1 = async function action3($$ACTION_CLOSURE_BOUND, e) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
$$ACTION_ARG_0(e); $$ACTION_ARG_0(e);
console.log(a, $$ACTION_ARG_1, $$ACTION_ARG_2, e); console.log(a, $$ACTION_ARG_1, $$ACTION_ARG_2, e);
} };
export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, d) { export const $$RSC_SERVER_ACTION_2 = async function action1($$ACTION_CLOSURE_BOUND, d) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND);
let f; let f;
console.log(...window, { console.log(...window, {
...@@ -38,6 +31,13 @@ export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, d) { ...@@ -38,6 +31,13 @@ export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, d) {
d d
])) ]))
]; ];
};
export async function action0(b, c, ...g) {
return registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
b,
c,
g
]));
} }
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([ ensureServerEntryExports([
......
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log($$ACTION_ARG_0.at(1), $$ACTION_ARG_1, $$ACTION_ARG_1.current);
console.log($$ACTION_ARG_2.push.call($$ACTION_ARG_2, 5));
};
export function Component() { export function Component() {
const data = [ const data = [
1, 1,
...@@ -23,8 +28,3 @@ export function Component() { ...@@ -23,8 +28,3 @@ export function Component() {
])); ]));
return <form action={action}/>; return <form action={action}/>;
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log($$ACTION_ARG_0.at(1), $$ACTION_ARG_1, $$ACTION_ARG_1.current);
console.log($$ACTION_ARG_2.push.call($$ACTION_ARG_2, 5));
}
...@@ -4,10 +4,10 @@ export async function a() {} ...@@ -4,10 +4,10 @@ export async function a() {}
export async function b() {} export async function b() {}
export async function c() {} export async function c() {}
function d() {} function d() {}
export const $$RSC_SERVER_ACTION_0 = async function e() {};
function Foo() { function Foo() {
var e = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); var e = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
} }
export async function $$RSC_SERVER_ACTION_0() {}
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([ ensureServerEntryExports([
a, a,
......
...@@ -11,6 +11,15 @@ export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788 ...@@ -11,6 +11,15 @@ export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788
} }
]; ];
}); });
export const $$RSC_SERVER_ACTION_2 = async function action($$ACTION_CLOSURE_BOUND, c) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND);
const d = $$ACTION_ARG_0 + $$ACTION_ARG_1 + c;
var cache = $$RSC_SERVER_REF_1.bind(null, encryptActionBoundArgs("3128060c414d59f8552e4788b846c0d2b7f74743", [
d,
$$ACTION_ARG_0
]));
return cache(d);
};
async function Component({ a }) { async function Component({ a }) {
const b = 1; const b = 1;
var action = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [ var action = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
...@@ -22,12 +31,3 @@ async function Component({ a }) { ...@@ -22,12 +31,3 @@ async function Component({ a }) {
</form>; </form>;
} }
var $$RSC_SERVER_REF_1 = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null); var $$RSC_SERVER_REF_1 = registerServerReference($$RSC_SERVER_CACHE_0, "3128060c414d59f8552e4788b846c0d2b7f74743", null);
export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, c) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND);
const d = $$ACTION_ARG_0 + $$ACTION_ARG_1 + c;
var cache = $$RSC_SERVER_REF_1.bind(null, encryptActionBoundArgs("3128060c414d59f8552e4788b846c0d2b7f74743", [
d,
$$ACTION_ARG_0
]));
return cache(d);
}
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","951c375b4a6a6e89d67b743ec5808127cfde405d":"$$RSC_SERVER_CACHE_1"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper";
export const $$RSC_SERVER_ACTION_0 = async function fn($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log($$ACTION_ARG_0);
return {
foo: $$ACTION_ARG_1
};
};
export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743ec5808127cfde405d", async function Component({ foo }) { export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743ec5808127cfde405d", async function Component({ foo }) {
const a = 123; const a = 123;
var fn = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ var fn = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
...@@ -11,10 +18,3 @@ export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743e ...@@ -11,10 +18,3 @@ export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743e
return <div>{data}</div>; return <div>{data}</div>;
}); });
export var Component = registerServerReference($$RSC_SERVER_CACHE_1, "951c375b4a6a6e89d67b743ec5808127cfde405d", null); export var Component = registerServerReference($$RSC_SERVER_CACHE_1, "951c375b4a6a6e89d67b743ec5808127cfde405d", null);
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log($$ACTION_ARG_0);
return {
foo: $$ACTION_ARG_1
};
}
...@@ -3,6 +3,10 @@ import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc ...@@ -3,6 +3,10 @@ import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper"; import { cache as $$cache__ } from "private-next-rsc-cache-wrapper";
import { Foo } from './client'; import { Foo } from './client';
const secret = 'my password is qwerty123'; const secret = 'my password is qwerty123';
export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log(secret, $$ACTION_ARG_0);
};
export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743ec5808127cfde405d", async function getCachedRandom(x, children) { export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743ec5808127cfde405d", async function getCachedRandom(x, children) {
return { return {
x, x,
...@@ -14,7 +18,3 @@ export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743e ...@@ -14,7 +18,3 @@ export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743e
}; };
}); });
var getCachedRandom = registerServerReference($$RSC_SERVER_CACHE_1, "951c375b4a6a6e89d67b743ec5808127cfde405d", null); var getCachedRandom = registerServerReference($$RSC_SERVER_CACHE_1, "951c375b4a6a6e89d67b743ec5808127cfde405d", null);
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
console.log(secret, $$ACTION_ARG_0);
}
import { Form } from './form'
export default function Page() {
const foo = async () => {
'use server'
return 'declarator arrow function expression'
}
async function bar() {
'use server'
return 'function declaration'
}
return (
<>
<Form action={foo} />
<Form action={bar} />
<Form
action={async () => {
'use server'
return 'arrow function expression'
}}
/>
<Form
action={async function () {
'use server'
return 'anonymous function expression'
}}
/>
<Form
action={async function baz() {
'use server'
return 'named function expression'
}}
/>
</>
)
}
/* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","a9b2939c1f39073a6bed227fd20233064c8b7869":"$$RSC_SERVER_ACTION_4"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import { Form } from './form';
export const $$RSC_SERVER_ACTION_0 = async function foo() {
return 'declarator arrow function expression';
};
export const $$RSC_SERVER_ACTION_1 = async function bar() {
return 'function declaration';
};
export const $$RSC_SERVER_ACTION_2 = async function action() {
return 'arrow function expression';
};
export const $$RSC_SERVER_ACTION_3 = async function action() {
return 'anonymous function expression';
};
export const $$RSC_SERVER_ACTION_4 = async function baz() {
return 'named function expression';
};
export default function Page() {
const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
var bar = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null);
return <>
<Form action={foo}/>
<Form action={bar}/>
<Form action={registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null)}/>
<Form action={registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null)}/>
<Form action={registerServerReference($$RSC_SERVER_ACTION_4, "a9b2939c1f39073a6bed227fd20233064c8b7869", null)}/>
</>;
}
...@@ -2,6 +2,16 @@ ...@@ -2,6 +2,16 @@
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import deleteFromDb from 'db'; import deleteFromDb from 'db';
const v1 = 'v1'; const v1 = 'v1';
export const $$RSC_SERVER_ACTION_0 = async function deleteItem($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb(v1);
await deleteFromDb($$ACTION_ARG_1);
await deleteFromDb({
id3: $$ACTION_ARG_2
});
await deleteFromDb($$ACTION_ARG_3);
};
export function Item({ id1, id2, id3, id4 }) { export function Item({ id1, id2, id3, id4 }) {
const v2 = id2; const v2 = id2;
var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
...@@ -12,13 +22,3 @@ export function Item({ id1, id2, id3, id4 }) { ...@@ -12,13 +22,3 @@ export function Item({ id1, id2, id3, id4 }) {
])); ]));
return <Button action={deleteItem}>Delete</Button>; return <Button action={deleteItem}>Delete</Button>;
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0);
await deleteFromDb(v1);
await deleteFromDb($$ACTION_ARG_1);
await deleteFromDb({
id3: $$ACTION_ARG_2
});
await deleteFromDb($$ACTION_ARG_3);
}
...@@ -12,6 +12,15 @@ function x() { ...@@ -12,6 +12,15 @@ function x() {
const f2 = 1; const f2 = 1;
const g201 = 1; const g201 = 1;
} }
export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3, $$ACTION_ARG_4, $$ACTION_ARG_5] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
const f17 = 1;
if (true) {
const f18 = 1;
const f19 = 1;
}
console.log(f, f1, $$ACTION_ARG_0, f3, f4, f5, f6, f7, f8, $$ACTION_ARG_0(f9), f12, $$ACTION_ARG_1, f16.x, f17, f18, $$ACTION_ARG_2, $$ACTION_ARG_3, $$ACTION_ARG_4, $$ACTION_ARG_5, g19, g20, globalThis);
};
export function y(p, [p1, { p2 }], ...p3) { export function y(p, [p1, { p2 }], ...p3) {
const f2 = 1; const f2 = 1;
const f11 = 1; const f11 = 1;
...@@ -29,12 +38,3 @@ export function y(p, [p1, { p2 }], ...p3) { ...@@ -29,12 +38,3 @@ export function y(p, [p1, { p2 }], ...p3) {
])); ]));
return <Button action={action}>Delete</Button>; return <Button action={action}>Delete</Button>;
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3, $$ACTION_ARG_4, $$ACTION_ARG_5] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
const f17 = 1;
if (true) {
const f18 = 1;
const f19 = 1;
}
console.log(f, f1, $$ACTION_ARG_0, f3, f4, f5, f6, f7, f8, $$ACTION_ARG_0(f9), f12, $$ACTION_ARG_1, f16.x, f17, f18, $$ACTION_ARG_2, $$ACTION_ARG_3, $$ACTION_ARG_4, $$ACTION_ARG_5, g19, g20, globalThis);
}
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3","a9b2939c1f39073a6bed227fd20233064c8b7869":"$$RSC_SERVER_ACTION_4"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","9ed0cc47abc4e1c64320cf42b74ae60b58c40f00":"$$RSC_SERVER_ACTION_3"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import deleteFromDb from 'db'; import deleteFromDb from 'db';
export const $$RSC_SERVER_ACTION_0 = async function deleteItem1($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]);
};
export function Item1(product, foo, bar) { export function Item1(product, foo, bar) {
const a = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [ const a = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
product, product,
...@@ -9,10 +13,10 @@ export function Item1(product, foo, bar) { ...@@ -9,10 +13,10 @@ export function Item1(product, foo, bar) {
])); ]));
return <Button action={a}>Delete</Button>; return <Button action={a}>Delete</Button>;
} }
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) { export const $$RSC_SERVER_ACTION_1 = async function deleteItem2($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]); await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]);
} };
export function Item2(product, foo, bar) { export function Item2(product, foo, bar) {
var deleteItem2 = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [ var deleteItem2 = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
product, product,
...@@ -21,31 +25,27 @@ export function Item2(product, foo, bar) { ...@@ -21,31 +25,27 @@ export function Item2(product, foo, bar) {
])); ]));
return <Button action={deleteItem2}>Delete</Button>; return <Button action={deleteItem2}>Delete</Button>;
} }
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND) { export const $$RSC_SERVER_ACTION_2 = async function deleteItem3($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]); await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]);
} };
export function Item3(product, foo, bar) { export function Item3(product, foo, bar) {
const deleteItem3 = registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null).bind(null, encryptActionBoundArgs("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", [ const deleteItem3 = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
product, product,
foo, foo,
bar bar
])); ]));
return <Button action={deleteItem3}>Delete</Button>; return <Button action={deleteItem3}>Delete</Button>;
} }
export async function $$RSC_SERVER_ACTION_3($$ACTION_CLOSURE_BOUND) { export const $$RSC_SERVER_ACTION_3 = async function deleteItem4($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", $$ACTION_CLOSURE_BOUND); var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]); await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]);
} };
export function Item4(product, foo, bar) { export function Item4(product, foo, bar) {
const deleteItem4 = registerServerReference($$RSC_SERVER_ACTION_4, "a9b2939c1f39073a6bed227fd20233064c8b7869", null).bind(null, encryptActionBoundArgs("a9b2939c1f39073a6bed227fd20233064c8b7869", [ const deleteItem4 = registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null).bind(null, encryptActionBoundArgs("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", [
product, product,
foo, foo,
bar bar
])); ]));
return <Button action={deleteItem4}>Delete</Button>; return <Button action={deleteItem4}>Delete</Button>;
} }
export async function $$RSC_SERVER_ACTION_4($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("a9b2939c1f39073a6bed227fd20233064c8b7869", $$ACTION_CLOSURE_BOUND);
await deleteFromDb($$ACTION_ARG_0.id, $$ACTION_ARG_0?.foo, $$ACTION_ARG_0.bar.baz, $$ACTION_ARG_0[$$ACTION_ARG_1, $$ACTION_ARG_2]);
}
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference"; /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null); export const $$RSC_SERVER_ACTION_0 = async function myAction(a, b, c) {
export async function $$RSC_SERVER_ACTION_0(a, b, c) {
// comment // comment
'use strict'; 'use strict';
console.log('a'); console.log('a');
} };
var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export default function Page() { export default function Page() {
return <Button action={myAction}>Delete</Button>; return <Button action={myAction}>Delete</Button>;
} }
'use server'
export async function foo() {
return 'result'
}
export async function bar() {
return 'result'
}
'use server'
export const foo = async () => {
return 'exported exported arrow function expression'
}
export async function bar() {
return 'exported named function declaration'
}
export const baz = async function () {
return 'exported anonymous function expression'
}
export const qux = async function quux() {
return 'exported named function expression'
}
export default async () => {
return 'default exported arrow function expression'
}
'use server'
export default async function () {
return 'default exported anonymous function expression'
}
'use server'
export default async function someName() {
return 'default exported named function expression'
}
'use client' 'use client'
import { Form } from '../form' import { Form } from '../form'
import { bar } from '../actions' import defaultAction1, { foo, bar, baz, qux } from '../actions1'
import defaultAction2 from '../actions2'
import defaultAction3 from '../actions3'
import Link from 'next/link' import Link from 'next/link'
export default function Page() { export default function Page() {
return ( return (
<main> <main>
<h1>client component page</h1> <h1>client component page</h1>
<Form action={bar} /> <Form id="form-1" action={defaultAction1} />
<Form id="form-2" action={defaultAction2} />
<Form id="form-3" action={defaultAction3} />
<Form id="form-4" action={foo} />
<Form id="form-5" action={bar} />
<Form id="form-6" action={baz} />
<Form id="form-7" action={qux} />
<Link href="/">server component page</Link> <Link href="/">server component page</Link>
</main> </main>
) )
......
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
import { useActionState } from 'react' import { useActionState } from 'react'
export function Form({ action }: { action: () => Promise<string> }) { export function Form({
action,
id,
}: {
action: () => Promise<string>
id: string
}) {
const [result, formAction] = useActionState(action, 'initial') const [result, formAction] = useActionState(action, 'initial')
return ( return (
<form action={formAction}> <form id={id} action={formAction}>
<button>Submit</button> <button>Submit</button>
<p>{result}</p> <p>{result}</p>
</form> </form>
......
import { Form } from './form' import { Form } from './form'
import { foo } from './actions' import defaultAction1, { foo, bar, baz, qux } from './actions1'
import defaultAction2 from './actions2'
import defaultAction3 from './actions3'
import Link from 'next/link' import Link from 'next/link'
import { ServerComponent } from './server-component' import { ServerComponent } from './server-component'
export default function Page() { export default function Page() {
const action1 = async () => {
'use server'
return 'declarator arrow function expression'
}
async function action2() {
'use server'
return 'function declaration'
}
return ( return (
<main> <main>
<ServerComponent /> <ServerComponent />
<Form action={foo} /> <Form id="form-1" action={defaultAction1} />
<Form id="form-2" action={defaultAction2} />
<Form id="form-3" action={defaultAction3} />
<Form id="form-4" action={foo} />
<Form id="form-5" action={bar} />
<Form id="form-6" action={baz} />
<Form id="form-7" action={qux} />
<Form id="form-8" action={action1} />
<Form id="form-9" action={action2} />
<Form <Form
id="form-10"
action={async () => { action={async () => {
'use server' 'use server'
return 'result' return 'arrow function expression'
}}
/>
<Form
id="form-11"
action={async function () {
'use server'
return 'anonymous function expression'
}}
/>
<Form
id="form-12"
action={async function myAction() {
'use server'
return 'named function expression'
}} }}
/> />
<Link href="/client">client component page</Link> <Link href="/client">client component page</Link>
......
...@@ -8,21 +8,161 @@ describe('source-mapping', () => { ...@@ -8,21 +8,161 @@ describe('source-mapping', () => {
it('should work with server actions passed to client components', async () => { it('should work with server actions passed to client components', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
expect(await browser.elementByCss('p').text()).toBe('initial')
await browser.elementByCss('button').click()
expect(await browser.elementByCss('#form-1 p').text()).toBe('initial')
await browser.elementByCss('#form-1 button').click()
await retry(async () => { await retry(async () => {
expect(await browser.elementByCss('p').text()).toBe('result') expect(await browser.elementByCss('#form-1 p').text()).toBe(
'default exported arrow function expression'
)
})
expect(await browser.elementByCss('#form-2 p').text()).toBe('initial')
await browser.elementByCss('#form-2 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-2 p').text()).toBe(
'default exported anonymous function expression'
)
})
expect(await browser.elementByCss('#form-3 p').text()).toBe('initial')
await browser.elementByCss('#form-3 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-3 p').text()).toBe(
'default exported named function expression'
)
})
expect(await browser.elementByCss('#form-4 p').text()).toBe('initial')
await browser.elementByCss('#form-4 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-4 p').text()).toBe(
'exported exported arrow function expression'
)
})
expect(await browser.elementByCss('#form-5 p').text()).toBe('initial')
await browser.elementByCss('#form-5 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-5 p').text()).toBe(
'exported named function declaration'
)
})
expect(await browser.elementByCss('#form-6 p').text()).toBe('initial')
await browser.elementByCss('#form-6 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-6 p').text()).toBe(
'exported anonymous function expression'
)
})
expect(await browser.elementByCss('#form-7 p').text()).toBe('initial')
await browser.elementByCss('#form-7 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-7 p').text()).toBe(
'exported named function expression'
)
})
expect(await browser.elementByCss('#form-8 p').text()).toBe('initial')
await browser.elementByCss('#form-8 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-8 p').text()).toBe(
'declarator arrow function expression'
)
})
expect(await browser.elementByCss('#form-9 p').text()).toBe('initial')
await browser.elementByCss('#form-9 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-9 p').text()).toBe(
'function declaration'
)
})
expect(await browser.elementByCss('#form-10 p').text()).toBe('initial')
await browser.elementByCss('#form-10 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-10 p').text()).toBe(
'arrow function expression'
)
})
expect(await browser.elementByCss('#form-11 p').text()).toBe('initial')
await browser.elementByCss('#form-11 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-11 p').text()).toBe(
'anonymous function expression'
)
})
expect(await browser.elementByCss('#form-12 p').text()).toBe('initial')
await browser.elementByCss('#form-12 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-12 p').text()).toBe(
'named function expression'
)
}) })
}) })
it('should work with server actions imported from client components', async () => { it('should work with server actions imported from client components', async () => {
const browser = await next.browser('/client') const browser = await next.browser('/client')
expect(await browser.elementByCss('p').text()).toBe('initial')
await browser.elementByCss('button').click()
expect(await browser.elementByCss('#form-1 p').text()).toBe('initial')
await browser.elementByCss('#form-1 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-1 p').text()).toBe(
'default exported arrow function expression'
)
})
expect(await browser.elementByCss('#form-2 p').text()).toBe('initial')
await browser.elementByCss('#form-2 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-2 p').text()).toBe(
'default exported anonymous function expression'
)
})
expect(await browser.elementByCss('#form-3 p').text()).toBe('initial')
await browser.elementByCss('#form-3 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-3 p').text()).toBe(
'default exported named function expression'
)
})
expect(await browser.elementByCss('#form-4 p').text()).toBe('initial')
await browser.elementByCss('#form-4 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-4 p').text()).toBe(
'exported exported arrow function expression'
)
})
expect(await browser.elementByCss('#form-5 p').text()).toBe('initial')
await browser.elementByCss('#form-5 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-5 p').text()).toBe(
'exported named function declaration'
)
})
expect(await browser.elementByCss('#form-6 p').text()).toBe('initial')
await browser.elementByCss('#form-6 button').click()
await retry(async () => {
expect(await browser.elementByCss('#form-6 p').text()).toBe(
'exported anonymous function expression'
)
})
expect(await browser.elementByCss('#form-7 p').text()).toBe('initial')
await browser.elementByCss('#form-7 button').click()
await retry(async () => { await retry(async () => {
expect(await browser.elementByCss('p').text()).toBe('result') expect(await browser.elementByCss('#form-7 p').text()).toBe(
'exported named function expression'
)
}) })
}) })
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment