Unverified Commit bd19545a authored by Shu Ding's avatar Shu Ding Committed by GitHub

Improve server directive SWC transform (#70257)

parent 050144e0
......@@ -922,6 +922,13 @@ async fn insert_next_shared_aliases(
"private-next-rsc-action-encryption",
request_to_import_mapping(project_path, "next/dist/server/app-render/encryption"),
);
import_map.insert_exact_alias(
"private-next-rsc-cache-wrapper",
request_to_import_mapping(
project_path,
"next/dist/build/webpack/loaders/next-flight-loader/cache-wrapper",
),
);
insert_turbopack_dev_alias(import_map);
insert_package_alias(
......
......@@ -46,10 +46,12 @@ pub fn server_actions<C: Comments>(
file_name: file_name.to_string(),
start_pos: BytePos(0),
in_action_file: false,
in_cache_file: false,
in_export_decl: false,
in_default_export_decl: false,
in_callee: false,
has_action: false,
has_cache: false,
reference_index: 0,
in_module_level: true,
......@@ -67,6 +69,7 @@ pub fn server_actions<C: Comments>(
annotations: Default::default(),
extra_items: Default::default(),
hoisted_extra_items: Default::default(),
export_actions: Default::default(),
private_ctxt: SyntaxContext::empty().apply_mark(Mark::new()),
......@@ -90,10 +93,12 @@ struct ServerActions<C: Comments> {
start_pos: BytePos,
in_action_file: bool,
in_cache_file: bool,
in_export_decl: bool,
in_default_export_decl: bool,
in_callee: bool,
has_action: bool,
has_cache: bool,
reference_index: u32,
in_module_level: bool,
......@@ -112,6 +117,7 @@ struct ServerActions<C: Comments> {
annotations: Vec<Stmt>,
extra_items: Vec<ModuleItem>,
hoisted_extra_items: Vec<ModuleItem>,
export_actions: Vec<String>,
private_ctxt: SyntaxContext,
......@@ -119,24 +125,24 @@ struct ServerActions<C: Comments> {
impl<C: Comments> ServerActions<C> {
// Check if the function or arrow function is an action function
fn get_action_info(
&mut self,
maybe_body: Option<&mut BlockStmt>,
remove_directive: bool,
) -> bool {
fn get_body_info(&mut self, maybe_body: Option<&mut BlockStmt>) -> (bool, bool) {
let mut is_action_fn = false;
let mut is_cache_fn = false;
if self.in_action_file && self.in_export_decl {
// All export functions in a server file are actions
is_action_fn = true;
} else if self.in_cache_file && self.in_export_decl {
// All export functions in a cache file are cache functions
is_cache_fn = true;
} else {
// Check if the function has `"use server"`
if let Some(body) = maybe_body {
let mut action_span = None;
remove_server_directive_index_in_fn(
&mut body.stmts,
remove_directive,
&mut is_action_fn,
&mut is_cache_fn,
&mut action_span,
self.config.enabled,
);
......@@ -154,7 +160,7 @@ impl<C: Comments> ServerActions<C> {
}
}
is_action_fn
(is_action_fn, is_cache_fn)
}
fn maybe_hoist_and_create_proxy(
......@@ -163,7 +169,7 @@ impl<C: Comments> ServerActions<C> {
function: Option<&mut Box<Function>>,
arrow: Option<&mut ArrowExpr>,
) -> Option<Box<Expr>> {
let action_name: JsWord = gen_ident(&mut self.reference_index);
let action_name: JsWord = gen_action_ident(&mut self.reference_index);
let action_ident = Ident::new(action_name.clone(), DUMMY_SP, self.private_ctxt);
let export_name: JsWord = action_name;
......@@ -171,7 +177,7 @@ impl<C: Comments> ServerActions<C> {
self.export_actions.push(export_name.to_string());
if let Some(a) = arrow {
let register_action_expr = annotate_ident_as_action(
let register_action_expr = annotate_ident_as_server_reference(
action_ident.clone(),
ids_from_closure
.iter()
......@@ -314,7 +320,7 @@ impl<C: Comments> ServerActions<C> {
return Some(Box::new(register_action_expr.clone()));
} else if let Some(f) = function {
let register_action_expr = annotate_ident_as_action(
let register_action_expr = annotate_ident_as_server_reference(
action_ident.clone(),
ids_from_closure
.iter()
......@@ -426,6 +432,295 @@ impl<C: Comments> ServerActions<C> {
None
}
fn maybe_hoist_and_create_proxy_to_cache(
&mut self,
ids_from_closure: Vec<Name>,
fn_name: Option<Ident>,
function: Option<&mut Box<Function>>,
arrow: Option<&mut ArrowExpr>,
) -> Option<Box<Expr>> {
let cache_name: JsWord = gen_cache_ident(&mut self.reference_index);
let cache_ident = private_ident!(cache_name.clone());
let export_name: JsWord = cache_name;
self.has_cache = true;
self.has_action = true;
self.export_actions.push(export_name.to_string());
let reference_id =
generate_action_id(&self.config.hash_salt, &self.file_name, &export_name);
if let Some(a) = arrow {
let register_action_expr = annotate_ident_as_server_reference(
cache_ident.clone(),
ids_from_closure
.iter()
.cloned()
.map(|id| Some(id.as_arg()))
.collect(),
reference_id.clone(),
);
if let BlockStmtOrExpr::BlockStmt(block) = &mut *a.body {
block.visit_mut_with(&mut ClosureReplacer {
used_ids: &ids_from_closure,
private_ctxt: self.private_ctxt,
});
}
// export const $ACTION_myAction = async () => {}
let mut new_params: Vec<Param> = vec![];
let mut new_body: BlockStmtOrExpr = *a.body.take();
if !ids_from_closure.is_empty() {
// First argument is the encrypted closure variables
new_params.push(Param {
span: DUMMY_SP,
decorators: vec![],
pat: Pat::Ident(
IdentName::new("$$ACTION_CLOSURE_BOUND".into(), DUMMY_SP).into(),
),
});
// Also prepend the decryption decl into the body.
// var [arg1, arg2, arg3] = await decryptActionBoundArgs(actionId,
// $$ACTION_CLOSURE_BOUND)
let mut pats = vec![];
for i in 0..ids_from_closure.len() {
pats.push(Some(Pat::Ident(
IdentName::new(format!("$$ACTION_ARG_{i}").into(), DUMMY_SP).into(),
)));
}
let decryption_decl = VarDecl {
span: DUMMY_SP,
kind: VarDeclKind::Var,
declare: false,
decls: vec![VarDeclarator {
span: DUMMY_SP,
name: Pat::Array(ArrayPat {
span: DUMMY_SP,
elems: pats,
optional: false,
type_ann: None,
}),
init: Some(Box::new(Expr::Await(AwaitExpr {
span: DUMMY_SP,
arg: Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: quote_ident!("decryptActionBoundArgs").as_callee(),
args: vec![
generate_action_id(
&self.config.hash_salt,
&self.file_name,
&export_name,
)
.as_arg(),
quote_ident!("$$ACTION_CLOSURE_BOUND").as_arg(),
],
..Default::default()
})),
}))),
definite: Default::default(),
}],
..Default::default()
};
match &mut new_body {
BlockStmtOrExpr::BlockStmt(body) => {
body.stmts.insert(0, decryption_decl.into());
}
BlockStmtOrExpr::Expr(body_expr) => {
new_body = BlockStmtOrExpr::BlockStmt(BlockStmt {
span: DUMMY_SP,
stmts: vec![
decryption_decl.into(),
Stmt::Return(ReturnStmt {
span: DUMMY_SP,
arg: Some(body_expr.take()),
}),
],
..Default::default()
});
}
}
}
for p in a.params.iter() {
new_params.push(Param {
span: DUMMY_SP,
decorators: vec![],
pat: p.clone(),
});
}
// Create the action export decl from the arrow function
// export var cache_ident = async function() {}
self.hoisted_extra_items
.push(ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl {
span: DUMMY_SP,
decl: VarDecl {
span: DUMMY_SP,
kind: VarDeclKind::Var,
decls: vec![VarDeclarator {
span: DUMMY_SP,
name: Pat::Ident(cache_ident.clone().into()),
init: Some(wrap_cache_expr(
Box::new(Expr::Fn(FnExpr {
ident: fn_name,
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,
is_generator: false,
is_async: true,
..Default::default()
}),
})),
"default",
&reference_id,
)),
definite: false,
}],
..Default::default()
}
.into(),
})));
return Some(Box::new(register_action_expr.clone()));
} else if let Some(f) = function {
let register_action_expr = annotate_ident_as_server_reference(
cache_ident.clone(),
ids_from_closure
.iter()
.cloned()
.map(|id| Some(id.as_arg()))
.collect(),
reference_id.clone(),
);
f.body.visit_mut_with(&mut ClosureReplacer {
used_ids: &ids_from_closure,
private_ctxt: self.private_ctxt,
});
// export async function $ACTION_myAction () {}
let mut new_params: Vec<Param> = vec![];
let mut new_body: Option<BlockStmt> = f.body.clone();
// add params from closure collected ids
if !ids_from_closure.is_empty() {
// First argument is the encrypted closure variables
new_params.push(Param {
span: DUMMY_SP,
decorators: vec![],
pat: Pat::Ident(
IdentName::new("$$ACTION_CLOSURE_BOUND".into(), DUMMY_SP).into(),
),
});
// Also prepend the decryption decl into the body.
// var [arg1, arg2, arg3] = await decryptActionBoundArgs(actionId,
// $$ACTION_CLOSURE_BOUND)
let mut pats = vec![];
for i in 0..ids_from_closure.len() {
pats.push(Some(Pat::Ident(
IdentName::new(format!("$$ACTION_ARG_{i}").into(), DUMMY_SP).into(),
)));
}
let decryption_decl = VarDecl {
span: DUMMY_SP,
kind: VarDeclKind::Var,
decls: vec![VarDeclarator {
span: DUMMY_SP,
name: Pat::Array(ArrayPat {
span: DUMMY_SP,
elems: pats,
optional: false,
type_ann: None,
}),
init: Some(Box::new(Expr::Await(AwaitExpr {
span: DUMMY_SP,
arg: Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: quote_ident!("decryptActionBoundArgs").as_callee(),
args: vec![
generate_action_id(
&self.config.hash_salt,
&self.file_name,
&export_name,
)
.as_arg(),
quote_ident!("$$ACTION_CLOSURE_BOUND").as_arg(),
],
..Default::default()
})),
}))),
definite: Default::default(),
}],
..Default::default()
};
if let Some(body) = &mut new_body {
body.stmts.insert(0, decryption_decl.into());
} else {
new_body = Some(BlockStmt {
span: DUMMY_SP,
stmts: vec![decryption_decl.into()],
..Default::default()
});
}
}
for p in f.params.iter() {
new_params.push(p.clone());
}
// export var cache_ident = async function() {}
self.hoisted_extra_items
.push(ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl {
span: DUMMY_SP,
decl: VarDecl {
span: DUMMY_SP,
kind: VarDeclKind::Var,
decls: vec![VarDeclarator {
span: DUMMY_SP,
name: Pat::Ident(cache_ident.clone().into()),
init: Some(wrap_cache_expr(
Box::new(Expr::Fn(FnExpr {
ident: fn_name,
function: Box::new(Function {
params: new_params,
body: new_body,
..*f.take()
}),
})),
"default",
&reference_id,
)),
definite: false,
}],
..Default::default()
}
.into(),
})));
return Some(Box::new(register_action_expr));
}
None
}
}
impl<C: Comments> VisitMut for ServerActions<C> {
......@@ -458,7 +753,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
}
fn visit_mut_fn_expr(&mut self, f: &mut FnExpr) {
let is_action_fn = self.get_action_info(f.function.body.as_mut(), true);
let (is_action_fn, is_cache_fn) = self.get_body_info(f.function.body.as_mut());
let declared_idents_until = self.declared_idents.len();
let current_names = take(&mut self.names);
......@@ -489,11 +784,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
take(&mut self.names)
};
if !is_action_fn {
return;
}
if !f.function.is_async {
if (is_action_fn || is_cache_fn) && !f.function.is_async {
HANDLER.with(|handler| {
handler
.struct_span_err(f.function.span, "Server actions must be async functions")
......@@ -501,11 +792,47 @@ impl<C: Comments> VisitMut for ServerActions<C> {
});
}
if !(self.in_action_file && self.in_export_decl) {
if is_cache_fn && !(self.in_cache_file && self.in_export_decl) {
// It's a cache function. If it doesn't have a name, give it one.
match f.ident.as_mut() {
None => {
let action_name = gen_cache_ident(&mut self.reference_index);
let ident = Ident::new(action_name, DUMMY_SP, Default::default());
f.ident.insert(ident)
}
Some(i) => i,
};
// Collect all the identifiers defined inside the closure and used
// in the cache function. With deduplication.
retain_names_from_declared_idents(
&mut child_names,
&self.declared_idents[..declared_idents_until],
);
let maybe_new_expr = self.maybe_hoist_and_create_proxy_to_cache(
child_names.clone(),
f.ident.clone(),
Some(&mut f.function),
None,
);
if self.in_default_export_decl {
// This function expression is also the default export:
// `export default async function() {}`
// This specific case (default export) isn't handled by `visit_mut_expr`.
// Replace the original function expr with a action proxy expr.
self.rewrite_default_fn_expr_to_proxy_expr = maybe_new_expr;
} else {
self.rewrite_expr_to_proxy_expr = maybe_new_expr;
}
}
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_ident(&mut self.reference_index);
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)
}
......@@ -546,7 +873,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
}
fn visit_mut_fn_decl(&mut self, f: &mut FnDecl) {
let is_action_fn = self.get_action_info(f.function.body.as_mut(), true);
let (is_action_fn, is_cache_fn) = self.get_body_info(f.function.body.as_mut());
let declared_idents_until = self.declared_idents.len();
let current_names = take(&mut self.names);
......@@ -577,31 +904,23 @@ impl<C: Comments> VisitMut for ServerActions<C> {
take(&mut self.names)
};
if !is_action_fn {
return;
}
if !f.function.is_async {
HANDLER.with(|handler| {
handler
.struct_span_err(f.ident.span, "Server actions must be async functions")
.emit();
});
}
if is_cache_fn {
if !f.function.is_async {
HANDLER.with(|handler| {
handler
.struct_span_err(f.ident.span, "Cache functions must be async functions")
.emit();
});
}
if !(self.in_action_file && self.in_export_decl) {
// Collect all the identifiers defined inside the closure and used
// in the action function. With deduplication.
retain_names_from_declared_idents(
&mut child_names,
&self.declared_idents[..declared_idents_until],
let maybe_new_expr = self.maybe_hoist_and_create_proxy_to_cache(
[].to_vec(),
Some(f.ident.clone()),
Some(&mut f.function),
None,
);
let maybe_new_expr =
self.maybe_hoist_and_create_proxy(child_names, Some(&mut f.function), None);
// Replace the original function declaration with a action proxy declaration
// expr.
// Replace the original function declaration with a cache decl.
self.rewrite_fn_decl_to_proxy_decl = Some(VarDecl {
span: DUMMY_SP,
kind: VarDeclKind::Var,
......@@ -613,6 +932,44 @@ impl<C: Comments> VisitMut for ServerActions<C> {
}],
..Default::default()
});
return;
}
if is_action_fn {
if !f.function.is_async {
HANDLER.with(|handler| {
handler
.struct_span_err(f.ident.span, "Server actions must be async functions")
.emit();
});
}
if !(self.in_action_file && self.in_export_decl) {
// Collect all the identifiers defined inside the closure and used
// in the action function. With deduplication.
retain_names_from_declared_idents(
&mut child_names,
&self.declared_idents[..declared_idents_until],
);
let maybe_new_expr =
self.maybe_hoist_and_create_proxy(child_names, Some(&mut f.function), None);
// Replace the original function declaration with a action proxy declaration
// expr.
self.rewrite_fn_decl_to_proxy_decl = Some(VarDecl {
span: DUMMY_SP,
kind: VarDeclKind::Var,
decls: vec![VarDeclarator {
span: DUMMY_SP,
name: Pat::Ident(f.ident.clone().into()),
init: maybe_new_expr,
definite: false,
}],
..Default::default()
});
}
}
}
......@@ -639,14 +996,12 @@ impl<C: Comments> VisitMut for ServerActions<C> {
fn visit_mut_arrow_expr(&mut self, a: &mut ArrowExpr) {
// Arrow expressions need to be visited in prepass to determine if it's
// an action function or not.
let is_action_fn = self.get_action_info(
if let BlockStmtOrExpr::BlockStmt(block) = &mut *a.body {
let (is_action_fn, is_cache_fn) =
self.get_body_info(if let BlockStmtOrExpr::BlockStmt(block) = &mut *a.body {
Some(block)
} else {
None
},
true,
);
});
let declared_idents_until = self.declared_idents.len();
let current_names = take(&mut self.names);
......@@ -682,11 +1037,11 @@ impl<C: Comments> VisitMut for ServerActions<C> {
take(&mut self.names)
};
if !is_action_fn {
if !is_action_fn && !is_cache_fn {
return;
}
if !a.is_async && !self.in_action_file {
if !a.is_async && !self.in_action_file && !self.in_cache_file {
HANDLER.with(|handler| {
handler
.struct_span_err(a.span, "Server actions must be async functions")
......@@ -701,7 +1056,12 @@ impl<C: Comments> VisitMut for ServerActions<C> {
&self.declared_idents[..declared_idents_until],
);
let maybe_new_expr = self.maybe_hoist_and_create_proxy(child_names, None, Some(a));
let maybe_new_expr = if is_action_fn {
self.maybe_hoist_and_create_proxy(child_names, None, Some(a))
} else {
self.maybe_hoist_and_create_proxy_to_cache(child_names, None, None, Some(a))
};
self.rewrite_expr_to_proxy_expr = maybe_new_expr;
}
......@@ -784,7 +1144,9 @@ impl<C: Comments> VisitMut for ServerActions<C> {
remove_server_directive_index_in_module(
stmts,
&mut self.in_action_file,
&mut self.in_cache_file,
&mut self.has_action,
&mut self.has_cache,
self.config.enabled,
);
......@@ -792,9 +1154,9 @@ impl<C: Comments> VisitMut for ServerActions<C> {
let mut new = Vec::with_capacity(stmts.len());
for mut stmt in stmts.take() {
// For action file, it's not allowed to export things other than async
// For server boundary files, it's not allowed to export things other than async
// functions.
if self.in_action_file {
if self.in_action_file || self.in_cache_file {
let mut disallowed_export_span = DUMMY_SP;
// Currently only function exports are allowed.
......@@ -874,7 +1236,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
} else {
// export default function() {}
let new_ident = Ident::new(
gen_ident(&mut self.reference_index),
gen_action_ident(&mut self.reference_index),
DUMMY_SP,
self.private_ctxt,
);
......@@ -896,7 +1258,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
} else {
// export default async () => {}
let new_ident = Ident::new(
gen_ident(&mut self.reference_index),
gen_action_ident(&mut self.reference_index),
DUMMY_SP,
self.private_ctxt,
);
......@@ -918,7 +1280,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
Expr::Call(call) => {
// export default fn()
let new_ident = Ident::new(
gen_ident(&mut self.reference_index),
gen_action_ident(&mut self.reference_index),
DUMMY_SP,
self.private_ctxt,
);
......@@ -971,6 +1333,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
}
if self.config.is_react_server_layer || !self.in_action_file {
new.append(&mut self.hoisted_extra_items);
new.push(new_stmt);
new.extend(self.annotations.drain(..).map(ModuleItem::Stmt));
new.append(&mut self.extra_items);
......@@ -1060,7 +1423,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
} else {
self.annotations.push(Stmt::Expr(ExprStmt {
span: DUMMY_SP,
expr: Box::new(annotate_ident_as_action(
expr: Box::new(annotate_ident_as_server_reference(
ident.clone(),
Vec::new(),
generate_action_id(
......@@ -1158,63 +1521,89 @@ impl<C: Comments> VisitMut for ServerActions<C> {
},
);
if self.config.is_react_server_layer {
// Inlined actions are only allowed on the server layer.
// import { registerServerReference } from 'private-next-rsc-server-reference'
// registerServerReference("action_id")
new.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
if !self.config.is_react_server_layer {
// Make it the first item
new.rotate_right(1);
}
}
// import { cache as $cache } from "private-next-rsc-cache-wrapper";
if self.has_cache {
new.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
span: DUMMY_SP,
specifiers: vec![ImportSpecifier::Named(ImportNamedSpecifier {
span: DUMMY_SP,
specifiers: vec![ImportSpecifier::Named(ImportNamedSpecifier {
local: quote_ident!("$$cache__").into(),
imported: Some(quote_ident!("cache").into()),
is_type_only: false,
})],
src: Box::new(Str {
span: DUMMY_SP,
value: "private-next-rsc-cache-wrapper".into(),
raw: None,
}),
type_only: false,
with: None,
phase: Default::default(),
})));
// Make it the first item
new.rotate_right(1);
}
if (self.has_action || self.has_cache) && self.config.is_react_server_layer {
// Inlined actions are only allowed on the server layer.
// import { registerServerReference } from 'private-next-rsc-server-reference'
// registerServerReference("action_id")
new.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
span: DUMMY_SP,
specifiers: vec![ImportSpecifier::Named(ImportNamedSpecifier {
span: DUMMY_SP,
local: quote_ident!("registerServerReference").into(),
imported: None,
is_type_only: false,
})],
src: Box::new(Str {
span: DUMMY_SP,
value: "private-next-rsc-server-reference".into(),
raw: None,
}),
type_only: false,
with: None,
phase: Default::default(),
})));
// Encryption and decryption only happens on the server layer.
// import { encryptActionBoundArgs, decryptActionBoundArgs } from
// 'private-next-rsc-action-encryption'
new.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
span: DUMMY_SP,
specifiers: vec![
ImportSpecifier::Named(ImportNamedSpecifier {
span: DUMMY_SP,
local: quote_ident!("registerServerReference").into(),
local: quote_ident!("encryptActionBoundArgs").into(),
imported: None,
is_type_only: false,
})],
src: Box::new(Str {
span: DUMMY_SP,
value: "private-next-rsc-server-reference".into(),
raw: None,
}),
type_only: false,
with: None,
phase: Default::default(),
})));
// Encryption and decryption only happens on the server layer.
// import { encryptActionBoundArgs, decryptActionBoundArgs } from
// 'private-next-rsc-action-encryption'
new.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
span: DUMMY_SP,
specifiers: vec![
ImportSpecifier::Named(ImportNamedSpecifier {
span: DUMMY_SP,
local: quote_ident!("encryptActionBoundArgs").into(),
imported: None,
is_type_only: false,
}),
ImportSpecifier::Named(ImportNamedSpecifier {
span: DUMMY_SP,
local: quote_ident!("decryptActionBoundArgs").into(),
imported: None,
is_type_only: false,
}),
],
src: Box::new(Str {
ImportSpecifier::Named(ImportNamedSpecifier {
span: DUMMY_SP,
value: "private-next-rsc-action-encryption".into(),
raw: None,
local: quote_ident!("decryptActionBoundArgs").into(),
imported: None,
is_type_only: false,
}),
type_only: false,
with: None,
phase: Default::default(),
})));
// Make it the first item
new.rotate_right(2);
} else {
// Make it the first item
new.rotate_right(1);
}
],
src: Box::new(Str {
span: DUMMY_SP,
value: "private-next-rsc-action-encryption".into(),
raw: None,
}),
type_only: false,
with: None,
phase: Default::default(),
})));
// Make it the first item
new.rotate_right(2);
}
*stmts = new;
......@@ -1284,12 +1673,38 @@ fn retain_names_from_declared_idents(child_names: &mut Vec<Name>, current_declar
*child_names = retained_names;
}
fn gen_ident(cnt: &mut u32) -> JsWord {
let id: JsWord = format!("$$ACTION_{cnt}").into();
fn gen_action_ident(cnt: &mut u32) -> JsWord {
let id: JsWord = format!("$$RSC_SERVER_ACTION_{cnt}").into();
*cnt += 1;
id
}
fn gen_cache_ident(cnt: &mut u32) -> JsWord {
let id: JsWord = format!("$$RSC_SERVER_CACHE_{cnt}").into();
*cnt += 1;
id
}
fn wrap_cache_expr(expr: Box<Expr>, name: &str, id: &str) -> Box<Expr> {
// expr -> $$cache__("name", "id", expr)
Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: quote_ident!("$$cache__").as_callee(),
args: vec![
ExprOrSpread {
spread: None,
expr: Box::new(name.into()),
},
ExprOrSpread {
spread: None,
expr: Box::new(id.into()),
},
expr.as_arg(),
],
..Default::default()
}))
}
fn attach_name_to_expr(ident: Ident, expr: Expr, extra_items: &mut Vec<ModuleItem>) -> Expr {
// Create the variable `var $$ACTION_0;`
extra_items.push(ModuleItem::Stmt(Stmt::Decl(Decl::Var(Box::new(VarDecl {
......@@ -1333,7 +1748,7 @@ fn generate_action_id(hash_salt: &str, file_name: &str, export_name: &str) -> St
hex_encode(result)
}
fn annotate_ident_as_action(
fn annotate_ident_as_server_reference(
ident: Ident,
bound: Vec<Option<ExprOrSpread>>,
action_id: String,
......@@ -1463,7 +1878,9 @@ fn detect_similar_strings(a: &str, b: &str) -> bool {
fn remove_server_directive_index_in_module(
stmts: &mut Vec<ModuleItem>,
in_action_file: &mut bool,
in_cache_file: &mut bool,
has_action: &mut bool,
has_cache: &mut bool,
enabled: bool,
) {
let mut is_directive = true;
......@@ -1499,15 +1916,30 @@ fn remove_server_directive_index_in_module(
.emit();
});
}
} else if value == "use cache" {
if is_directive {
*in_cache_file = true;
*has_cache = true;
return false;
} else {
HANDLER.with(|handler| {
handler
.struct_span_err(
*span,
"The \"use cache\" directive must be at the top of the file.",
)
.emit();
});
}
} else {
// Detect typo of "use server"
if detect_similar_strings(value, "use server") {
// Detect typo of "use cache"
if detect_similar_strings(value, "use cache") {
HANDLER.with(|handler| {
handler
.struct_span_err(
*span,
format!(
"Did you mean \"use server\"? \"{value}\" is not a supported \
"Did you mean \"use cache\"? \"{value}\" is not a supported \
directive name."
)
.as_str(),
......@@ -1549,6 +1981,28 @@ fn remove_server_directive_index_in_module(
.emit();
})
}
} else if value == "use cache" || detect_similar_strings(value, "use cache") {
if is_directive {
HANDLER.with(|handler| {
handler
.struct_span_err(
*span,
"The \"use cache\" directive cannot be wrapped in \
parentheses.",
)
.emit();
})
} else {
HANDLER.with(|handler| {
handler
.struct_span_err(
*span,
"The \"use cache\" directive must be at the top of the file, \
and cannot be wrapped in parentheses.",
)
.emit();
})
}
}
}
_ => {
......@@ -1561,8 +2015,8 @@ fn remove_server_directive_index_in_module(
fn remove_server_directive_index_in_fn(
stmts: &mut Vec<Stmt>,
remove_directive: bool,
is_action_fn: &mut bool,
is_cache_fn: &mut bool,
action_span: &mut Option<Span>,
enabled: bool,
) {
......@@ -1589,9 +2043,7 @@ fn remove_server_directive_index_in_fn(
.emit()
});
}
if remove_directive {
return false;
}
return false;
} else {
HANDLER.with(|handler| {
handler
......@@ -1603,9 +2055,8 @@ fn remove_server_directive_index_in_fn(
.emit();
});
}
} else {
// Detect typo of "use server"
if detect_similar_strings(value, "use server") {
} else if detect_similar_strings(value, "use server") {
// Detect typo of "use server"
HANDLER.with(|handler| {
handler
.struct_span_err(
......@@ -1618,7 +2069,36 @@ fn remove_server_directive_index_in_fn(
)
.emit();
});
} else if value == "use cache" {
if is_directive {
// Detect typo of "use server"
*is_cache_fn = true;
return false;
} else {
HANDLER.with(|handler| {
handler
.struct_span_err(
*span,
"The \"use cache\" directive must be at the top of the function \
body.",
)
.emit();
});
}
} else if detect_similar_strings(value, "use cache") {
// Detect typo of "use cache"
HANDLER.with(|handler| {
handler
.struct_span_err(
*span,
format!(
"Did you mean \"use cache\"? \"{value}\" is not a supported \
directive name."
)
.as_str(),
)
.emit();
});
}
} else {
is_directive = false;
......
/* __next_internal_client_entry_do_not_use__ default auto */ /* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0"} */ export async function $$ACTION_0() {}
/* __next_internal_client_entry_do_not_use__ default auto */ /* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0"} */ export async function $$RSC_SERVER_ACTION_0() {}
export default function App() {
var fn = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
var fn = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
return <div>App</div>;
}
x Did you mean "use server"? "use sevrer" is not a supported directive name.
,-[input.js:1:1]
1 | 'use sevrer'
: ^^^^^^^^^^^^
`----
/* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
export default registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
export async function $$ACTION_0() {}
export default registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
export async function $$RSC_SERVER_ACTION_0() {}
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([]);
/* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
const foo = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
export async function $$ACTION_0() {}
const foo = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
export async function $$RSC_SERVER_ACTION_0() {}
/* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
const foo = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
export async function $$ACTION_0() {
const foo = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
export async function $$RSC_SERVER_ACTION_0() {
'use strict';
}
const bar = async ()=>{
......
/* __next_internal_action_entry_do_not_use__ {"0090eaf4e1f08a2d94f6be401e54a2ded399b87c":"action0","188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","9878bfa39811ca7650992850a8751f9591b6a557":"$$ACTION_2"} */ export var action0 = /*#__PURE__*/ createServerReference("0090eaf4e1f08a2d94f6be401e54a2ded399b87c");
/* __next_internal_action_entry_do_not_use__ {"0090eaf4e1f08a2d94f6be401e54a2ded399b87c":"action0","1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91":"$$RSC_SERVER_ACTION_2","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1"} */ export var action0 = /*#__PURE__*/ createServerReference("0090eaf4e1f08a2d94f6be401e54a2ded399b87c");
import { createServerReference } from "private-next-rsc-action-client-wrapper";
/* __next_internal_action_entry_do_not_use__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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';
export function Item({ id1, id2 }) {
var deleteItem = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
var deleteItem = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
id1,
id2
]));
return <Button action={deleteItem}>Delete</Button>;
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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);
}
......@@ -18,14 +18,14 @@ export default function Home() {
name: 'John',
test: 'test'
};
const action = registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1).bind(null, encryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", [
const action = registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
info.name,
info.test
]));
return null;
}
export async function $$ACTION_1($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_CLOSURE_BOUND);
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 $$ACTION_0() {}
export default async function $$RSC_SERVER_ACTION_0() {}
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
$$ACTION_0
$$RSC_SERVER_ACTION_0
]);
registerServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", $$ACTION_0);
registerServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", $$RSC_SERVER_ACTION_0);
/* __next_internal_action_entry_do_not_use__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference";
/* __next_internal_action_entry_do_not_use__ {"90b5db271335765a4b0eab01f044b381b5ebd5cd":"$$RSC_SERVER_ACTION_1","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export default $$ACTION_0 = registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1);
var $$ACTION_0;
export async function $$ACTION_1(a, b) {
export default $$RSC_SERVER_ACTION_0 = registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1);
var $$RSC_SERVER_ACTION_0;
export async function $$RSC_SERVER_ACTION_1(a, b) {
console.log(a, b);
}
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
$$ACTION_0
$$RSC_SERVER_ACTION_0
]);
registerServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", $$ACTION_0);
registerServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", $$RSC_SERVER_ACTION_0);
/* __next_internal_action_entry_do_not_use__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","9878bfa39811ca7650992850a8751f9591b6a557":"$$ACTION_2"} */ 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 deleteFromDb from 'db';
const v1 = 'v1';
export function Item({ id1, id2 }) {
const v2 = id2;
const deleteItem = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
const deleteItem = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
id1,
v2
]));
return <Button action={deleteItem}>Delete</Button>;
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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);
}
const f = (x)=>{
var g = registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1).bind(null, encryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", [
var g = registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
x
]));
};
export async function $$ACTION_1($$ACTION_CLOSURE_BOUND, y, ...z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_CLOSURE_BOUND);
export async function $$RSC_SERVER_ACTION_1($$ACTION_CLOSURE_BOUND, y, ...z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$ACTION_CLOSURE_BOUND);
return $$ACTION_ARG_0 + y + z[0];
}
const g = (x)=>{
f = registerServerReference("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_2).bind(null, encryptActionBoundArgs("9878bfa39811ca7650992850a8751f9591b6a557", [
f = registerServerReference("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$RSC_SERVER_ACTION_2).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
x
]));
};
export async function $$ACTION_2($$ACTION_CLOSURE_BOUND, y, ...z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_CLOSURE_BOUND);
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__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo","ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference";
/* __next_internal_action_entry_do_not_use__ {"6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","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("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
export async function $$ACTION_0() {}
export const foo = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
export async function $$RSC_SERVER_ACTION_0() {}
const bar = async ()=>{};
export { bar };
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
......
/* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","9878bfa39811ca7650992850a8751f9591b6a557":"$$ACTION_2"} */ 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"} */ 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 function Item({ id1, id2 }) {
const v2 = id2;
return <>
<Button action={registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
<Button action={registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
id1,
v2
]))}>
Delete
</Button>
<Button action={registerServerReference("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_2).bind(null, encryptActionBoundArgs("9878bfa39811ca7650992850a8751f9591b6a557", [
<Button action={registerServerReference("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$RSC_SERVER_ACTION_2).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
id1,
v2
]))}>
......@@ -19,14 +19,14 @@ export function Item({ id1, id2 }) {
</Button>
</>;
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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 $$ACTION_2($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_CLOSURE_BOUND);
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__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
export function Item({ value }) {
return <>
<Button action={registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
<Button action={registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
value
]))}>
Multiple
</Button>
</>;
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND, value2) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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;
}
/* __next_internal_action_entry_do_not_use__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
var myAction = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
export async function $$ACTION_0(a, b, c) {
var myAction = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
export async function $$RSC_SERVER_ACTION_0(a, b, c) {
console.log('a');
}
export default function Page() {
return <Button action={myAction}>Delete</Button>;
}
export const action = withValidate(registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1));
export async function $$ACTION_1() {}
export const action = withValidate(registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1));
export async function $$RSC_SERVER_ACTION_1() {}
/* __next_internal_action_entry_do_not_use__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","56a859f462d35a297c46a1bbd1e6a9058c104ab8":"$$ACTION_3","9878bfa39811ca7650992850a8751f9591b6a557":"$$ACTION_2"} */ import { registerServerReference } from "private-next-rsc-server-reference";
/* __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";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
import { validator, another } from 'auth';
const x = 1;
export default function Page() {
const y = 1;
return <Foo action={validator(registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1).bind(null, encryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", [
return <Foo action={validator(registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
y
])))}/>;
}
export async function $$ACTION_1($$ACTION_CLOSURE_BOUND, z) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_CLOSURE_BOUND);
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("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_2));
export async function $$ACTION_2() {}
another(validator(registerServerReference("56a859f462d35a297c46a1bbd1e6a9058c104ab8", $$ACTION_3)));
export async function $$ACTION_3() {}
validator(registerServerReference("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$RSC_SERVER_ACTION_2));
export async function $$RSC_SERVER_ACTION_2() {}
another(validator(registerServerReference("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", $$RSC_SERVER_ACTION_3)));
export async function $$RSC_SERVER_ACTION_3() {}
/* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","9878bfa39811ca7650992850a8751f9591b6a557":"$$ACTION_2","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default","f14702b5a021dd117f7ec7a3c838f397c2046d3b":"action"} */ 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","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("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0));
export async function $$ACTION_0() {}
export default $$ACTION_1 = validator(registerServerReference("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_2));
var $$ACTION_1;
export async function $$ACTION_2() {}
export const action = validator(registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0));
export async function $$RSC_SERVER_ACTION_0() {}
export default $$RSC_SERVER_ACTION_1 = validator(registerServerReference("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$RSC_SERVER_ACTION_2));
var $$RSC_SERVER_ACTION_1;
export async function $$RSC_SERVER_ACTION_2() {}
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
action,
$$ACTION_1
$$RSC_SERVER_ACTION_1
]);
registerServerReference("f14702b5a021dd117f7ec7a3c838f397c2046d3b", action);
registerServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", $$ACTION_1);
registerServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", $$RSC_SERVER_ACTION_1);
/* __next_internal_action_entry_do_not_use__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
export default function Page({ foo, x, y }) {
var action = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
var action = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
x
]));
action.bind(null, foo[0], foo[1], foo.x, foo[y]);
const action2 = registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1).bind(null, encryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", [
const action2 = registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
x
]));
action2.bind(null, foo[0], foo[1], foo.x, foo[y]);
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND, a, b, c, d) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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 $$ACTION_1($$ACTION_CLOSURE_BOUND, a, b, c, d) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_CLOSURE_BOUND);
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__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
export default function Page({ foo, x, y }) {
var action = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
var action = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
foo
]));
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND, a, b, c, { d }) {
var [$$ACTION_ARG_0] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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';
export function Item({ id1, id2 }) {
......@@ -7,13 +7,13 @@ export function Item({ id1, id2 }) {
id1++;
return <Button action={deleteItem}>Delete</Button>;
})();
var deleteItem = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
var deleteItem = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
id1,
id2
]));
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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);
}
......@@ -26,13 +26,13 @@ export function Item2({ id1, id2 }) {
id1++;
temp.push(<Button action={deleteItem}>Delete</Button>);
return temp;
var deleteItem = registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1).bind(null, encryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", [
var deleteItem = registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
id1,
id2
]));
}
export async function $$ACTION_1($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1] = await decryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_CLOSURE_BOUND);
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);
}
/* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
const noop = (action)=>action;
export const log = noop(registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0));
export async function $$ACTION_0(data) {
export const log = noop(registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0));
export async function $$RSC_SERVER_ACTION_0(data) {
console.log(data);
}
// Rules here:
// 1. Each exported function should still be exported, but as a reference `registerServerReference(...)`.
// 2. Actual action functions should be renamed to `$$ACTION_...` and got exported.
/* __next_internal_action_entry_do_not_use__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","56a859f462d35a297c46a1bbd1e6a9058c104ab8":"$$ACTION_3","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","9878bfa39811ca7650992850a8751f9591b6a557":"$$ACTION_2","9c0dd1f7c2b3f41d32e10f5c437de3d67ad32c6c":"$$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";
var foo = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
export async function $$ACTION_0() {
var foo = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
export async function $$RSC_SERVER_ACTION_0() {
console.log(1);
}
export { foo };
export var bar = registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1);
export async function $$ACTION_1() {
export var bar = registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1);
export async function $$RSC_SERVER_ACTION_1() {
console.log(2);
}
export default registerServerReference("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_2);
export async function $$ACTION_2() {
export default registerServerReference("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$RSC_SERVER_ACTION_2);
export async function $$RSC_SERVER_ACTION_2() {
console.log(3);
}
export const qux = registerServerReference("56a859f462d35a297c46a1bbd1e6a9058c104ab8", $$ACTION_3);
export async function $$ACTION_3() {
export const qux = registerServerReference("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", $$RSC_SERVER_ACTION_3);
export async function $$RSC_SERVER_ACTION_3() {
console.log(4);
}
export const quux = registerServerReference("9c0dd1f7c2b3f41d32e10f5c437de3d67ad32c6c", $$ACTION_4);
export async function $$ACTION_4() {
export const quux = registerServerReference("a9b2939c1f39073a6bed227fd20233064c8b7869", $$RSC_SERVER_ACTION_4);
export async function $$RSC_SERVER_ACTION_4() {
console.log(5);
}
/* __next_internal_action_entry_do_not_use__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","9878bfa39811ca7650992850a8751f9591b6a557":"$$ACTION_2"} */ 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";
let a, f;
function Comp(b, c, ...g) {
return registerServerReference("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_2).bind(null, encryptActionBoundArgs("9878bfa39811ca7650992850a8751f9591b6a557", [
return registerServerReference("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$RSC_SERVER_ACTION_2).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
b,
c,
g
]));
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND, e) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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);
console.log(a, $$ACTION_ARG_0, $$ACTION_ARG_1, e, $$ACTION_ARG_2, $$ACTION_ARG_3);
}
export async function $$ACTION_1($$ACTION_CLOSURE_BOUND, e) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_CLOSURE_BOUND);
export async function $$RSC_SERVER_ACTION_1($$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 $$ACTION_2($$ACTION_CLOSURE_BOUND, d) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_CLOSURE_BOUND);
export async function $$RSC_SERVER_ACTION_2($$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, {
window
});
console.log(a, $$ACTION_ARG_0, action2);
var action2 = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
var action2 = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
$$ACTION_ARG_1,
d,
f,
......@@ -32,7 +32,7 @@ export async function $$ACTION_2($$ACTION_CLOSURE_BOUND, d) {
]));
return [
action2,
registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1).bind(null, encryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", [
registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
action2,
$$ACTION_ARG_1,
d
......
/* __next_internal_action_entry_do_not_use__ {"28baf972d345b86b747ad0df73d75a0088a42214":"dec","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference";
/* __next_internal_action_entry_do_not_use__ {"28baf972d345b86b747ad0df73d75a0088a42214":"dec","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export const dec = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
export async function $$ACTION_0(value) {
export const dec = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
export async function $$RSC_SERVER_ACTION_0(value) {
return value - 1;
}
// Test case for https://github.com/vercel/next.js/issues/54655
......@@ -12,4 +12,4 @@ ensureServerEntryExports([
dec
]);
registerServerReference("28baf972d345b86b747ad0df73d75a0088a42214", dec);
registerServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", dec);
\ No newline at end of file
registerServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", dec);
/* __next_internal_action_entry_do_not_use__ {"0090eaf4e1f08a2d94f6be401e54a2ded399b87c":"action0","188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","9878bfa39811ca7650992850a8751f9591b6a557":"$$ACTION_2"} */ 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";
let a, f;
export async function action0(b, c, ...g) {
return registerServerReference("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_2).bind(null, encryptActionBoundArgs("9878bfa39811ca7650992850a8751f9591b6a557", [
return registerServerReference("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", $$RSC_SERVER_ACTION_2).bind(null, encryptActionBoundArgs("1c36b06e398c97abe5d5d7ae8c672bfddf4e1b91", [
b,
c,
g
]));
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND, e) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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);
console.log(a, $$ACTION_ARG_0, $$ACTION_ARG_1, e, $$ACTION_ARG_2, $$ACTION_ARG_3);
}
export async function $$ACTION_1($$ACTION_CLOSURE_BOUND, e) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_CLOSURE_BOUND);
export async function $$RSC_SERVER_ACTION_1($$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 $$ACTION_2($$ACTION_CLOSURE_BOUND, d) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("9878bfa39811ca7650992850a8751f9591b6a557", $$ACTION_CLOSURE_BOUND);
export async function $$RSC_SERVER_ACTION_2($$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, {
window
});
console.log(a, $$ACTION_ARG_0, action2);
var action2 = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
var action2 = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
$$ACTION_ARG_1,
d,
f,
......@@ -32,7 +32,7 @@ export async function $$ACTION_2($$ACTION_CLOSURE_BOUND, d) {
]));
return [
action2,
registerServerReference("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1).bind(null, encryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", [
registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
action2,
$$ACTION_ARG_1,
d
......
/* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
export function Component() {
const data = [
......@@ -16,15 +16,15 @@ export function Component() {
current: 1
}
};
var action = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
var action = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
data,
baz.value,
foo
]));
return <form action={action}/>;
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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));
}
\ No newline at end of file
}
const v = 'world'
async function fn() {
'use cache'
return 'hello, ' + v
}
export async function Component() {
const data = await fn()
return <div>{data}</div>
}
/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ 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";
const v = 'world';
export var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function fn() {
return 'hello, ' + v;
});
var fn = registerServerReference("3128060c414d59f8552e4788b846c0d2b7f74743", $$RSC_SERVER_CACHE_0);
export async function Component() {
const data = await fn();
return <div>{data}</div>;
}
'use cache'
export async function foo() {
return 'data'
}
/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ 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 var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function foo() {
return 'data';
});
export var foo = registerServerReference("3128060c414d59f8552e4788b846c0d2b7f74743", $$RSC_SERVER_CACHE_0);
'use cache'
export const my_fn = async () => {
return 'data'
}
/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_0"} */ 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 var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function() {
return 'data';
});
export const my_fn = registerServerReference("3128060c414d59f8552e4788b846c0d2b7f74743", $$RSC_SERVER_CACHE_0);
'use cache'
export async function foo() {
return 'data A'
}
export async function bar() {
return 'data B'
}
/* __next_internal_action_entry_do_not_use__ {"3128060c414d59f8552e4788b846c0d2b7f74743":"$$RSC_SERVER_CACHE_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 var $$RSC_SERVER_CACHE_0 = $$cache__("default", "3128060c414d59f8552e4788b846c0d2b7f74743", async function foo() {
return 'data A';
});
export var foo = registerServerReference("3128060c414d59f8552e4788b846c0d2b7f74743", $$RSC_SERVER_CACHE_0);
export var $$RSC_SERVER_CACHE_1 = $$cache__("default", "951c375b4a6a6e89d67b743ec5808127cfde405d", async function bar() {
return 'data B';
});
export var bar = registerServerReference("951c375b4a6a6e89d67b743ec5808127cfde405d", $$RSC_SERVER_CACHE_1);
/* __next_internal_action_entry_do_not_use__ {"1ab723c80dcca470e0410b4b2a2fc2bf21f41476":"c","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","6e7bc104e4d6e7fda190c4a51be969cfd0be6d6d":"a","d1f7eb64271d7c601dfef7d4d7053de1c2ca4338":"b"} */ import { registerServerReference } from "private-next-rsc-server-reference";
/* __next_internal_action_entry_do_not_use__ {"1ab723c80dcca470e0410b4b2a2fc2bf21f41476":"c","6a88810ecce4a4e8b59d53b8327d7e98bbf251d7":"$$RSC_SERVER_ACTION_0","6e7bc104e4d6e7fda190c4a51be969cfd0be6d6d":"a","d1f7eb64271d7c601dfef7d4d7053de1c2ca4338":"b"} */ import { registerServerReference } from "private-next-rsc-server-reference";
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption";
export async function a() {}
export async function b() {}
export async function c() {}
function d() {}
function Foo() {
var e = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
var e = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
}
export async function $$ACTION_0() {}
export async function $$RSC_SERVER_ACTION_0() {}
import { ensureServerEntryExports } from "private-next-rsc-action-validate";
ensureServerEntryExports([
a,
......
/* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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 deleteFromDb from 'db';
const v1 = 'v1';
export function Item({ id1, id2, id3, id4 }) {
const v2 = id2;
var deleteItem = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
var deleteItem = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
id1,
v2,
id3,
......@@ -12,8 +12,8 @@ export function Item({ id1, id2, id3, id4 }) {
]));
return <Button action={deleteItem}>Delete</Button>;
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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);
......
/* __next_internal_action_entry_do_not_use__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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 f, { f1, f2 } from 'foo';
const f3 = 1;
......@@ -19,7 +19,7 @@ export function y(p, [p1, { p2 }], ...p3) {
if (true) {
const f8 = 1;
}
var action = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
var action = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
f2,
f11,
p,
......@@ -29,8 +29,8 @@ export function y(p, [p1, { p2 }], ...p3) {
]));
return <Button action={action}>Delete</Button>;
}
export async function $$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("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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;
......
/* __next_internal_action_entry_do_not_use__ {"188d5d945750dc32e2c842b93c75a65763d4a922":"$$ACTION_1","56a859f462d35a297c46a1bbd1e6a9058c104ab8":"$$ACTION_3","6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$ACTION_0","9c0dd1f7c2b3f41d32e10f5c437de3d67ad32c6c":"$$ACTION_4"} */ 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","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 deleteFromDb from 'db';
export function Item1(product, foo, bar) {
const a = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0).bind(null, encryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", [
const a = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0).bind(null, encryptActionBoundArgs("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", [
product,
foo,
bar
]));
return <Button action={a}>Delete</Button>;
}
export async function $$ACTION_0($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_CLOSURE_BOUND);
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);
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("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_1).bind(null, encryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", [
var deleteItem2 = registerServerReference("90b5db271335765a4b0eab01f044b381b5ebd5cd", $$RSC_SERVER_ACTION_1).bind(null, encryptActionBoundArgs("90b5db271335765a4b0eab01f044b381b5ebd5cd", [
product,
foo,
bar
]));
return <Button action={deleteItem2}>Delete</Button>;
}
export async function $$ACTION_1($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_CLOSURE_BOUND);
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);
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("56a859f462d35a297c46a1bbd1e6a9058c104ab8", $$ACTION_3).bind(null, encryptActionBoundArgs("56a859f462d35a297c46a1bbd1e6a9058c104ab8", [
const deleteItem3 = registerServerReference("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", $$RSC_SERVER_ACTION_3).bind(null, encryptActionBoundArgs("9ed0cc47abc4e1c64320cf42b74ae60b58c40f00", [
product,
foo,
bar
]));
return <Button action={deleteItem3}>Delete</Button>;
}
export async function $$ACTION_3($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("56a859f462d35a297c46a1bbd1e6a9058c104ab8", $$ACTION_CLOSURE_BOUND);
export async function $$RSC_SERVER_ACTION_3($$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("9c0dd1f7c2b3f41d32e10f5c437de3d67ad32c6c", $$ACTION_4).bind(null, encryptActionBoundArgs("9c0dd1f7c2b3f41d32e10f5c437de3d67ad32c6c", [
const deleteItem4 = registerServerReference("a9b2939c1f39073a6bed227fd20233064c8b7869", $$RSC_SERVER_ACTION_4).bind(null, encryptActionBoundArgs("a9b2939c1f39073a6bed227fd20233064c8b7869", [
product,
foo,
bar
]));
return <Button action={deleteItem4}>Delete</Button>;
}
export async function $$ACTION_4($$ACTION_CLOSURE_BOUND) {
var [$$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2] = await decryptActionBoundArgs("9c0dd1f7c2b3f41d32e10f5c437de3d67ad32c6c", $$ACTION_CLOSURE_BOUND);
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__ {"6d53ce510b2e36499b8f56038817b9bad86cabb4":"$$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";
var myAction = registerServerReference("6d53ce510b2e36499b8f56038817b9bad86cabb4", $$ACTION_0);
export async function $$ACTION_0(a, b, c) {
var myAction = registerServerReference("6a88810ecce4a4e8b59d53b8327d7e98bbf251d7", $$RSC_SERVER_ACTION_0);
export async function $$RSC_SERVER_ACTION_0(a, b, c) {
// comment
'use strict';
console.log('a');
......
......@@ -8,6 +8,7 @@ import {
RSC_ACTION_CLIENT_WRAPPER_ALIAS,
RSC_ACTION_VALIDATE_ALIAS,
RSC_ACTION_ENCRYPTION_ALIAS,
RSC_CACHE_WRAPPER_ALIAS,
type WebpackLayerName,
} from '../lib/constants'
import type { NextConfigComplete } from '../server/config-shared'
......@@ -151,6 +152,9 @@ export function createWebpackAliases({
[RSC_ACTION_ENCRYPTION_ALIAS]: 'next/dist/server/app-render/encryption',
[RSC_CACHE_WRAPPER_ALIAS]:
'next/dist/build/webpack/loaders/next-flight-loader/cache-wrapper',
...(isClient || isEdgeServer
? {
[clientResolveRewrites]: hasRewrites
......
......@@ -192,7 +192,7 @@ export function makeExternalHandler({
}
const notExternalModules =
/^(?:private-next-pages\/|next\/(?:dist\/pages\/|(?:app|document|link|form|image|legacy\/image|constants|dynamic|script|navigation|headers|router)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-server-reference$)/
/^(?:private-next-pages\/|next\/(?:dist\/pages\/|(?:app|document|link|form|image|legacy\/image|constants|dynamic|script|navigation|headers|router)$)|string-hash|private-next-rsc-action-validate|private-next-rsc-action-client-wrapper|private-next-rsc-server-reference|private-next-rsc-cache-wrapper$)/
if (notExternalModules.test(request)) {
return
}
......
export function cache(_kind: string, _id: string, fn: any) {
return fn
}
......@@ -1213,5 +1213,5 @@ function getModuleResource(mod: webpack.NormalModule): string {
// x-ref crates/next-custom-transforms/src/transforms/server_actions.rs `gen_ident` funcition
function isInlineActionIdentifier(name: string) {
return name.startsWith('$$ACTION_')
return name.startsWith('$$RSC_SERVER_')
}
......@@ -345,6 +345,7 @@ export class ClientReferenceManifestPlugin {
function addSSRIdMapping() {
const exportName = resource
if (
// TODO: Add mapping from client module IDs to RSC module IDs
typeof pluginState.serverModuleIds[ssrNamedModuleId] !== 'undefined'
) {
moduleIdMapping[modId] = moduleIdMapping[modId] || {}
......
......@@ -48,6 +48,7 @@ export const APP_DIR_ALIAS = 'private-next-app-dir'
export const RSC_MOD_REF_PROXY_ALIAS = 'private-next-rsc-mod-ref-proxy'
export const RSC_ACTION_VALIDATE_ALIAS = 'private-next-rsc-action-validate'
export const RSC_ACTION_PROXY_ALIAS = 'private-next-rsc-server-reference'
export const RSC_CACHE_WRAPPER_ALIAS = 'private-next-rsc-cache-wrapper'
export const RSC_ACTION_ENCRYPTION_ALIAS = 'private-next-rsc-action-encryption'
export const RSC_ACTION_CLIENT_WRAPPER_ALIAS =
'private-next-rsc-action-client-wrapper'
......
......@@ -390,13 +390,13 @@ impl DepGraph {
// Workaround for implcit export issue of server actions.
//
// Inline server actions require the generated `$$ACTION_0` to be **exported**.
// Inline server actions require the generated `$$RSC_SERVER_0` to be **exported**.
//
// But tree shaking works by removing unused code, and the **export** of $$ACTION_0 is
// cleary not used from the external module as it does not exist at all in the user
// code.
// But tree shaking works by removing unused code, and the **export** of $$RSC_SERVER_0
// is cleary not used from the external module as it does not exist at all
// in the user code.
//
// So we need to add an import for $$ACTION_0 to the module, so that the export is
// So we need to add an import for $$RSC_SERVER_0 to the module, so that the export is
// preserved.
if use_export_instead_of_declarator {
for (other_ix, other_group) in groups.graph_ix.iter().enumerate() {
......@@ -408,7 +408,7 @@ impl DepGraph {
for other_item in other_group {
if let ItemId::Group(ItemIdGroupKind::Export(export, _)) = other_item {
if !export.0.as_str().starts_with("$$ACTION_") {
if !export.0.as_str().starts_with("$$RSC_SERVER_") {
continue;
}
......
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