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
......@@ -73,6 +73,8 @@ pub fn server_actions<C: Comments>(
export_actions: Default::default(),
private_ctxt: SyntaxContext::empty().apply_mark(Mark::new()),
arrow_or_fn_expr_ident: None,
})
}
......@@ -121,6 +123,8 @@ struct ServerActions<C: Comments> {
export_actions: Vec<String>,
private_ctxt: SyntaxContext,
arrow_or_fn_expr_ident: Option<Ident>,
}
impl<C: Comments> ServerActions<C> {
......@@ -307,31 +311,42 @@ impl<C: Comments> ServerActions<C> {
}
// Create the action export decl from the arrow function
self.extra_items
// export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) {}
self.hoisted_extra_items
.push(ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl {
span: DUMMY_SP,
decl: FnDecl {
ident: action_ident.clone(),
function: Box::new(Function {
params: new_params,
body: match new_body {
BlockStmtOrExpr::BlockStmt(body) => Some(body),
BlockStmtOrExpr::Expr(expr) => Some(BlockStmt {
decl: VarDecl {
kind: VarDeclKind::Const,
span: DUMMY_SP,
decls: vec![VarDeclarator {
span: DUMMY_SP,
name: Pat::Ident(action_ident.clone().into()),
definite: false,
init: Some(Box::new(Expr::Fn(FnExpr {
ident: self.arrow_or_fn_expr_ident.clone(),
function: Box::new(Function {
params: new_params,
body: match new_body {
BlockStmtOrExpr::BlockStmt(body) => Some(body),
BlockStmtOrExpr::Expr(expr) => Some(BlockStmt {
span: DUMMY_SP,
stmts: vec![Stmt::Return(ReturnStmt {
span: DUMMY_SP,
arg: Some(expr),
})],
..Default::default()
}),
},
decorators: vec![],
span: DUMMY_SP,
stmts: vec![Stmt::Return(ReturnStmt {
span: DUMMY_SP,
arg: Some(expr),
})],
is_generator: false,
is_async: true,
..Default::default()
}),
},
decorators: vec![],
span: DUMMY_SP,
is_generator: false,
is_async: true,
..Default::default()
}),
}))),
}],
declare: Default::default(),
ctxt: self.private_ctxt,
}
.into(),
})));
......@@ -343,6 +358,7 @@ impl<C: Comments> ServerActions<C> {
&mut self,
ids_from_closure: Vec<Name>,
function: &mut Box<Function>,
fn_name: Option<Ident>,
) -> Box<Expr> {
let action_name: JsWord = gen_action_ident(&mut self.reference_index);
......@@ -442,17 +458,29 @@ impl<C: Comments> ServerActions<C> {
new_params.push(p.clone());
}
self.extra_items
// Create the action export decl from the function
// export const $$RSC_SERVER_ACTION_0 = async function action($$ACTION_CLOSURE_BOUND) {}
self.hoisted_extra_items
.push(ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl {
span: DUMMY_SP,
decl: FnDecl {
ident: action_ident.clone(),
function: Box::new(Function {
params: new_params,
body: new_body,
..*function.take()
}),
decl: VarDecl {
kind: VarDeclKind::Const,
span: DUMMY_SP,
decls: vec![VarDeclarator {
span: DUMMY_SP, // TODO: need to map it to the original span?
name: Pat::Ident(action_ident.clone().into()),
definite: false,
init: Some(Box::new(Expr::Fn(FnExpr {
ident: fn_name,
function: Box::new(Function {
params: new_params,
body: new_body,
..*function.take()
}),
}))),
}],
declare: Default::default(),
ctxt: self.private_ctxt,
}
.into(),
})));
......@@ -936,16 +964,6 @@ impl<C: Comments> VisitMut for ServerActions<C> {
}
if is_action_fn && !(self.in_action_file && self.in_export_decl) {
// It's an action function. If it doesn't have a name, give it one.
match f.ident.as_mut() {
None => {
let action_name = gen_action_ident(&mut self.reference_index);
let ident = Ident::new(action_name, DUMMY_SP, self.private_ctxt);
f.ident.insert(ident)
}
Some(i) => i,
};
// Collect all the identifiers defined inside the closure and used
// in the action function. With deduplication.
retain_names_from_declared_idents(
......@@ -956,6 +974,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
let new_expr = self.maybe_hoist_and_create_proxy_for_server_action_function(
child_names,
&mut f.function,
f.ident.clone().or(self.arrow_or_fn_expr_ident.clone()),
);
if self.in_default_export_decl {
......@@ -1073,6 +1092,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
let new_expr = self.maybe_hoist_and_create_proxy_for_server_action_function(
child_names,
&mut f.function,
Some(f.ident.clone()),
);
// Replace the original function declaration with a action proxy declaration
......@@ -1180,7 +1200,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
&self.declared_idents[..declared_idents_until],
);
let maybe_new_expr = if is_action_fn {
let maybe_new_expr = if is_action_fn && !self.in_action_file {
Some(self.maybe_hoist_and_create_proxy_for_server_action_arrow_expr(child_names, a))
} else {
cache_type.map(|cache_type_str| {
......@@ -1223,6 +1243,17 @@ impl<C: Comments> VisitMut for ServerActions<C> {
}
fn visit_mut_prop_or_spread(&mut self, n: &mut PropOrSpread) {
let old_arrow_expr_ident = self.arrow_or_fn_expr_ident.take();
if let PropOrSpread::Prop(box Prop::KeyValue(KeyValueProp {
key: PropName::Ident(ident_name),
value: box Expr::Arrow(_) | box Expr::Fn(_),
..
})) = n
{
self.arrow_or_fn_expr_ident = Some(ident_name.clone().into());
}
if !self.in_module_level && self.should_track_names {
if let PropOrSpread::Prop(box Prop::Shorthand(i)) = n {
self.names.push(Name::from(&*i));
......@@ -1234,6 +1265,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
}
n.visit_mut_children_with(self);
self.arrow_or_fn_expr_ident = old_arrow_expr_ident
}
fn visit_mut_callee(&mut self, n: &mut Callee) {
......@@ -1378,7 +1410,10 @@ impl<C: Comments> VisitMut for ServerActions<C> {
f.ident = Some(new_ident.clone());
self.exported_idents.push((new_ident, "default".into()));
self.exported_idents
.push((new_ident.clone(), "default".into()));
attach_name_to_default_expr(&new_ident, &mut self.extra_items);
}
}
_ => {
......@@ -1405,11 +1440,11 @@ impl<C: Comments> VisitMut for ServerActions<C> {
self.exported_idents
.push((new_ident.clone(), "default".into()));
*default_expr.expr = attach_name_to_expr(
new_ident,
Expr::Arrow(arrow.clone()),
&mut self.extra_items,
);
create_var_declarator(&new_ident, &mut self.extra_items);
attach_name_to_default_expr(&new_ident, &mut self.extra_items);
*default_expr.expr =
assign_arrow_expr(&new_ident, Expr::Arrow(arrow.clone()));
}
}
Expr::Ident(ident) => {
......@@ -1430,11 +1465,11 @@ impl<C: Comments> VisitMut for ServerActions<C> {
self.exported_idents
.push((new_ident.clone(), "default".into()));
*default_expr.expr = attach_name_to_expr(
new_ident,
Expr::Call(call.clone()),
&mut self.extra_items,
);
create_var_declarator(&new_ident, &mut self.extra_items);
attach_name_to_default_expr(&new_ident, &mut self.extra_items);
*default_expr.expr =
assign_arrow_expr(&new_ident, Expr::Call(call.clone()));
}
_ => {
disallowed_export_span = default_expr.span;
......@@ -1540,14 +1575,14 @@ impl<C: Comments> VisitMut for ServerActions<C> {
let action_id =
generate_action_id(&self.config.hash_salt, &self.file_name, export_name);
let call_expr_span = Span::dummy_with_cmt();
self.comments.add_pure_comment(call_expr_span.lo);
if export_name == "default" {
self.comments.add_pure_comment(ident.span.lo);
let export_expr = ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultExpr(
ExportDefaultExpr {
span: ident.span,
span: DUMMY_SP,
expr: Box::new(Expr::Call(CallExpr {
span: call_expr_span,
span: ident.span,
callee: Callee::Expr(Box::new(Expr::Ident(
create_ref_ident.clone(),
))),
......@@ -1564,6 +1599,9 @@ impl<C: Comments> VisitMut for ServerActions<C> {
));
new.push(export_expr);
} else {
let call_expr_span = Span::dummy_with_cmt();
self.comments.add_pure_comment(call_expr_span.lo);
let export_expr =
ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl {
span: DUMMY_SP,
......@@ -1797,6 +1835,58 @@ impl<C: Comments> VisitMut for ServerActions<C> {
self.annotations = old_annotations;
}
fn visit_mut_jsx_attr(&mut self, attr: &mut JSXAttr) {
let old_arrow_expr_ident = self.arrow_or_fn_expr_ident.take();
if let (Some(JSXAttrValue::JSXExprContainer(container)), JSXAttrName::Ident(ident_name)) =
(&attr.value, &attr.name)
{
match &container.expr {
JSXExpr::Expr(box Expr::Arrow(_)) | JSXExpr::Expr(box Expr::Fn(_)) => {
self.arrow_or_fn_expr_ident = Some(ident_name.clone().into());
}
_ => {}
}
}
attr.visit_mut_children_with(self);
self.arrow_or_fn_expr_ident = old_arrow_expr_ident
}
fn visit_mut_var_declarator(&mut self, var_declarator: &mut VarDeclarator) {
let old_arrow_expr_ident = self.arrow_or_fn_expr_ident.take();
if let (Pat::Ident(ident), Some(box Expr::Arrow(_) | box Expr::Fn(_))) =
(&var_declarator.name, &var_declarator.init)
{
self.arrow_or_fn_expr_ident = Some(ident.id.clone());
}
var_declarator.visit_mut_children_with(self);
self.arrow_or_fn_expr_ident = old_arrow_expr_ident;
}
fn visit_mut_assign_expr(&mut self, assign_expr: &mut AssignExpr) {
let old_arrow_expr_ident = self.arrow_or_fn_expr_ident.take();
if let (
AssignTarget::Simple(SimpleAssignTarget::Ident(ident)),
box Expr::Arrow(_) | box Expr::Fn(_),
) = (&assign_expr.left, &assign_expr.right)
{
// Ignore assignment expressions that we created.
if !ident.id.to_id().0.starts_with("$$RSC_SERVER_") {
self.arrow_or_fn_expr_ident = Some(ident.id.clone());
}
}
assign_expr.visit_mut_children_with(self);
self.arrow_or_fn_expr_ident = old_arrow_expr_ident;
}
noop_visit_mut_type!();
}
......@@ -1886,7 +1976,7 @@ fn wrap_cache_expr(expr: Box<Expr>, name: &str, id: &str) -> Box<Expr> {
}))
}
fn attach_name_to_expr(ident: Ident, expr: Expr, extra_items: &mut Vec<ModuleItem>) -> Expr {
fn create_var_declarator(ident: &Ident, extra_items: &mut Vec<ModuleItem>) {
// Create the variable `var $$ACTION_0;`
extra_items.push(ModuleItem::Stmt(Stmt::Decl(Decl::Var(Box::new(VarDecl {
span: DUMMY_SP,
......@@ -1899,7 +1989,55 @@ fn attach_name_to_expr(ident: Ident, expr: Expr, extra_items: &mut Vec<ModuleIte
}],
..Default::default()
})))));
}
fn attach_name_to_default_expr(ident: &Ident, extra_items: &mut Vec<ModuleItem>) {
// Assign a name with `Object.defineProperty($$ACTION_0, 'name', {value: 'default'})`
extra_items.push(ModuleItem::Stmt(Stmt::Expr(ExprStmt {
span: DUMMY_SP,
expr: Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: Callee::Expr(Box::new(Expr::Member(MemberExpr {
span: DUMMY_SP,
obj: Box::new(Expr::Ident(Ident::new(
"Object".into(),
DUMMY_SP,
ident.ctxt,
))),
prop: MemberProp::Ident(IdentName::new("defineProperty".into(), DUMMY_SP)),
}))),
args: vec![
ExprOrSpread {
spread: None,
expr: Box::new(Expr::Ident(ident.clone())),
},
ExprOrSpread {
spread: None,
expr: Box::new("name".into()),
},
ExprOrSpread {
spread: None,
expr: Box::new(Expr::Object(ObjectLit {
span: DUMMY_SP,
props: vec![
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
key: PropName::Str("value".into()),
value: Box::new("default".into()),
}))),
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
key: PropName::Str("writable".into()),
value: Box::new(false.into()),
}))),
],
})),
},
],
..Default::default()
})),
})));
}
fn assign_arrow_expr(ident: &Ident, expr: Expr) -> Expr {
if let Expr::Paren(_paren) = &expr {
expr
} else {
......@@ -1908,7 +2046,7 @@ fn attach_name_to_expr(ident: Ident, expr: Expr, extra_items: &mut Vec<ModuleIte
span: DUMMY_SP,
expr: Box::new(Expr::Assign(AssignExpr {
span: DUMMY_SP,
left: ident.into(),
left: ident.clone().into(),
op: op!("="),
right: Box::new(expr),
})),
......
/* __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";
export default registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export async function $$RSC_SERVER_ACTION_0() {}
export default (()=>{});
/* __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";
export const $$RSC_SERVER_ACTION_0 = async function foo() {};
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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export async function $$RSC_SERVER_ACTION_0() {
export const $$RSC_SERVER_ACTION_0 = async function foo() {
'use strict';
}
};
const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
const bar = async ()=>{
const x = 1;
// 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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
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 }) {
var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
id1,
......@@ -8,11 +13,11 @@ export function Item({ id1, id2 }) {
]));
return <Button action={deleteItem}>Delete</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($$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);
console.log($$ACTION_ARG_0);
console.log($$ACTION_ARG_1);
};
export default function Home() {
const info = {
name: 'John',
......@@ -24,8 +29,3 @@ export default function Home() {
]));
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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
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";
ensureServerEntryExports([
$$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";
export default $$RSC_SERVER_ACTION_0 = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null);
var $$RSC_SERVER_ACTION_0;
export async function $$RSC_SERVER_ACTION_1(a, b) {
export default $$RSC_SERVER_ACTION_0 = async (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";
ensureServerEntryExports([
$$RSC_SERVER_ACTION_0
......
......@@ -2,6 +2,12 @@
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import deleteFromDb from 'db';
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 }) {
const v2 = id2;
const deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
......@@ -10,27 +16,21 @@ export function Item({ id1, id2 }) {
]));
return <Button action={deleteItem}>Delete</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 const $$RSC_SERVER_ACTION_1 = async function g($$ACTION_CLOSURE_BOUND, y, ...z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
return $$ACTION_ARG_0 + y + z[0];
};
const f = (x)=>{
var g = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
x
]));
};
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND, y, ...z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
export const $$RSC_SERVER_ACTION_2 = async function f($$ACTION_CLOSURE_BOUND, y, ...z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$ACTION_CLOSURE_BOUND);
return $$ACTION_ARG_0 + y + z[0];
}
};
const g = (x)=>{
f = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
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";
export const foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export async function $$RSC_SERVER_ACTION_0() {}
export const foo = async ()=>{};
const bar = async ()=>{};
export { bar };
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 deleteFromDb from 'db';
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 }) {
const v2 = id2;
return <>
......@@ -11,7 +23,7 @@ export function Item({ id1, id2 }) {
]))}>
Delete
</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,
v2
]))}>
......@@ -19,15 +31,3 @@ export function Item({ id1, id2 }) {
</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";
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 }) {
return <>
<Button action={registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
......@@ -9,7 +13,3 @@ export function Item({ value }) {
</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() {
return <Button action={myAction}>Delete</Button>
}
// TODO: should use `action` as function name?
export const action = withValidate(async () => {
'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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export async function $$RSC_SERVER_ACTION_0(a, b, c) {
export const $$RSC_SERVER_ACTION_0 = async function myAction(a, b, c) {
console.log('a');
}
};
var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export default function Page() {
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 async function $$RSC_SERVER_ACTION_1() {}
......@@ -6,6 +6,7 @@ export default function Page() {
const y = 1
return (
<Foo
// TODO: should use `action` as function name?
action={validator(async function (z) {
'use server'
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 { validator, another } from 'auth';
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() {
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
])))}/>;
}
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND, z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
return x + $$ACTION_ARG_0 + z;
}
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() {}
export const $$RSC_SERVER_ACTION_1 = async function() {};
validator(registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null));
export const $$RSC_SERVER_ACTION_2 = async function() {};
another(validator(registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null)));
/* __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 { validator } from 'auth';
export const action = validator(registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null));
export async function $$RSC_SERVER_ACTION_0() {}
export default $$RSC_SERVER_ACTION_1 = validator(registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null));
var $$RSC_SERVER_ACTION_1;
export async function $$RSC_SERVER_ACTION_2() {}
export const action = validator(async ()=>{});
export default $$RSC_SERVER_ACTION_0 = validator(async ()=>{});
var $$RSC_SERVER_ACTION_0;
Object.defineProperty($$RSC_SERVER_ACTION_0, "name", {
"value": "default",
"writable": false
});
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
action,
$$RSC_SERVER_ACTION_1
$$RSC_SERVER_ACTION_0
]);
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";
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 }) {
var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
x
]));
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
]));
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";
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 }) {
var action = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
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 }) {
id1++;
return (()=>{
......@@ -12,11 +17,11 @@ export function Item({ id1, id2 }) {
id2
]));
}
export async function $$RSC_SERVER_ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$ACTION_CLOSURE_BOUND);
export const $$RSC_SERVER_ACTION_1 = async function deleteItem($$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);
}
};
// In this example, if Button immediately executes the action, different ids should
// be passed.
export function Item2({ id1, id2 }) {
......@@ -31,8 +36,3 @@ export function Item2({ id1, 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
// TODO: should use `log` as function name?
export const log = noop(async (data) => {
'use server'
console.log(data)
......
/* __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";
const noop = (action)=>action;
export const log = noop(registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null));
export async function $$RSC_SERVER_ACTION_0(data) {
export const $$RSC_SERVER_ACTION_0 = async function(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 @@
// 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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
var foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export async function $$RSC_SERVER_ACTION_0() {
export const $$RSC_SERVER_ACTION_0 = async function foo() {
console.log(1);
}
};
var foo = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export { foo };
export var bar = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null);
export async function $$RSC_SERVER_ACTION_1() {
export const $$RSC_SERVER_ACTION_1 = async function bar() {
console.log(2);
}
export default registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null);
export async function $$RSC_SERVER_ACTION_2() {
};
export var bar = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null);
export const $$RSC_SERVER_ACTION_2 = async function baz() {
console.log(3);
}
export const qux = registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null);
export async function $$RSC_SERVER_ACTION_3() {
};
export default registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null);
export const $$RSC_SERVER_ACTION_3 = async function qux() {
console.log(4);
}
export const quux = registerServerReference($$RSC_SERVER_ACTION_4, "a9b2939c1f39073a6bed227fd20233064c8b7869", null);
export async function $$RSC_SERVER_ACTION_4() {
};
export const qux = registerServerReference($$RSC_SERVER_ACTION_3, "9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", null);
export const $$RSC_SERVER_ACTION_4 = async function quuux() {
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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
let a, f;
function Comp(b, c, ...g) {
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) {
export const $$RSC_SERVER_ACTION_0 = async function action2($$ACTION_CLOSURE_BOUND, e) {
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);
}
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);
$$ACTION_ARG_0(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);
let f;
console.log(...window, {
......@@ -38,4 +31,11 @@ export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, 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";
export const dec = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export async function $$RSC_SERVER_ACTION_0(value) {
export const dec = async (value)=>{
return value - 1;
}
};
// Test case for https://github.com/vercel/next.js/issues/54655
export default dec;
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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
let a, f;
export async function action0(b, c, ...g) {
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) {
export const $$RSC_SERVER_ACTION_0 = async function action2($$ACTION_CLOSURE_BOUND, e) {
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);
}
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);
$$ACTION_ARG_0(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);
let f;
console.log(...window, {
......@@ -38,6 +31,13 @@ export async function $$RSC_SERVER_ACTION_2($$ACTION_CLOSURE_BOUND, 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";
ensureServerEntryExports([
......
/* __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";
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() {
const data = [
1,
......@@ -23,8 +28,3 @@ export function Component() {
]));
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() {}
export async function b() {}
export async function c() {}
function d() {}
export const $$RSC_SERVER_ACTION_0 = async function e() {};
function Foo() {
var e = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
}
export async function $$RSC_SERVER_ACTION_0() {}
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
a,
......
......@@ -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 }) {
const b = 1;
var action = registerServerReference($$RSC_SERVER_ACTION_2, "1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", null).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
......@@ -22,12 +31,3 @@ async function Component({ a }) {
</form>;
}
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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
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 }) {
const a = 123;
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
return <div>{data}</div>;
});
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
import { cache as $$cache__ } from "private-next-rsc-cache-wrapper";
import { Foo } from './client';
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) {
return {
x,
......@@ -14,7 +18,3 @@ export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743e
};
});
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 @@
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import deleteFromDb from 'db';
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 }) {
const v2 = id2;
var deleteItem = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
......@@ -12,13 +22,3 @@ export function Item({ id1, id2, id3, id4 }) {
]));
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() {
const f2 = 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) {
const f2 = 1;
const f11 = 1;
......@@ -29,12 +38,3 @@ export function y(p, [p1, { p2 }], ...p3) {
]));
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 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) {
const a = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
product,
......@@ -9,10 +13,10 @@ export function Item1(product, foo, bar) {
]));
return <Button action={a}>Delete</Button>;
}
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);
export const $$RSC_SERVER_ACTION_1 = async function deleteItem2($$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]);
}
};
export function Item2(product, foo, bar) {
var deleteItem2 = registerServerReference($$RSC_SERVER_ACTION_1, "90b5db271335765a4b0eab01f044b381b5ebd5cd", null).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
product,
......@@ -21,31 +25,27 @@ export function Item2(product, foo, bar) {
]));
return <Button action={deleteItem2}>Delete</Button>;
}
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$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("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]);
}
};
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,
foo,
bar
]));
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);
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) {
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,
foo,
bar
]));
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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export async function $$RSC_SERVER_ACTION_0(a, b, c) {
export const $$RSC_SERVER_ACTION_0 = async function myAction(a, b, c) {
// comment
'use strict';
console.log('a');
}
};
var myAction = registerServerReference($$RSC_SERVER_ACTION_0, "6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", null);
export default function Page() {
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'
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'
export default function Page() {
return (
<main>
<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>
</main>
)
......
......@@ -2,11 +2,17 @@
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')
return (
<form action={formAction}>
<form id={id} action={formAction}>
<button>Submit</button>
<p>{result}</p>
</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 { ServerComponent } from './server-component'
export default function Page() {
const action1 = async () => {
'use server'
return 'declarator arrow function expression'
}
async function action2() {
'use server'
return 'function declaration'
}
return (
<main>
<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
id="form-10"
action={async () => {
'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>
......
......@@ -8,21 +8,161 @@ describe('source-mapping', () => {
it('should work with server actions passed to client components', async () => {
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 () => {
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 () => {
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 () => {
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