-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
…ions (#71463) With this PR, we're adding one extra leading byte to Server Reference IDs (both Server Actions and `"use cache"` functions), to include some static information about the function itself. The information byte has the following format: ``` 0 000000 0 ^type ^arg mask ^rest args ``` The type bit represents if the action is a cache function or not. For cache functions, the type bit is set to `1`. Otherwise, it's `0`. The arg mask bit is used to determine which arguments are used by the function itself, up to 6 arguments. The bit is set to `1` if the argument is used, or being spread or destructured (so it can be indirectly or partially used). The bit is set to `0` otherwise. The rest args bit is used to determine if there's a `...` rest argument in the function signature. If there is, the bit is set to `1`. For example: ```tsx async function foo(a, foo, b, bar, ...baz) { 'use cache'; return a + b; } ``` will have it encoded as `[1][101011][1]`. The first bit is set to `1` because it's a cache function. The second part has `1010` because the only arguments used are `a` and `b`. The subsequent `11` bits are set to `1` because there's a `...baz` argument starting from the 5th. The last bit is set to `1` as well for the same reason. Note: Currently in this PR we don't track if an argument is actually referenced in the function body or not. That will be implemented as a follow-up optimization. Also, the reference ID is currently hex-encoded so there will be exact 2 characters for easier decoding. This encoding might change though. With this extra byte, the client can do some further optimizations. More details can be found in the code comment.
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
/* __next_internal_action_entry_do_not_use__ {"00ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
export function foo() {} | ||
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; | ||
ensureServerEntryExports([ | ||
foo | ||
]); | ||
registerServerReference(foo, "ab21efdafbe611287bc25c0462b1e0510d13e48b", null); | ||
registerServerReference(foo, "00ab21efdafbe611287bc25c0462b1e0510d13e48b", null); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
/* __next_internal_action_entry_do_not_use__ {"00ac840dcaf5e8197cb02b7f3a43c119b7a770b272":"bar"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
'use strict'; | ||
export function bar() {} | ||
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; | ||
ensureServerEntryExports([ | ||
bar | ||
]); | ||
registerServerReference(bar, "ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null); | ||
registerServerReference(bar, "00ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// app/send.ts | ||
/* __next_internal_action_entry_do_not_use__ {"ab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; | ||
export var foo = /*#__PURE__*/ createServerReference("ab21efdafbe611287bc25c0462b1e0510d13e48b", callServer, void 0, findSourceMapURL, "foo"); | ||
/* __next_internal_action_entry_do_not_use__ {"7fab21efdafbe611287bc25c0462b1e0510d13e48b":"foo"} */ import { createServerReference, callServer, findSourceMapURL } from "private-next-rsc-action-client-wrapper"; | ||
export var foo = /*#__PURE__*/ createServerReference("7fab21efdafbe611287bc25c0462b1e0510d13e48b", callServer, void 0, findSourceMapURL, "foo"); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
/* __next_internal_action_entry_do_not_use__ {"00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
export default async function foo() {} | ||
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; | ||
ensureServerEntryExports([ | ||
foo | ||
]); | ||
registerServerReference(foo, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); | ||
registerServerReference(foo, "00c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/* __next_internal_action_entry_do_not_use__ {"c18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
/* __next_internal_action_entry_do_not_use__ {"7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d":"default"} */ import { registerServerReference } from "private-next-rsc-server-reference"; | ||
import { encryptActionBoundArgs, decryptActionBoundArgs } from "private-next-rsc-action-encryption"; | ||
async function foo() {} | ||
export default foo; | ||
import { ensureServerEntryExports } from "private-next-rsc-action-validate"; | ||
ensureServerEntryExports([ | ||
foo | ||
]); | ||
registerServerReference(foo, "c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); | ||
registerServerReference(foo, "7fc18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null); |