Unverified Commit 2988be2a authored by Shu Ding's avatar Shu Ding Committed by GitHub

Update server reference syntax and tests (#46389)

parent b942a6f4
......@@ -166,6 +166,17 @@ impl<C: Comments> VisitMut for ServerActions<C> {
.push(annotate(&f.ident, "$$name", action_name.into()));
if self.top_level {
// myAction.$$bound = [];
self.annotations.push(annotate(
&f.ident,
"$$bound",
ArrayLit {
span: DUMMY_SP,
elems: Vec::new(),
}
.into(),
));
if !(self.in_action_file && self.in_export_decl) {
// export const $ACTION_myAction = myAction;
self.extra_items
......@@ -197,10 +208,10 @@ impl<C: Comments> VisitMut for ServerActions<C> {
used_ids: &ids_from_closure,
});
// myAction.$$closure = [id1, id2]
// myAction.$$bound = [id1, id2]
self.annotations.push(annotate(
&f.ident,
"$$closure",
"$$bound",
ArrayLit {
span: DUMMY_SP,
elems: ids_from_closure
......@@ -218,7 +229,7 @@ impl<C: Comments> VisitMut for ServerActions<C> {
args: vec![f
.ident
.clone()
.make_member(quote_ident!("$$closure"))
.make_member(quote_ident!("$$bound"))
.as_arg()],
type_args: Default::default(),
};
......
......@@ -2,3 +2,4 @@
foo.$$typeof = Symbol.for("react.server.reference");
foo.$$filepath = "/app/item.js";
foo.$$name = "foo";
foo.$$bound = [];
\ No newline at end of file
......@@ -3,3 +3,4 @@ export function bar() {}
bar.$$typeof = Symbol.for("react.server.reference");
bar.$$filepath = "/app/item.js";
bar.$$name = "bar";
bar.$$bound = [];
\ No newline at end of file
/* __next_internal_action_entry_do_not_use__ $ACTION_deleteItem */ import deleteFromDb from 'db'
export function Item({ id1 , id2 }) {
async function deleteItem() {
return $ACTION_deleteItem(deleteItem.$$closure);
return $ACTION_deleteItem(deleteItem.$$bound);
}
deleteItem.$$typeof = Symbol.for("react.server.reference");
deleteItem.$$filepath = "/app/item.js";
deleteItem.$$name = "$ACTION_deleteItem";
deleteItem.$$closure = [
deleteItem.$$bound = [
id1,
id2
];
......
......@@ -4,6 +4,7 @@
myAction.$$typeof = Symbol.for("react.server.reference");
myAction.$$filepath = "/app/item.js";
myAction.$$name = "$ACTION_myAction";
myAction.$$bound = [];
export const $ACTION_myAction = myAction;
export default function Page() {
return <Button action={myAction}>Delete</Button>;
......
......@@ -5,3 +5,4 @@
myAction.$$typeof = Symbol.for("react.server.reference");
myAction.$$filepath = "/app/item.js";
myAction.$$name = "myAction";
myAction.$$bound = [];
......@@ -2,22 +2,25 @@
a.$$typeof = Symbol.for("react.server.reference");
a.$$filepath = "/app/item.js";
a.$$name = "a";
a.$$bound = [];
export async function b() {}
b.$$typeof = Symbol.for("react.server.reference");
b.$$filepath = "/app/item.js";
b.$$name = "b";
b.$$bound = [];
export async function c() {}
c.$$typeof = Symbol.for("react.server.reference");
c.$$filepath = "/app/item.js";
c.$$name = "c";
c.$$bound = [];
function d() {}
function Foo() {
async function e() {
return $ACTION_e(e.$$closure);
return $ACTION_e(e.$$bound);
}
e.$$typeof = Symbol.for("react.server.reference");
e.$$filepath = "/app/item.js";
e.$$name = "$ACTION_e";
e.$$closure = [];
e.$$bound = [];
}
export async function $ACTION_e(closure) {}
\ No newline at end of file
......@@ -3,12 +3,12 @@ const v1 = 'v1';
export function Item({ id1 , id2 }) {
const v2 = id2;
async function deleteItem() {
return $ACTION_deleteItem(deleteItem.$$closure);
return $ACTION_deleteItem(deleteItem.$$bound);
}
deleteItem.$$typeof = Symbol.for("react.server.reference");
deleteItem.$$filepath = "/app/item.js";
deleteItem.$$name = "$ACTION_deleteItem";
deleteItem.$$closure = [
deleteItem.$$bound = [
id1,
v2
];
......
......@@ -18,12 +18,12 @@ export function y(p, [p1, { p2 }], ...p3) {
const f8 = 1;
}
async function action() {
return $ACTION_action(action.$$closure);
return $ACTION_action(action.$$bound);
}
action.$$typeof = Symbol.for("react.server.reference");
action.$$filepath = "/app/item.js";
action.$$name = "$ACTION_action";
action.$$closure = [
action.$$bound = [
f2,
f2,
f11,
......
/* __next_internal_action_entry_do_not_use__ $ACTION_deleteItem */ import deleteFromDb from 'db';
export function Item(product, foo, bar) {
async function deleteItem() {
return $ACTION_deleteItem(deleteItem.$$closure);
return $ACTION_deleteItem(deleteItem.$$bound);
}
deleteItem.$$typeof = Symbol.for("react.server.reference");
deleteItem.$$filepath = "/app/item.js";
deleteItem.$$name = "$ACTION_deleteItem";
deleteItem.$$closure = [
deleteItem.$$bound = [
product.id,
product?.foo,
product.bar.baz,
......
......@@ -6,6 +6,7 @@
myAction.$$typeof = Symbol.for("react.server.reference");
myAction.$$filepath = "/app/item.js";
myAction.$$name = "$ACTION_myAction";
myAction.$$bound = [];
export const $ACTION_myAction = myAction;
export default function Page() {
return <Button action={myAction}>Delete</Button>;
......
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